SMAT-Lab / Scalpel

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

Error in SSA.const #7

Closed billquan closed 2 years ago

billquan commented 2 years ago

https://github.com/SMAT-Lab/Scalpel/blob/ec5dd9068f84b77eb8da1c17660bdf5835d6f741/tests/test_typeinfer_with_real_libs.py#L136

SSA module gives an error when testing typeinfer, the error can be reproduced by running the python file linked above.

The traceback is as follows: Traceback (most recent call last): File "xxxx\Scalpel/tests/test_typeinfer_with_real_libs.py", line 155, in test_pytest_case4() File "xxxx\Scalpel/tests/test_typeinfer_with_real_libs.py", line 135, in test_pytest_case4 infferer.infer_types() File "xxxx\Scalpel\scalpel\typeinfer\typeinfer.py", line 128, in infer_types processed_file = self.process_file(node.source) File "xxxx\Scalpel\scalpel\typeinfer\typeinfer.py", line 382, in process_file return_visitor.visit(function_node) File "xxxx\AppData\Local\Programs\Python\Python38-32\Lib\ast.py", line 360, in visit return visitor(node) File "xxxx\Scalpel\scalpel\typeinfer\analysers.py", line 593, in visit_FunctionDef self.type_infer_CFG(node) File "xxxx\Scalpel\scalpel\typeinfer\analysers.py", line 721, in type_infer_CFG ssa_results, ident_const_dict = ssa_analyzer.compute_SSA(cfg) File "xxxx\Scalpel\scalpel\SSA\const.py", line 123, in compute_SSA stored_idents, loaded_idents, func_names = self.get_stmt_idents_ctx(stmt, const_dict=tmp_const_dict) File "xxxx\Scalpel\scalpel\SSA\const.py", line 208, in get_stmt_idents_ctx left_name = stmt.targets[0].id AttributeError: 'AnnAssign' object has no attribute 'targets'

Jarvx commented 2 years ago

The test case now gives no error.