Commit 86e03011

86e03011912eMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · ~2 modified

Description

fix(analyze,codegen): SuperNode + tail-arith infer-type promote sweep

@nd_inferred_type was populated by annotate_all_node_types AFTER the global int -> bigint sweep, but several arms still cached an "int" type:

  • SuperNode: cls_method_return was returning the post-promotion bigint for direct calls, but a still-int cached value for the super reference confused compile_body_return's coerce.
  • Arith CallNode chains (super + 5): infer_type for the outer + stayed cached "int" even though the operand-side analysis said the recv side returned bigint.

Two tweaks:

  • analyze: after annotate, sweep @nd_inferred_type and rewrite "int" -> "bigint" for SuperNode / ForwardingSuperNode entries.
  • codegen: compile_body_return peeks arith operand types so a tail super + N (where super is bigint and N is an int literal) doesn't re-wrap the already-bigint sum.

Promote-mode test count: 534 pass / 53 fail / 31 error -> 535 pass / 53 fail / 30 error. Default raise mode 618 / 0 / 0.

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
86e03011912e
Parent
5d63d8292198

spinel_analyze.rbmodifiedView file

@@ -21520,6 +21520,27 @@
2152021520 end
2152121521 end
2152221522 annotate_all_node_types
21523+ # Promote-mode safety: annotate may have produced stale "int"
21524+ # entries for nodes whose inferred type derived from cached
21525+ # state captured before promote_int_to_bigint_globally landed
21526+ # (SuperNode reading cls_method_return's pre-promotion result,
21527+ # CallNode chains whose mid-tree return type was cached, etc.).
21528+ # Sweep `@nd_inferred_type` again and rewrite "int" -> "bigint"
21529+ # for node kinds whose concrete C emit is always bigint when the
21530+ # underlying slot is promoted.
21531+ if @int_overflow_mode == "promote"
21532+ ni_p = 0
21533+ while ni_p < @nd_inferred_type.length
21534+ tp = @nd_inferred_type[ni_p]
21535+ if tp == "int"
21536+ ntp = @nd_type[ni_p]
21537+ if ntp == "SuperNode" || ntp == "ForwardingSuperNode"
21538+ @nd_inferred_type[ni_p] = "bigint"
21539+ end
21540+ end
21541+ ni_p = ni_p + 1
21542+ end
21543+ end
2152321544 # Now that @nd_inferred_type is populated for every reachable
2152421545 # node, we can resolve `recv.method(...)`'s receiver class
2152521546 # cheaply. Check each RBS-pinned method's positional args at