Skip to content

Commit 9c563ad

Browse files
authored
Fix rewrap-where for anonymous function parse (#47315)
Was throwing away the tail of the list, dropping the result of where clauses. Fixes #45506
1 parent def946a commit 9c563ad

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/julia-parser.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@
13521352

13531353
(define (rewrap-where x w)
13541354
(if (and (pair? w) (eq? (car w) 'where))
1355-
(list 'where (rewrap-where x (cadr w)) (caddr w))
1355+
(list* 'where (rewrap-where x (cadr w)) (cddr w))
13561356
x))
13571357

13581358
(define (parse-struct-field s)

test/syntax.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,12 @@ let f = function (x::T, y::S) where T<:S where S
878878
@test f(0,1) === (Int,Int)
879879
end
880880

881+
# issue #45506
882+
@test :( function (a) where {B, C} end).args[1] == Expr(:where, Expr(:tuple, :a), :B, :C)
883+
@test (function(::Type{Tuple{A45506, B45506}}) where {A45506 <: Any, B45506 <: Any}
884+
B45506
885+
end)(Tuple{Int8, Int16}) == Int16
886+
881887
# issue #20541
882888
@test Meta.parse("[a .!b]") == Expr(:hcat, :a, Expr(:call, :.!, :b))
883889

0 commit comments

Comments
 (0)