Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix traceback raised on an expression list assignment (#439)
When there is an assignment using a pattern_list and expression_list, the current code will iterate through each assignment. However, the current code assumes it can use context['node'], which is not the expected node during the parse. ```console : Language(path, name) is deprecated. Use Language(ptr, name) instead. warn("{} is deprecated. Use {} instead.".format(old, new), FutureWarning) logging initialized Working on file: tests/unit/parsers/examples/expression_list_assignment.py Exception occurred when executing rules against tests/unit/parsers/examples/expression_list_assignment.py. Run "precli --debug tests/unit/parsers/examples/expression_list_assignment.py" to see the full traceback. Exception string: cannot access local variable 'func_node' where it is not associated with a value Exception traceback: Traceback (most recent call last): File "/Users/ericwb/workspace/precli/precli/core/run.py", line 127, in parse_file return parser.parse(artifact) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ericwb/workspace/precli/precli/parsers/__init__.py", line 99, in parse self.visit([tree.root_node]) File "/Users/ericwb/workspace/precli/precli/parsers/__init__.py", line 124, in visit visitor_fn(node.children) File "/Users/ericwb/workspace/precli/precli/parsers/python.py", line 31, in visit_module self.visit(nodes) File "/Users/ericwb/workspace/precli/precli/parsers/__init__.py", line 124, in visit visitor_fn(node.children) File "/Users/ericwb/workspace/precli/precli/parsers/__init__.py", line 124, in visit visitor_fn(node.children) File "/Users/ericwb/workspace/precli/precli/parsers/python.py", line 98, in visit_assignment self.visit_assignment( File "/Users/ericwb/workspace/precli/precli/parsers/python.py", line 145, in visit_assignment func_node=func_node, ^^^^^^^^^ UnboundLocalError: cannot access local variable 'func_node' where it is not associated with a value ``` Signed-off-by: Eric Brown <eric.brown@securesauce.dev>
- Loading branch information