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))
12
12
return true
13
13
end
14
14
15
+ explain_nonisbits (@nospecialize (T), depth= 0 ) = " " ^ depth * " $T is not a bitstype\n "
16
+
15
17
function explain_eltype (@nospecialize (T), depth= 0 ; maxdepth= 10 )
16
18
depth > maxdepth && return " "
17
19
46
48
# 3. bitstype unions (`Union{Int, Float32}`, etc)
47
49
# these are stored contiguously and require a selector array (handled by us)
48
50
@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
50
53
explanation = explain_eltype (T)
51
54
error ("""
52
55
$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
55
55
a:: Any
56
56
end
57
57
const MyBadType2 = Union{BigFloat, Float32}
58
+ struct MyBadType3
59
+ a:: MyBadType2
60
+ end
58
61
@testset " Bad CuArray eltype" begin
59
62
@test_throws ErrorException CuArray {MyBadType, 1} (undef, 64 )
60
63
@test_throws ErrorException CuArray {MyBadType2, 1} (undef, 64 )
64
+ @test_throws ErrorException CuArray {MyBadType3, 1} (undef, 64 )
61
65
end
62
66
63
67
@testset " synchronization" begin
You can’t perform that action at this time.
0 commit comments