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

parse error on for loop in macro in function call #32182

Open
yha opened this issue May 29, 2019 · 3 comments
Open

parse error on for loop in macro in function call #32182

yha opened this issue May 29, 2019 · 3 comments
Labels
parser Language parsing and surface syntax

Comments

@yha
Copy link
Contributor

yha commented May 29, 2019

These trigger a syntax error, which seems wrong:

foo(@bar for i in x; end)  # => ERROR: syntax: unexpected "end"

foo(@bar for i in x
    i
end)  # => ERROR: syntax: missing comma or ) in argument list

These parse fine:

foo(@bar while i in x; end)
foo(@bar while i in x; 
    i
end)
foo(@bar begin for i in x; end end)
foo(begin @bar for i in x; end end)
julia> versioninfo()
Julia Version 1.1.1
Commit 55e36cc308 (2019-05-16 04:10 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i9-7940X CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 14
@JeffBezanson
Copy link
Member

See #18650. We decided to resolve this ambiguity in favor of generators, since for loops do not return values. Granted, the macro could do something to make the for loop return a value. Did this arise from a real world case like that?

@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label May 29, 2019
@yha
Copy link
Contributor Author

yha commented May 29, 2019

Yes, I was trying to do something like

using Interact
pad(1em, @manipulate for filename=dropdown(readdir(dir))
    ...
end)

So if I understand correctly, it tries to parse this as a generator expression as if it said pad(1em, (@manipulate) for ... end)?

@JeffBezanson
Copy link
Member

Yes.

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

No branches or pull requests

2 participants