You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This case is ambiguous as it might be either one of the following;
require the user to explicitly disambiguate between them
```
function (@f(x),)
body
end
function @f(x)
body
end
```
For the same reasons, `function ($f) body end` is also ambiguous.
Also fix parsing of `function (f(x),) end` to correctly emit a tuple.
@@ -2128,7 +2129,14 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
2128
2129
# function (x,y) end ==> (function (tuple-p x y) (block))
2129
2130
# function (x=1) end ==> (function (tuple-p (= x 1)) (block))
2130
2131
# function (;x=1) end ==> (function (tuple-p (parameters (= x 1))) (block))
2132
+
# function (f(x),) end ==> (function (tuple-p (call f x)) (block))
2133
+
ambiguous_parens = opts.maybe_grouping_parens &&
2134
+
peek_behind(ps).kind inKSet"macrocall $"
2131
2135
emit(ps, mark, K"tuple", PARENS_FLAG)
2136
+
if ambiguous_parens
2137
+
# Got something like `(@f(x))`. Is it anon `(@f(x),)` or named sig `@f(x)` ??
2138
+
emit(ps, mark, K"error", error="Ambiguous signature. Add a trailing comma if this is a 1-argument anonymous function; remove parentheses if this is a macro call acting as function signature.")
2139
+
end
2132
2140
elseif is_empty_tuple
2133
2141
# Weird case which is consistent with parse_paren but will be
0 commit comments