SMAT-Lab / Scalpel

Scalpel: The Python Static Analysis Framework
Apache License 2.0
286 stars 43 forks source link

Bug in SSA usage in typeinfer.analyser #15

Closed billquan closed 2 years ago

billquan commented 2 years ago

https://github.com/SMAT-Lab/Scalpel/blob/a8d967dd1181d9583ce1e26bdb8ba4e43d65c74f/tests/tmp_test_script_for_issue.py#L5 The SSA part can give a KeyError when running typeinfer, the error can be reproduced by running the script linked above.

The traceback is as follows: Traceback (most recent call last): File "C:/Scalpel/tests/tmp_test_script_for_issue.py", line 5, in inferer.infer_types() File "C:\Scalpel\scalpel\typeinfer\typeinfer.py", line 113, in infer_types processed_file = self.process_file(node.source) File "C:\Scalpel\scalpel\typeinfer\typeinfer.py", line 403, in process_file return_visitor.visit(function_node) File "C:\Anaconda3\Lib\ast.py", line 253, in visit return visitor(node) File "C:\Scalpel\scalpel\typeinfer\analysers.py", line 670, in visit_FunctionDef self.type_infer_CFG(node) File "C:\Scalpel\scalpel\typeinfer\analysers.py", line 832, in type_infer_CFG return_values = get_return_value(block) File "C:\Scalpel\scalpel\typeinfer\analysers.py", line 825, in get_return_value const_values.append(ident_const_dict[stmt.value.id, ident_no]) KeyError: ('count', 1)

Jarvx commented 2 years ago

The issue has been fixed.