Commit 92db1827
92db18276631Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 5 files · +1 added · ~4 modified
Description
Add sprintf, $0, inline rescue expr, symbol-key hashes, hash literal fix
- sprintf as alias for format (both call sp_format helper)
- $0 / $PROGRAM_NAME → argv[0]
- Inline rescue as expression: x = expr rescue default
- Symbol-key hashes with string values → sp_RbHash
- Fix: homogeneous integer hash literals now populate entries
- sp_raise forward declaration fix for poly + exc coexistence
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 92db18276631
- Parent
- 12c30d221adc
examples/bm_misc2.rbaddedView file
1+
# Test format/sprintf2+
puts format("%d:%02d", 5, 3)3+
puts sprintf("hello %s %d", "world", 42)4+
5+
# Test inline rescue as expression6+
x = raise("oops") rescue 427+
puts x8+
9+
# Test symbol key hash (string values -> sp_RbHash)10+
h = {running: "green", waiting: "yellow"}11+
puts h[:running]12+
puts h[:waiting]13+
14+
# Test symbol key hash with integer values (-> sp_StrIntHash)15+
h2 = {a: 1, b: 2}16+
puts h2[:a]17+
puts h2[:b]src/codegen.cmodifiedView file
Loading diff…
src/emit.cmodifiedView file
Loading diff…
src/expr.cmodifiedView file
Loading diff…
src/type.cmodifiedView file
Loading diff…