JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.07k stars 5.43k forks source link

type application doesn't infer as consistent #54410

Open nsajko opened 2 months ago

nsajko commented 2 months ago
julia> struct S{T<:Tuple{Vararg{Nothing}}} end

julia> f() = S{<:Tuple{Vararg{Nothing}}}
f (generic function with 1 method)

julia> Base.infer_effects(f, Tuple{})
(?c,+e,!n,+t,+s,+m,+u)

julia> versioninfo()
Julia Version 1.12.0-DEV.489
Commit 29ced9e2a02 (2024-05-08 07:57 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-17.0.6 (ORCJIT, znver2)
Threads: 6 default, 0 interactive, 6 GC (on 8 virtual cores)

Older Julia versions have even worse effect inference for f.

vtjnash commented 2 months ago

This relates to a recent type egal question/bug: since each TypeVar is semantically distinct, the computation here is indeed !c, even though we then do cause and permit the UnionAll wrapped object returns here to be egal for all calls