Skip to content

Incorrect type inference for getfield with varargs #57292

@xal-0

Description

@xal-0

Vararg handling in getfield_tfunc is brittle:

julia> foo(xs::Union{Tuple{String}, Int}...) = getfield(xs...)
foo (generic function with 1 method)

julia> code_typed(foo)
1-element Vector{Any}:
 CodeInfo(
1 ─     Core._apply_iterate(Base.iterate, Main.getfield, xs)::Union{}
└──     unreachable
) => Union{}

julia> foo(("hello",), 1)

[27438] signal 4 (1): Illegal instruction: 4
in expression starting at REPL[3]:1
foo at ./REPL[1]:1
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XC9YQX9HH2.0/build/default-honeycrisp-XC9YQX9HH2-0/julialang/julia-release-1-dot-11/src/./julia.h:2157 [inlined]

(Found while trying to understand enough of getfield_tfunc and getfield_nothrow to fix #56056 (comment))

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorcompiler:inferenceType inference

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions