Skip to content

Commit e2de9b3

Browse files
committed
fix #27807, hygiene issue in static parameters
1 parent c404bb7 commit e2de9b3

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/macroexpand.scm

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@
5959
;; function definition
6060
(pattern-lambda (function (-$ (call name . argl) (|::| (call name . argl) _t)) body)
6161
(cons 'varlist (safe-llist-positional-args (fix-arglist argl))))
62-
(pattern-lambda (function (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
63-
(cons 'varlist (append (safe-llist-positional-args (fix-arglist argl))
64-
(typevar-names wheres))))
62+
(pattern-lambda (function (where callspec . wheres) body)
63+
(let ((others (pattern-expand1 vars-introduced-by-patterns `(function ,callspec ,body))))
64+
(cons 'varlist (append (if (and (pair? others) (eq? (car others) 'varlist))
65+
(cdr others)
66+
'())
67+
(typevar-names wheres)))))
6568

6669
(pattern-lambda (function (tuple . args) body)
6770
`(-> (tuple ,@args) ,body))
@@ -71,7 +74,7 @@
7174
`(function (call (curly ,name . ,sparams) . ,argl) ,body))
7275
(pattern-lambda (= (-$ (call name . argl) (|::| (call name . argl) _t)) body)
7376
`(function (call ,name ,@argl) ,body))
74-
(pattern-lambda (= (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
77+
(pattern-lambda (= (where callspec . wheres) body)
7578
(cons 'function (cdr __)))
7679

7780
;; anonymous function
@@ -150,14 +153,14 @@
150153

151154
(pattern-lambda (function (-$ (call name . argl) (|::| (call name . argl) _t)) body)
152155
(cons 'varlist (safe-llist-keyword-args (fix-arglist argl))))
153-
(pattern-lambda (function (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
154-
(cons 'varlist (safe-llist-keyword-args (fix-arglist argl))))
156+
(pattern-lambda (function (where callspec . wheres) body)
157+
`(function ,callspec ,body))
155158

156159
(pattern-lambda (= (call (curly name . sparams) . argl) body)
157160
`(function (call (curly ,name . ,sparams) . ,argl) ,body))
158161
(pattern-lambda (= (-$ (call name . argl) (|::| (call name . argl) _t)) body)
159162
`(function (call ,name ,@argl) ,body))
160-
(pattern-lambda (= (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
163+
(pattern-lambda (= (where callspec . wheres) body)
161164
(cons 'function (cdr __)))
162165
))
163166

test/syntax.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,3 +1489,15 @@ let val(::Type{Val{X}}) where {X} = X, f
14891489
end
14901490
@test val(first(methods(f())).sig.parameters[2])(21) == 42
14911491
end
1492+
1493+
# issue #27807
1494+
module A27807
1495+
macro m()
1496+
quote
1497+
function foo(x::T, y::S) where T<:Number where S<:Number
1498+
return one(T), zero(S)
1499+
end
1500+
end
1501+
end
1502+
end
1503+
@test A27807.@m()(1,1.0) === (1, 0.0)

0 commit comments

Comments
 (0)