julia
64d45186 - [JuliaLowering] Avoid creating global binding for keyword slurp argument (#60600)

Commit
99 days ago
[JuliaLowering] Avoid creating global binding for keyword slurp argument (#60600) When `use_ssa_kw_temps=false` (i.e., when a keyword default depends on another keyword name), `kw_val_vars` was set to `kw_names` which included the slurp argument. Since the slurp argument is passed via `remaining_kws`, including it in `kw_val_vars` caused: 1. The slurp name to be referenced as an unbound `Identifier` in kwcall 2. Scope analysis resolving it as a global binding 3. The call to body method having an extra argument This fix excludes the slurp argument from `kw_val_vars` when `has_kw_slurp=true`, since it's always the last element of `kw_names`. IR change in kwcall method for `f(; a=1, b=a, kws...) = (a, b, kws)`: Before: 22 TestMod.#f#0 23 slot₅/a 24 slot₆/b 25 Main.kws # unwanted global 26 (call %₂₂ %₂₃ %₂₄ %₂₅ %₂₁ slot₃/#self#) # extra argument After: 22 TestMod.#f#0 23 slot₅/a 24 slot₆/b 25 (call %₂₂ %₂₃ %₂₄ %₂₁ slot₃/#self#) # correct This fix is important not only for the correctness of the IR generated by JuliaLowering, but also it eliminates false positive undefined global variable reports that JETLS would report for cases like the following: ```julia function f_kw_slurp_dep(; a=1, b=a, kws...) (a, b, kws) end ``` Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Author
Parents
Loading