Skip to content

Commit 471f019

Browse files
committed
fix index operator
1 parent 81e921a commit 471f019

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

crates/emmylua_code_analysis/src/semantic/infer/infer_index.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,10 @@ fn infer_member_by_index_custom_type(
458458
.get_operator(operator_id)
459459
.ok_or(InferFailReason::None)?;
460460
let operands = operator.get_operands();
461-
462-
if operands.len() == 2 {
461+
let return_type = operator.get_result();
462+
if operands.len() == 1 {
463463
let typ =
464-
infer_index_metamethod(db, cache, &index_key, &operands[0], &operands[1])?;
464+
infer_index_metamethod(db, cache, &index_key, &operands[0], &return_type)?;
465465
return Ok(typ);
466466
}
467467
}
@@ -642,14 +642,16 @@ fn infer_member_by_index_generic(
642642
.iter()
643643
.map(|operand| instantiate_type_generic(db, operand, &substitutor))
644644
.collect::<Vec<_>>();
645+
let return_type =
646+
instantiate_type_generic(db, index_operator.get_result(), &substitutor);
645647

646-
if instianted_operands.len() == 2 {
648+
if instianted_operands.len() == 1 {
647649
let result = infer_index_metamethod(
648650
db,
649651
cache,
650652
&member_key,
651653
&instianted_operands[0],
652-
&instianted_operands[1],
654+
&return_type,
653655
);
654656

655657
match result {

0 commit comments

Comments
 (0)