vformat.rb: fix format/arg type mismatch in %!d test case

The test pushed mrb_int via vf.i but the format read int via %!d. On
x86_64/aarch64 the va_arg slots overlap so reading the low 32 bits of
the pushed int64 returned the right value, but on strict-alignment
ABIs (MIPS o32) va_arg(ap, int) reads the alignment padding and the
format prints 0 instead of the value.

Make the format match the helper: vf.i pairs with %!i (reads mrb_int),
matching the surrounding lines 44-50 convention and the "inspect
mrb_int" label.

Reported by vobloeb in #6857.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-05-24 10:31:14 +09:00
parent b1adab4e87
commit 36dd9eab88
+1 -1
View File
@@ -42,7 +42,7 @@ assert('mrb_vformat') do
assert_equal '`S`: {a: 1, "b" => "c"}', vf.v('`S`: %S', {a: 1, "b" => ?c})
assert_equal 'percent: %', vf.z('percent: %%')
assert_equal '"I": inspect char', vf.c('%!c: inspect char', ?I)
assert_equal '709: inspect mrb_int', vf.i('%!d: inspect mrb_int', 709)
assert_equal '709: inspect mrb_int', vf.i('%!i: inspect mrb_int', 709)
assert_equal '"a\x00b\xff"', vf.l('%!l', "a\000b\xFFc\000d", 4)
assert_equal ':"&.": inspect symbol', vf.n('%!n: inspect symbol', :'&.')
assert_equal 'inspect "String"', vf.v('inspect %!v', 'String')