Skip to content

Commit

Permalink
fix macro hygiene for @nospecialize(::T) (#40293)
Browse files Browse the repository at this point in the history
(cherry picked from commit 73aa7e4)
  • Loading branch information
simeonschaub authored and staticfloat committed Dec 22, 2022
1 parent 22ba73d commit 21b80e0
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 @@ -2686,3 +2686,9 @@ macro m_begin_hygiene(a)
end

@test @m_begin_hygiene([1, 2, 3]) == 1

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

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

0 comments on commit 21b80e0

Please sign in to comment.