Skip to content

type inference regression in 1.10.0-alpha1 when using @propagate_inbounds #50544

Closed
@matthias314

Description

@matthias314

I've noticed this in real code, but here is a MWE:

struct A{T<:Tuple} t::T; end

Base.@propagate_inbounds f(x, i, ii...) = f(f(x, i), ii...)   
Base.@propagate_inbounds f(::Type{A{T}}, i) where T = T.parameters[i]

g(T...) = A{Tuple{T...}}

h(x::T) where T = g(f(T, 1), f(T, 2, 1))

a = A((1, A((2.0, 'x'))))
@code_typed h(a)

With 1.10.0-alpha I get

=> Type{A{var"#s173"}} where var"#s173"<:Tuple{Int64, Vararg}

With 1.9.2 it's

=> Type{A{Tuple{Int64, Float64}}}

Without @propagate_inbounds the inference works also for 1.10.0-alpha1.

My understanding is that Julia's type inference capabilities are not guaranteed. So maybe you think this is a bug, maybe not.

Julia Version 1.10.0-alpha1
Commit f8ad15f7b16 (2023-07-06 10:36 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, sandybridge)
  Threads: 1 on 24 virtual cores

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions