Commit 7b48ef15

7b48ef1500a5Merged

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

Description

Object#object_id

object_id returns a stable Integer id: 2n+1 for an Integer (MRI's tagged form), the interned id for a Symbol, and the pointer bit pattern for a pointer-backed value (string/array/hash/object).

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

Details

Commit
7b48ef1500a5
Parent
62f0fa423d6f

src/analyze.cmodifiedView file

@@ -666,6 +666,7 @@
666666 if (!strcmp(name, "!")) return TY_BOOL;
667667 if (!strcmp(name, "respond_to?") && recv >= 0) return TY_BOOL;
668668 if (!strcmp(name, "nil?") && recv >= 0 && argc == 0) return TY_BOOL;
669+ if (!strcmp(name, "object_id") && recv >= 0 && argc == 0) return TY_INT;
669670 if ((!strcmp(name, "match?") || !strcmp(name, "!~")) && recv >= 0) return TY_BOOL;
670671 if (!strcmp(name, "=~") && recv >= 0 && argc == 1) {
671672 const char *rrt = nt_type(nt, recv), *art = nt_type(nt, argv[0]);