Skip to content

Commit 2655a3a

Browse files
authored
Drop use of something in reflection.jl (#38067)
* Drop use of `something` in reflection.jl reflection.jl is included in Core.Compiler, but the `something` function is not, so we cannot use it here. Throw an explicit error instead. I considered having it not throw the error when `err==false`, but it seems to me like passing such a UnionAll is just a user error, rather than an acceptable query, so I left it as is and simply did the bug fix. * Update base/reflection.jl
1 parent 44b55d1 commit 2655a3a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

base/reflection.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,13 @@ function fieldindex(T::DataType, name::Symbol, err::Bool=true)
638638
return Int(ccall(:jl_field_index, Cint, (Any, Any, Cint), T, name, err)+1)
639639
end
640640

641-
fieldindex(t::UnionAll, name::Symbol, err::Bool=true) = fieldindex(something(argument_datatype(t)), name, err)
641+
function fieldindex(t::UnionAll, name::Symbol, err::Bool=true)
642+
t = argument_datatype(t)
643+
if t === nothing
644+
throw(ArgumentError("type does not have definite fields"))
645+
end
646+
return fieldindex(t, name, err)
647+
end
642648

643649
argument_datatype(@nospecialize t) = ccall(:jl_argument_datatype, Any, (Any,), t)
644650

0 commit comments

Comments
 (0)