julia
20c5626e - subtype: fix sparam extraction for free-typevar singletons

Commit
10 days ago
subtype: fix sparam extraction for free-typevar singletons Fix fix_inferred_var_bound to distinguish between typevars that were peeled from LHS UnionAlls during subtyping (which should be re-wrapped) and typevars that are inherently free in the LHS (which are singletons and should be preserved as-is). When jl_type_intersection_env_s matches a <: b, it now passes the set of free typevars from `a` (the LHS) to fix_inferred_var_bound. The function only re-wraps typevars NOT in this set, and returns the result directly (not wrapped in a TypeVar) when LHS-free typevars remain. This makes f(Vector.body) correctly bind T = Array{T,1} (the singleton) rather than T<:Vector (a TypeVar). For the NamedTuple case (e.g. getindex(NamedTuple{names} where _A)), the typevar _A from the LHS UnionAll is NOT free in the LHS, so it gets re-wrapped correctly: T = NamedTuple{names, _A} where _A = NamedTuple{names} (the original UnionAll). Also add free-typevar checks in codegen (emit_sparam, uses_specsig, static_parameter_sym) to treat sparams with free typevars as unknown at compile time, requiring runtime resolution via the sparam_vals mechanism. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Parents
Loading