Commit 2fe45584

2fe45584777eMerged

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

Description

Improve module constants: type inference for Module::CONST paths, better type detection for string/bool/hash constant values

Module constants now properly infer types for qualified access (Config::GREETING returns STRING, Config::ENABLED returns BOOLEAN). Type detection expanded beyond INTEGER/FLOAT to handle string literals, booleans, and common method calls (Dir.home, File.join).

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

Details

Commit
2fe45584777e
Parent
5fca17b526f2

examples/bm_constants.rbaddedView file

1+# Test module constants and top-level constants
2+
3+MAX_SIZE = 100
4+PI_APPROX = 3
5+NAME = "spinel"
6+
7+module Config
8+ VERSION = 42
9+ GREETING = "hello"
10+ ENABLED = true
11+end
12+
13+puts MAX_SIZE # 100
14+puts PI_APPROX # 3
15+puts NAME # spinel
16+puts Config::VERSION # 42
17+puts Config::GREETING # hello
18+puts Config::ENABLED # true
19+
20+# Constants in expressions
21+puts MAX_SIZE + 1 # 101
22+puts NAME.length # 6
23+puts Config::GREETING.upcase # HELLO
24+
25+puts "done"