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

Parsing of binary operators in struct field names #41316

Open
Keno opened this issue Jun 22, 2021 · 1 comment
Open

Parsing of binary operators in struct field names #41316

Keno opened this issue Jun 22, 2021 · 1 comment
Labels
parser Language parsing and surface syntax

Comments

@Keno
Copy link
Member

Keno commented Jun 22, 2021

The following surprised me:

julia> struct Foo
           +::Function
       end
ERROR: syntax: invalid "::" syntax around REPL[22]:1
Stacktrace:
 [1] top-level scope
   @ REPL[22]:1

Now, I happen to know enough about Julia to know that the following would probably work:

julia> struct Foo
           (+)::Function
       end

but I can imagine many users would not know what to do. If there's nothing wrong with allowing
the first case, I would suggest we might want to consider doing that. Otherwise, it would
be nice to get some sort of hint in the error message to tell the user what to do.

@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label Jun 22, 2021
@JeffBezanson
Copy link
Sponsor Member

Parses as a unary call to + on the expression ::Function, which is pretty useless. We could try terminating unary parsing if the next token is ::; will take some fiddling no doubt.

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