Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean logic short circuiting should lazily resolve variable references #127

Closed
d0c-s4vage opened this issue Jan 26, 2020 · 0 comments · Fixed by #128
Closed

Boolean logic short circuiting should lazily resolve variable references #127

d0c-s4vage opened this issue Jan 26, 2020 · 0 comments · Fixed by #128
Assignees
Labels
bug concrete-issue An actionable, concrete issue that includes stack trace & technical details. Usually post-triage

Comments

@d0c-s4vage
Copy link
Owner

Describe the bug

Short circuiting in 010 editor does not resolve variables until the actual comparison is made. E.g., consider the 010 template below:

local int a = 1;
if (a || DOES_NOT_EXIST) {
    Printf("Short circuit power!\n");
}

In 010 Editor, the string Short circuit power! is printed.

In pfp, the error UnresolvedID: Could not resolve field 'DOES_NOT_EXIST' is raised.

Stack Trace

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/james/__ws__/dev/pfp/pfp/__main__.py", line 61, in <module>
    main(sys.argv)
  File "/home/james/__ws__/dev/pfp/pfp/__main__.py", line 55, in main
    keep_successful=args.keep,
  File "/home/james/__ws__/dev/pfp/pfp/__init__.py", line 91, in parse
    printf=printf,
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 846, in parse
    res = self._run(keep_successful)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1051, in _run
    traceback,
  File "/home/james/__ws__/dev/pfp/venv3/lib/python3.6/site-packages/six.py", line 695, in reraise
    raise value.with_traceback(tb)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1024, in _run
    res = self._handle_node(self._ast, None, None, self._stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1133, in _handle_node
    res = self._node_switch[node.__class__](node, scope, ctxt, stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1177, in _handle_file_ast
    self._handle_node(child, scope, ctxt, stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1133, in _handle_node
    res = self._node_switch[node.__class__](node, scope, ctxt, stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2374, in _handle_if
    cond = self._handle_node(node.cond, scope, ctxt, stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1133, in _handle_node
    res = self._node_switch[node.__class__](node, scope, ctxt, stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1878, in _handle_binary_op
    right_val = self._handle_node(node.right, scope, ctxt, stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1133, in _handle_node
    res = self._node_switch[node.__class__](node, scope, ctxt, stream)
  File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2044, in _handle_id
    raise errors.UnresolvedID(node.coord, node.name)
pfp.errors.PfpError: UnresolvedID: Could not resolve field 'DOES_NOT_EXIST' at /tmp/tmpm_y_oum_:2
Exception at test.bt:2

To Reproduce

Run the provided 010 template

Expected Behavior

pfp should lazily resolve referenced variables during boolean logic operations

Implementation/Fix Notes/Thoughts

This could either be really easy, or really hard.

@d0c-s4vage d0c-s4vage added bug concrete-issue An actionable, concrete issue that includes stack trace & technical details. Usually post-triage labels Jan 26, 2020
@d0c-s4vage d0c-s4vage self-assigned this Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug concrete-issue An actionable, concrete issue that includes stack trace & technical details. Usually post-triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant