Commit a2f41ee2

a2f41ee2e787Merged

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

Description

feat: Phase 9 - fix poly detection, all 11 phase tests passing

Fix poly detection to not over-eagerly mark params as poly when the first type seen differs from the default "int". Distinguish between first-real-type update and genuinely-different-types.

Self-compilation: 0 errors (5379 warnings). Self-hosted binary generation from v1 Spinel is functional but the v1 compiler's string array handling limits full self-hosting verification (known v1 limitation).

All CRuby tests passing: bm_yield, bm_block2, bm_enumerable, bm_rescue, bm_fileio, bm_catch, bm_mutable_str, bm_struct, bm_pattern, bm_poly, bm_mega

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
a2f41ee2e787
Parent
696097b787fd

spinel_codegen.rbmodifiedView file

@@ -2872,9 +2872,20 @@
28722872 ct = ptypes[k]
28732873 if ct != at
28742874 if ct != "poly"
2875- # Types differ - mark as poly
2876- ptypes[k] = "poly"
2877- @needs_rb_value = 1
2875+ # Only mark as poly if both types are meaningful
2876+ # (not just default "int" vs actual type)
2877+ if ct == "int"
2878+ # First real type seen - update, don't mark poly
2879+ ptypes[k] = at
2880+ else
2881+ if at == "int"
2882+ # arg is int, param already has a type - keep it
2883+ else
2884+ # Genuinely different types - mark poly
2885+ ptypes[k] = "poly"
2886+ @needs_rb_value = 1
2887+ end
2888+ end
28782889 end
28792890 end
28802891 end