julia
e277ceca - [JuliaLowering] Accept splatted rhs in `where` and type alias defs

Commit
25 days ago
[JuliaLowering] Accept splatted rhs in `where` and type alias defs Running JETLS on Compiler/test/inference.jl reported a lowering error for the regression test for #51310: https://github.com/JuliaLang/julia/blob/bf8238154e7abd3181ce2d014ba91c8b5cfc5fec/Compiler/test/inference.jl#L7142 @test code_typed() do b{c} = d... end |> only |> first isa Core.CodeInfo flisp lowers a type alias `X{T} = rhs` via `rhs where T` into `Core.UnionAll(T, rhs)`, so a splatted rhs (and likewise `(x...) where T`) simply becomes a splat into that call, i.e. `Core.UnionAll(T, x...)`. JuliaLowering's validation instead rejected the `...` as a splat outside of a call. The `where` expansion already produces the `Core.UnionAll` call, so allowing the splat in validation is enough to match flisp's IR. Plain assignments such as `b = d...` or `b{c} = d = e...` are still rejected, as in flisp. Whether this should become an error in the future: the form is practically meaningless, since it only works when `x` iterates to exactly one element, and it is accepted by flisp only as a side effect of how `where` is expanded. Rejecting it would give a clearer error for what is almost certainly a mistake, but it would break code that lowers fine today, so I believe that would need to be done under a new syntax edition (e.g. gated on `is_flisp_compat`). The #51310 test exists to exercise inference of `Core.UnionAll` with a vararg argument, which the adjacent `UnionAll(some.value...)` test already covers directly, so it could be rewritten if the syntax were ever rejected. For now this follows the existing flisp-compat behavior unconditionally. Assisted-by: Claude Code (Opus 5.5)
Author
Committer
Parents
Loading