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

Misplaced tracebacks from some models created in the reader #2422

Closed
Kodiologist opened this issue Mar 25, 2023 · 0 comments · Fixed by #2423
Closed

Misplaced tracebacks from some models created in the reader #2422

Kodiologist opened this issue Mar 25, 2023 · 0 comments · Fixed by #2423
Labels

Comments

@Kodiologist
Copy link
Member

$ echo ';;;;;;\na.b' >ex.hy
$ hy ex.hy 
Traceback (most recent call last):
  …
  File "/tmp/ex.hy", line 1, in <module>
    ;;;;;;
NameError: name 'a' is not defined

The error is wrongly attributed to line 1 because the reader fails to set position information for a model created during the expansion of a.b into (. a b). Contrast with this case, which is correct:

$ echo ';;;;;;\n(. a b)' >ex.hy
$ hy ex.hy                     
Traceback (most recent call last):
  …
  File "/tmp/ex.hy", line 2, in <module>
    (. a b)
NameError: name 'a' is not defined

I believe it suffices to call model.replace(model) in HyReader.fill_pos, so that positions are fixed recursively. I just need to write a test.

This bug is more consequential than it sounds because it can crash pytest internally, when non-existent columns of the source are retrieved for a traceback. Hy's own error reporting doesn't fail so badly in such a case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant