Skip to content

Commit f8c92ee

Browse files
Fix error messages in DataLayouts (#2275)
1 parent 342b1c0 commit f8c92ee

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/DataLayouts/DataLayouts.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ end
364364

365365
@noinline _property_view(
366366
data::AbstractData{S},
367-
::Val{Nothing},
367+
::Val{nothing},
368368
name,
369-
) where {S} = error("Invalid field name $name for type $(S)")
369+
) where {S} = error("Invalid field name `$name` for type `$(S)`.")
370370

371371
# In the past, we've sometimes needed a generated function
372372
# for inference and constant propagation:

test/DataLayouts/data0d.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#=
2-
julia --project=test
2+
julia --project
33
using Revise; include(joinpath("test", "DataLayouts", "data0d.jl"))
44
=#
55
using Test
@@ -65,6 +65,14 @@ end
6565
@test_throws MethodError data[] = SB
6666
end
6767

68+
@testset "DataF error messages" begin
69+
SA = (; a = 1.0)
70+
data = DataF{typeof(SA)}(ArrayType{Float64})
71+
@test_throws ErrorException(
72+
"Invalid field name `oops` for type `$(typeof(SA))`.",
73+
) data.oops
74+
end
75+
6876
@testset "DataF broadcasting between 0D data objects and scalars" begin
6977
for FT in TestFloatTypes
7078
S = Complex{FT}

0 commit comments

Comments
 (0)