Skip to content

Commit 349e072

Browse files
authored
fix #38386, macro defining empty function with escaped name (#38402)
1 parent e24533d commit 349e072

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/macroexpand.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@
383383
,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg)))
384384

385385
((= function)
386-
(if (and (pair? (cadr e)) (function-def? e))
386+
(if (and (pair? (cadr e)) (function-def? e) (length> e 2))
387387
;; in (kw x 1) inside an arglist, the x isn't actually a kwarg
388388
`(,(car e) ,(resolve-in-function-lhs (cadr e) env m parent-scope inarg)
389389
,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg))

test/syntax.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,14 @@ end
26172617

26182618
@test eval(Expr(:if, Expr(:block, Expr(:&&, true, Expr(:call, :(===), 1, 1))), 1, 2)) == 1
26192619

2620+
# issue #38386
2621+
macro m38386()
2622+
fname = :f38386
2623+
:(function $(esc(fname)) end)
2624+
end
2625+
@m38386
2626+
@test isempty(methods(f38386))
2627+
26202628
@testset "all-underscore varargs on the rhs" begin
26212629
@test ncalls_in_lowered(quote _..., = a end, GlobalRef(Base, :rest)) == 0
26222630
@test ncalls_in_lowered(quote ___..., = a end, GlobalRef(Base, :rest)) == 0

0 commit comments

Comments
 (0)