File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 382
382
383
383
function showerror (io:: IO , exc:: FieldError )
384
384
@nospecialize
385
- print (io, " FieldError: type $(exc. type |> nameof ) has no field `$(exc. field) `" )
385
+ print (io, " FieldError: type $(exc. type. name . wrapper ) has no field `$(exc. field) `" )
386
386
Base. Experimental. show_error_hints (io, exc)
387
387
end
388
388
Original file line number Diff line number Diff line change @@ -1332,3 +1332,22 @@ let err_str
1332
1332
err_str = @except_str f56325 (1 ,2 ) MethodError
1333
1333
@test occursin (" The anonymous function" , err_str)
1334
1334
end
1335
+
1336
+ @testset " FieldError with changing fields" begin
1337
+ # https://discourse.julialang.org/t/better-error-message-for-modified-structs-in-julia-1-12/129265
1338
+ module FieldErrorTest
1339
+ struct Point end
1340
+ p = Point ()
1341
+ end
1342
+
1343
+ err_str1 = @except_str FieldErrorTest. p. x FieldError
1344
+ @test occursin (" FieldErrorTest.Point" , err_str1)
1345
+
1346
+ @eval FieldErrorTest struct Point{T}
1347
+ x:: T
1348
+ y:: T
1349
+ end
1350
+ err_str2 = @except_str FieldErrorTest. p. x FieldError
1351
+ @test occursin (" @world" , err_str2)
1352
+ @test occursin (" FieldErrorTest.Point" , err_str2)
1353
+ end
You can’t perform that action at this time.
0 commit comments