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 from type T{} in anonymous function #41253

Closed
stevengj opened this issue Jun 17, 2021 · 3 comments · Fixed by #41259 or #41382
Closed

parse error from type T{} in anonymous function #41253

stevengj opened this issue Jun 17, 2021 · 3 comments · Fixed by #41259 or #41382
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior parser Language parsing and surface syntax

Comments

@stevengj
Copy link
Member

stevengj commented Jun 17, 2021

This seems inconsistent (from discourse):

julia> function foo(::Dict{}); end
foo (generic function with 1 method)

julia> function(::Dict{}); end
ERROR: syntax: expected "(" in function definition
Stacktrace:
 [1] top-level scope
   @ none:1

julia> function(::Dict); end
#5 (generic function with 1 method)

julia> (::Dict{}) -> nothing
#9 (generic function with 1 method)
@stevengj stevengj added bug Indicates an unexpected problem or unintended behavior parser Language parsing and surface syntax labels Jun 17, 2021
@JeffBezanson JeffBezanson self-assigned this Jun 17, 2021
@A1-Mathematik
Copy link
Contributor

A1-Mathematik commented Jun 18, 2021

I don't know if that's also fix with that

julia> f(a = (b::String)::Bool -> true) = a
ERROR: syntax: "b::String" is not a valid function argument name around REPL[13]:1
Stacktrace:
 [1] top-level scope
   @ REPL[13]:1

julia> f(a = (b::String)::Bool -> begin true end) = a
ERROR: syntax: "b::String" is not a valid function argument name around REPL[14]:1
Stacktrace:
 [1] top-level scope
   @ REPL[14]:1

@A1-Mathematik
Copy link
Contributor

julia> function(a::Int)::Bool end
ERROR: syntax: ambiguous signature in function definition. Try adding a comma if this is a 1-argument anonymous function.
Stacktrace:
 [1] top-level scope
   @ none:1

julia> function(a::Int,)::Bool end
ERROR: syntax: ambiguous signature in function definition. Try adding a comma if this is a 1-argument anonymous function.
Stacktrace:
 [1] top-level scope
   @ none:1

julia> VERSION
v"1.8.0-DEV.94"

@stevengj
Copy link
Member Author

stevengj commented Jul 1, 2021

@A1-Mathematik, you should open a new issue since this seems to be a different problem.

johanmon pushed a commit to johanmon/julia that referenced this issue Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior parser Language parsing and surface syntax
Projects
None yet
3 participants