Commit f2785f69
f2785f692d3dMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · +1 added
Description
test: add regression test for class-scoped constant path reads
Issue #52 reported that class User; MAX = 20; end; puts User::MAX
emitted User_MAX as an undeclared C identifier. The current codegen
emits it as cst_User_MAX with a matching declaration, and the
reproducer prints 20 cleanly. The fix landed earlier as part of the
broader constant-resolution work (commits b9487db, d3171e3, 2cda5c7);
this just nails down the original reproducer plus a few neighbouring
shapes (top-level const, module const, nested class const) so they
can't silently regress.
Closes #52
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- f2785f692d3d
- Parent
- a03517c7529d
test/class_constant_path_read.rbaddedView file
1+
# Issue #52: reading a class-scoped constant from outside the class2+
# via `ClassName::CONST` used to emit `User_MAX_NAME_LENGTH` as an3+
# undeclared C identifier. Now it's emitted as `cst_User_MAX_NAME_LENGTH`4+
# with a matching declaration.5+
6+
class User7+
MAX_NAME_LENGTH = 208+
end9+
10+
puts User::MAX_NAME_LENGTH # 2011+
12+
# Mixed reads: class const, module const, top-level const all13+
# accessible via the same path forms.14+
TOP = 115+
16+
module Site17+
ROOT = 218+
19+
class Page20+
LIMIT = 321+
end22+
end23+
24+
puts TOP # 125+
puts Site::ROOT # 226+
puts Site::Page::LIMIT # 3