-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
parserLanguage parsing and surface syntaxLanguage parsing and surface syntax
Description
From conversation with @c42f, the relative precedence of ::
and where
is strangely context dependent:
julia> using JuliaSyntax
julia> parsestmt(SyntaxNode, "function f()::T where T 0 end")
line:col│ tree │ file_name
1:1 │[function]
1:10 │ [where]
1:10 │ [::-i]
1:10 │ [call]
1:10 │ f
1:15 │ T
1:23 │ T
1:24 │ [block]
1:25 │ 0
julia> parsestmt(SyntaxNode, "f()::T where T = 0")
line:col│ tree │ file_name
1:1 │[=]
1:1 │ [::-i]
1:1 │ [call]
1:1 │ f
1:6 │ [where]
1:6 │ T
1:14 │ T
1:18 │ 0
This also reproduces on pre-JS versions, but is less unambiguously visible
julia> :(function f()::T where T 0 end)
:(function (f()::T) where T
#= REPL[26]:1 =#
#= REPL[26]:1 =#
0
end)
julia> :(f()::T where T = 0)
:(f()::(T where T) = begin
#= REPL[27]:1 =#
0
end)
Metadata
Metadata
Assignees
Labels
parserLanguage parsing and surface syntaxLanguage parsing and surface syntax