Skip to content

Commit 38a8a6c

Browse files
simeonschaubKristofferC
authored andcommitted
fix macro hygiene for @nospecialize(::T) (#40293)
(cherry picked from commit 73aa7e4)
1 parent fcdbfe5 commit 38a8a6c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/macroexpand.scm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@
210210
((atom? v) '())
211211
(else
212212
(case (car v)
213-
((... kw |::| =) (try-arg-name (cadr v)))
213+
((|::|) (if (length= v 2) '() (try-arg-name (cadr v))))
214+
((... kw =) (try-arg-name (cadr v)))
214215
((escape) (list v))
215216
((hygienic-scope) (try-arg-name (cadr v)))
216217
((meta) ;; allow certain per-argument annotations

test/syntax.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,3 +2686,9 @@ macro m_begin_hygiene(a)
26862686
end
26872687

26882688
@test @m_begin_hygiene([1, 2, 3]) == 1
2689+
2690+
macro m_nospecialize_unnamed_hygiene()
2691+
return :(f(@nospecialize(::Any)) = Any)
2692+
end
2693+
2694+
@test @m_nospecialize_unnamed_hygiene()(1) === Any

0 commit comments

Comments
 (0)