File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ function hasfieldcount(@nospecialize(dt))
1212 return true
1313end
1414
15+ explain_nonisbits (@nospecialize (T), depth= 0 ) = " " ^ depth * " $T is not a bitstype\n "
16+
1517function explain_eltype (@nospecialize (T), depth= 0 ; maxdepth= 10 )
1618 depth > maxdepth && return " "
1719
4648# 3. bitstype unions (`Union{Int, Float32}`, etc)
4749# these are stored contiguously and require a selector array (handled by us)
4850@inline function check_eltype (name, T)
49- if ! Base. allocatedinline (T)
51+ eltype_is_invalid = ! Base. allocatedinline (T) || (hasfieldcount (T) && any (! Base. allocatedinline, fieldtypes (T)))
52+ if eltype_is_invalid
5053 explanation = explain_eltype (T)
5154 error ("""
5255 $name only supports element types that are allocated inline.
Original file line number Diff line number Diff line change @@ -55,9 +55,13 @@ mutable struct MyBadType
5555 a:: Any
5656end
5757const MyBadType2 = Union{BigFloat, Float32}
58+ struct MyBadType3
59+ a:: MyBadType2
60+ end
5861@testset " Bad CuArray eltype" begin
5962 @test_throws ErrorException CuArray {MyBadType, 1} (undef, 64 )
6063 @test_throws ErrorException CuArray {MyBadType2, 1} (undef, 64 )
64+ @test_throws ErrorException CuArray {MyBadType3, 1} (undef, 64 )
6165end
6266
6367@testset " synchronization" begin
You can’t perform that action at this time.
0 commit comments