Skip to content

Commit d179f48

Browse files
JeffBezansonvchuravy
authored andcommitted
fix #38386, macro defining empty function with escaped name (#38402)
1 parent 24a4637 commit d179f48

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
@@ -2324,3 +2324,11 @@ end
23242324

23252325
@test (Int .<: [Integer] .<: [Real]) == [true]
23262326
end
2327+
2328+
# issue #38386
2329+
macro m38386()
2330+
fname = :f38386
2331+
:(function $(esc(fname)) end)
2332+
end
2333+
@m38386
2334+
@test isempty(methods(f38386))

0 commit comments

Comments
 (0)