Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type inference for getfield with varargs #57292

Open
xal-0 opened this issue Feb 6, 2025 · 0 comments · May be fixed by #57293
Open

Incorrect type inference for getfield with varargs #57292

xal-0 opened this issue Feb 6, 2025 · 0 comments · May be fixed by #57293
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference

Comments

@xal-0
Copy link
Contributor

xal-0 commented Feb 6, 2025

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))

@xal-0 xal-0 added bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference labels Feb 6, 2025
@xal-0 xal-0 self-assigned this Feb 6, 2025
xal-0 added a commit to xal-0/julia that referenced this issue Feb 6, 2025
Even if T has no intersection with the type we want, we don't know that we will
throw, because the arguments are optional.

Fixes JuliaLang#57292.
@xal-0 xal-0 linked a pull request Feb 6, 2025 that will close this issue
xal-0 added a commit to xal-0/julia that referenced this issue Feb 7, 2025
Even if T has no intersection with the type we want, we don't know that we will
throw, because the arguments are optional.

Fixes JuliaLang#57292.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant