Commit 75f5d853

75f5d853da80Merged

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

Description

analyze,codegen: Object#object_id on int / string / symbol

CRuby contract is "stable per object, unique-ish"; the exact numbers are implementation-defined. Spinel formulas: int -> 2*n + 1 (MRI tagged-int parity) string -> pointer bit pattern (str-heap doesn't relocate) symbol -> sym_id * 8 + 4 (offset avoids collision with int formula)

Each receiver type's compile_*_method_expr gets the arm; analyze claims int return.

Fixes #992

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

Details

Commit
75f5d853da80
Parent
87f5a835190e

spinel_analyze.rbmodifiedView file

@@ -5038,6 +5038,9 @@
50385038 if mname == "next_float" || mname == "prev_float"
50395039 return "float"
50405040 end
5041+ if mname == "object_id"
5042+ return "int"
5043+ end
50415044 if mname == "nan?" || mname == "finite?"
50425045 return "bool"
50435046 end