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

Top-level statements like exports need LineNumberNodes #28991

Closed
epatters opened this issue Aug 31, 2018 · 1 comment
Closed

Top-level statements like exports need LineNumberNodes #28991

epatters opened this issue Aug 31, 2018 · 1 comment
Assignees
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) kind:bug Indicates an unexpected problem or unintended behavior

Comments

@epatters
Copy link

epatters commented Aug 31, 2018

As of Julia v0.7, running the snippet

eval(Expr(:toplevel,
   Expr(:module, true, :MyModule,
     Expr(:block, 
        Expr(:export, :Inner),
        Expr(:abstract, :Inner)))))

yields the error

ERROR: syntax: "export" expression not at top level
Stacktrace:
 [1] eval at ./boot.jl:319 [inlined]
 [2] eval(::Expr) at ./client.jl:399
 [3] top-level scope at none:0

After much tinkering, I discovered that adding a dummy LineNumberNode fixes the problem:

eval(Expr(:toplevel,
   Expr(:module, true, :MyModule,
     Expr(:block, 
        LineNumberNode(0),
        Expr(:export, :Inner),
        Expr(:abstract, :Inner)))))

Still, this seems like a bug, and the behavior didn't exist prior to v0.7. Possibly related to #28990.

@JeffBezanson JeffBezanson self-assigned this Sep 4, 2018
@JeffBezanson JeffBezanson added kind:bug Indicates an unexpected problem or unintended behavior compiler:lowering Syntax lowering (compiler front end, 2nd stage) labels Sep 4, 2018
JeffBezanson added a commit that referenced this issue Sep 4, 2018
The code for this expected the first element of a block to be a line
number; check to make sure it is before using it.
@epatters
Copy link
Author

epatters commented Sep 5, 2018

Thanks for the fix!

KristofferC pushed a commit that referenced this issue Sep 6, 2018
#29044)

The code for this expected the first element of a block to be a line
number; check to make sure it is before using it.

(cherry picked from commit 11e32a4)
KristofferC pushed a commit that referenced this issue Sep 8, 2018
#29044)

The code for this expected the first element of a block to be a line
number; check to make sure it is before using it.

(cherry picked from commit 11e32a4)
KristofferC pushed a commit that referenced this issue Sep 8, 2018
#29044)

The code for this expected the first element of a block to be a line
number; check to make sure it is before using it.

(cherry picked from commit 11e32a4)
KristofferC pushed a commit that referenced this issue Feb 11, 2019
#29044)

The code for this expected the first element of a block to be a line
number; check to make sure it is before using it.

(cherry picked from commit 11e32a4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants