Commit 63572713

63572713b0ceMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Fix rest_end OOB when pure splat fills fixed+rest params

When calling mix(*arr) where mix(a,b,*rest), rest_end was clamped to the rest param index (2) even though the caller only had 1 argv element. This caused emit_rest_from_splat_and_argv's suffix loop to access argv[1] out-of-bounds, accidentally reading a RestParameterNode as an argument and failing with "unsupported boxing value into poly".

The clamping is unnecessary: both emit_rest_pack and emit_rest_from_splat_and_argv already handle pos_argc <= from as an empty range.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

Details

Commit
63572713b0ce
Parent
5a9c9717155c

src/codegen.cmodifiedView file

@@ -2921,7 +2921,6 @@
29212921 if (m->rest_idx >= 0 && i == m->rest_idx) {
29222922 /* rest collects middle args; stop before post-splat params */
29232923 int rest_end = pos_argc - m->npost_rest;
2924- if (rest_end < i) rest_end = i;
29252924 if (splat_tmp >= 0) {
29262925 emit_rest_from_splat_and_argv(splat_tmp, splat_at, i - splat_idx,
29272926 c, splat_idx + 1, rest_end, argv, out);