Skip to content

Commit 13283ae

Browse files
committed
fix JuliaLang#36272: Error with optional argument in anonymous function defined in macro (JuliaLang#36273)
1 parent 39c169b commit 13283ae

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/macroexpand.scm

+5-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
((atom? v) '())
211211
(else
212212
(case (car v)
213-
((... kw |::|) (try-arg-name (cadr v)))
213+
((... kw |::| =) (try-arg-name (cadr v)))
214214
((escape) (list v))
215215
((hygienic-scope) (try-arg-name (cadr v)))
216216
((meta) ;; allow certain per-argument annotations
@@ -275,6 +275,9 @@
275275
,@(map (lambda (x)
276276
(resolve-expansion-vars-with-new-env x env m parent-scope #t))
277277
(cddr e))))
278+
((tuple) `(tuple ,@(map (lambda (x)
279+
(resolve-expansion-vars-with-new-env x env m parent-scope #t))
280+
(cdr e))))
278281
(else (other e))))
279282

280283
(define (new-expansion-env-for x env (outermost #f))
@@ -367,7 +370,7 @@
367370
(resolve-expansion-vars- x env m parent-scope #f)))
368371
(cdr e))))
369372

370-
((= function)
373+
((= function ->)
371374
(if (and (pair? (cadr e)) (function-def? e))
372375
;; in (kw x 1) inside an arglist, the x isn't actually a kwarg
373376
`(,(car e) ,(resolve-in-function-lhs (cadr e) env m parent-scope inarg)

test/syntax.jl

+6
Original file line numberDiff line numberDiff line change
@@ -2268,3 +2268,9 @@ end
22682268
# issue #36196
22692269
@test_throws ParseError("\"for\" at none:1 expected \"end\", got \")\"") Meta.parse("(for i=1; println())")
22702270
@test_throws ParseError("\"try\" at none:1 expected \"end\", got \")\"") Meta.parse("(try i=1; println())")
2271+
2272+
# issue #36272
2273+
macro m36272()
2274+
:((a, b=1) -> a*b)
2275+
end
2276+
@test @m36272()(1) == 1

0 commit comments

Comments
 (0)