File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ julia> ntuple(i -> 2*i, 4)
1414(2, 4, 6, 8)
1515```
1616"""
17- @inline function ntuple (f:: F , n:: Integer ) where F
17+ @inline function ntuple (f:: F , n:: Int ) where F
1818 # marked inline since this benefits from constant propagation of `n`
1919 t = n == 0 ? () :
2020 n == 1 ? (f (1 ),) :
@@ -30,8 +30,10 @@ julia> ntuple(i -> 2*i, 4)
3030 _ntuple (f, n)
3131 return t
3232end
33+ ntuple (f:: F , n:: Integer ) where F = ntuple (f, convert (Int, n):: Int )
3334
34- function _ntuple (f:: F , n) where F
35+ # `n` should always be an Int (#55790)
36+ function _ntuple (f:: F , n:: Int ) where F
3537 @noinline
3638 (n >= 0 ) || throw (ArgumentError (LazyString (" tuple length should be ≥ 0, got " , n)))
3739 ([f (i) for i = 1 : n]. .. ,)
Original file line number Diff line number Diff line change 534534 end
535535
536536 @test Base. infer_return_type (ntuple, Tuple{typeof (identity), Val}) == Tuple{Vararg{Int}}
537+
538+ # issue #55790
539+ for n in 1 : 32
540+ @test typeof (ntuple (identity, UInt64 (n))) == NTuple{n, Int}
541+ end
537542end
538543
539544struct A_15703{N}
You can’t perform that action at this time.
0 commit comments