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

Allow interpolation in using and export statement #11338

Merged
merged 2 commits into from
May 26, 2015

Conversation

yuyichao
Copy link
Contributor

This should be useful for some packages (especially for export). Using is probably less useful but why not....

Fix #11332

@yuyichao
Copy link
Contributor Author

Note that the test for using need to construct the whole AST manually because of #10910 .

@ihnorton
Copy link
Member

cc @jakebolewski

@tkelman tkelman added the parser Language parsing and surface syntax label May 21, 2015
@JeffBezanson
Copy link
Member

Looks fine. Just needs a rebase now.

@yuyichao
Copy link
Contributor Author

Done.

JeffBezanson added a commit that referenced this pull request May 26, 2015
Allow interpolation in using and export statement
@JeffBezanson JeffBezanson merged commit e650220 into JuliaLang:master May 26, 2015
@JeffBezanson
Copy link
Member

I think I'm going to have to revert this. It breaks parsing of imports like

import Base: &
x

where it now tries to parse & as a unary operator and so grabs the x on the next line.

@yuyichao
Copy link
Contributor Author

I see. I'll try to fix it and submit a new one.

@yuyichao
Copy link
Contributor Author

@JeffBezanson

I think this issue is not specific to export and import/using. parse-unary-prefix seems to parse pass newline.

julia> &
& (generic function with 35 methods)

julia> parse("a = &\nb")
:(a = &b)

julia> parse("a = &")
:(a = (&))

julia> a = &
& (generic function with 35 methods)

julia> a
& (generic function with 35 methods)

Is this intentional and I should special case export/import or I should fix parse-unary-prefix?

P.S. I thought you've already reverted it so I was taking my time before getting back to this.....

@yuyichao
Copy link
Contributor Author

@JeffBezanson

And the export/import is just a special case for it.

julia> parse("export &")
:(export &)

julia> parse("export &\na")
ERROR: ParseError("invalid \"export\" statement")
 in parse at ./string.jl:1257

julia> parse("export \$\na")
:(export $(Expr(:$, :a)))

@JeffBezanson
Copy link
Member

It's debatable whether parse-unary-prefix should do that, but there's no particular reason for export etc. to call parse-unary-prefix, so we have to fix export/import first. I'd fix it just for export/import.

@yuyichao
Copy link
Contributor Author

I'm just trying not to duplicate code. OK. I can special case export/import. (after dinner)

@JeffBezanson
Copy link
Member

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

export and import (using/importall) does not support interpolation
4 participants