Skip to content

Commit

Permalink
fix #38386, macro defining empty function with escaped name (#38402)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and Sacha0 committed Jan 21, 2021
1 parent f6e36a1 commit e8b16f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/macroexpand.scm
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg)))

((= function)
(if (and (pair? (cadr e)) (function-def? e))
(if (and (pair? (cadr e)) (function-def? e) (length> e 2))
;; in (kw x 1) inside an arglist, the x isn't actually a kwarg
`(,(car e) ,(resolve-in-function-lhs (cadr e) env m parent-scope inarg)
,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg))
Expand Down
8 changes: 8 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2324,3 +2324,11 @@ end

@test (Int .<: [Integer] .<: [Real]) == [true]
end

# issue #38386
macro m38386()
fname = :f38386
:(function $(esc(fname)) end)
end
@m38386
@test isempty(methods(f38386))

0 comments on commit e8b16f7

Please sign in to comment.