@@ -2016,6 +2016,7 @@ end
2016
2016
# Parse function and macro definitions
2017
2017
function parse_function_signature (ps:: ParseState , is_function:: Bool )
2018
2018
is_anon_func = false
2019
+ parsed_call = false
2019
2020
2020
2021
mark = position (ps)
2021
2022
if ! is_function
@@ -2053,17 +2054,7 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
2053
2054
parsed_call = _parsed_call)
2054
2055
end
2055
2056
is_anon_func = opts. is_anon_func
2056
- if opts. parsed_call
2057
- # Compat: Ugly case where extra parentheses existed and we've
2058
- # already parsed the whole signature.
2059
- # function (f() where T) end ==> (function (where (call f) T) (block))
2060
- # function (f()::S) end ==> (function (:: (call f) S) (block))
2061
- #
2062
- # TODO : Warn for use of parens? The precedence of `::` and
2063
- # `where` don't work inside parens so this is a bit of a syntax
2064
- # oddity/aberration.
2065
- return true
2066
- end
2057
+ parsed_call = opts. parsed_call
2067
2058
if is_anon_func
2068
2059
# function (x) body end ==> (function (tuple x) (block body))
2069
2060
# function (x::f()) end ==> (function (tuple (:: x (call f))) (block))
@@ -2099,10 +2090,10 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
2099
2090
end
2100
2091
end
2101
2092
end
2102
- if peek (ps, skip_newlines= true ) == K " end" && ! is_anon_func
2093
+ if peek (ps, skip_newlines= true ) == K " end" && ! is_anon_func && ! parsed_call
2103
2094
return false
2104
2095
end
2105
- if ! is_anon_func
2096
+ if ! is_anon_func && ! parsed_call
2106
2097
# Parse function argument list
2107
2098
# function f(x,y) end ==> (function (call f x y) (block))
2108
2099
# function f{T}() end ==> (function (call (curly f T)) (block))
@@ -2129,6 +2120,19 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
2129
2120
parse_where_chain (ps, mark)
2130
2121
end
2131
2122
# function f()::S where T end ==> (function (where (:: (call f) S) T) (block))
2123
+ #
2124
+ # Ugly cases for compat where extra parentheses existed and we've
2125
+ # already parsed at least the call part of the signature
2126
+ #
2127
+ # function (f() where T) end ==> (function (where (call f) T) (block))
2128
+ # function (f()) where T end ==> (function (where (call f) T) (block))
2129
+ # function (f() where T) where U end ==> (function (where (where (call f) T) U) (block))
2130
+ # function (f()::S) end ==> (function (:: (call f) S) (block))
2131
+ # function ((f()::S) where T) end ==> (function (where (:: (call f) S) T) (block))
2132
+ #
2133
+ # TODO : Warn for use of parens? The precedence of `::` and
2134
+ # `where` don't work inside parens so this is a bit of a syntax
2135
+ # oddity/aberration.
2132
2136
return true
2133
2137
end
2134
2138
0 commit comments