Skip to content

Commit d6ea2f2

Browse files
committed
[FIX] server: crash on rebuild arch of manually created function
1 parent d50bc03 commit d6ea2f2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/src/core/python_arch_builder.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ impl PythonArchBuilder {
113113
file_info_ast.ast.as_ref().unwrap()
114114
},
115115
false => {
116-
&AstUtils::find_stmt_from_ast(file_info_ast.ast.as_ref().unwrap(), self.sym_stack[0].borrow().ast_indexes().unwrap()).as_function_def_stmt().unwrap().body
116+
if !self.sym_stack[0].borrow().ast_indexes().unwrap().is_empty() {
117+
&AstUtils::find_stmt_from_ast(file_info_ast.ast.as_ref().unwrap(), self.sym_stack[0].borrow().ast_indexes().unwrap()).as_function_def_stmt().unwrap().body
118+
} else {
119+
//if ast_index is empty, this is because the function has been added manually and do not belong to the ast. Skip it's building
120+
&vec![]
121+
}
117122
}
118123
};
119124
let old_stack_noqa = session.noqas_stack.clone();

0 commit comments

Comments
 (0)