Skip to content

Commit

Permalink
fix advanced resolver walk_list_if_item_expr
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa committed Feb 1, 2024
1 parent 09aa50f commit 862e134
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions kclvm/sema/src/advanced_resolver/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ impl<'ctx> MutSelfTypedResultWalker<'ctx> for AdvancedResolver<'ctx> {
&mut self,
list_if_item_expr: &'ctx ast::ListIfItemExpr,
) -> Self::Result {
self.expr(&list_if_item_expr.if_cond)?;
if let Some(orelse) = &list_if_item_expr.orelse {
self.expr(orelse);
}
Expand Down
15 changes: 15 additions & 0 deletions kclvm/tools/src/LSP/src/goto_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,19 @@ mod tests {
let res = goto_definition_with_gs(&program, &pos, &gs);
compare_goto_res(res, (&file, 84, 22, 84, 23));
}

#[test]
#[bench_test]
fn list_if_expr_test() {
let (file, program, _, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k");

let pos = KCLPos {
filename: file.clone(),
line: 91,
column: Some(8),
};

let res = goto_definition_with_gs(&program, &pos, &gs);
compare_goto_res(res, (&file, 88, 0, 88, 1));
}
}
8 changes: 7 additions & 1 deletion kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_def.k
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,10 @@ p4 = Person {

func = lambda x: int, y: int -> int {
x + y
}
}

b = True
command: [str] = [
if b:
"a"
]

0 comments on commit 862e134

Please sign in to comment.