Skip to content

Commit

Permalink
fix macro hygiene for @nospecialize(::T) (#40293)
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub authored Apr 3, 2021
1 parent c0d2e1a commit 73aa7e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/macroexpand.scm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@
((atom? v) '())
(else
(case (car v)
((... kw |::| =) (try-arg-name (cadr v)))
((|::|) (if (length= v 2) '() (try-arg-name (cadr v))))
((... kw =) (try-arg-name (cadr v)))
((escape) (list v))
((hygienic-scope) (try-arg-name (cadr v)))
((meta) ;; allow certain per-argument annotations
Expand Down
6 changes: 6 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2771,3 +2771,9 @@ end

@test eval(Expr(:string, "a", Expr(:string, "b", "c"))) == "abc"
@test eval(Expr(:string, "a", Expr(:string, "b", Expr(:string, "c")))) == "abc"

macro m_nospecialize_unnamed_hygiene()
return :(f(@nospecialize(::Any)) = Any)
end

@test @m_nospecialize_unnamed_hygiene()(1) === Any

0 comments on commit 73aa7e4

Please sign in to comment.