@@ -2064,6 +2064,7 @@ end
2064
2064
function parse_function_signature (ps:: ParseState , is_function:: Bool )
2065
2065
is_anon_func = false
2066
2066
parsed_call = false
2067
+ needs_parse_call = true
2067
2068
2068
2069
mark = position (ps)
2069
2070
if ! is_function
@@ -2082,29 +2083,28 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
2082
2083
end
2083
2084
else
2084
2085
if peek (ps) != K " ("
2086
+ # function f() end ==> (function (call f))
2085
2087
parse_unary_prefix (ps)
2086
2088
else
2087
- # When an initial parenthesis is present, we might either have
2088
- # * the function name in parens, followed by (args...)
2089
- # * an anonymous function argument list in parens
2090
- # * the whole function declaration in parens
2091
- #
2092
- # This should somewhat parse as in parse_paren() (this is what
2093
- # the flisp parser does), but that results in weird parsing of
2094
- # keyword parameters. So we peek at a following `(` instead to
2095
- # distinguish the cases here.
2089
+ # When an initial parenthesis is present, we need to distinguish
2090
+ # between
2091
+ # * The function name in parens, followed by (args...)
2092
+ # * An anonymous function argument list in parens
2093
+ # * The whole function declaration, in parens
2096
2094
bump (ps, TRIVIA_FLAG)
2097
2095
is_empty_tuple = peek (ps, skip_newlines= true ) == K " )"
2098
2096
opts = parse_brackets (ps, K " )" ) do _, _, _, _
2099
2097
_parsed_call = was_eventually_call (ps)
2100
- t2 = peek_token (ps, 2 )
2101
- _is_anon_func = kind (t2) ∉ KSet " ( . " && ! _parsed_call
2098
+ _needs_parse_call = peek (ps, 2 ) ∈ KSet " ( . "
2099
+ _is_anon_func = ! _needs_parse_call && ! _parsed_call
2102
2100
return (needs_parameters = _is_anon_func,
2103
2101
is_anon_func = _is_anon_func,
2104
- parsed_call = _parsed_call)
2102
+ parsed_call = _parsed_call,
2103
+ needs_parse_call = _needs_parse_call)
2105
2104
end
2106
2105
is_anon_func = opts. is_anon_func
2107
2106
parsed_call = opts. parsed_call
2107
+ needs_parse_call = opts. needs_parse_call
2108
2108
if is_anon_func
2109
2109
# function (x) body end ==> (function (tuple-p x) (block body))
2110
2110
# function (x::f()) end ==> (function (tuple-p (::-i x (call f))) (block))
@@ -2122,6 +2122,7 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
2122
2122
# function (:)() end ==> (function (call (parens :)) (block))
2123
2123
# function (x::T)() end ==> (function (call (parens (::-i x T))) (block))
2124
2124
# function (::T)() end ==> (function (call (parens (::-pre T))) (block))
2125
+ # function (:*=(f))() end ==> (function (call (parens (call (quote-: *=) f))) (block))
2125
2126
emit (ps, mark, K " parens" , PARENS_FLAG)
2126
2127
end
2127
2128
end
@@ -2142,7 +2143,7 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
2142
2143
if peek (ps, skip_newlines= true ) == K " end" && ! is_anon_func && ! parsed_call
2143
2144
return false
2144
2145
end
2145
- if ! is_anon_func && ! parsed_call
2146
+ if needs_parse_call
2146
2147
# Parse function argument list
2147
2148
# function f(x,y) end ==> (function (call f x y) (block))
2148
2149
# function f{T}() end ==> (function (call (curly f T)) (block))
0 commit comments