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 constants2+
3+
MAX_SIZE = 1004+
PI_APPROX = 35+
NAME = "spinel"6+
7+
module Config8+
VERSION = 429+
GREETING = "hello"10+
ENABLED = true11+
end12+
13+
puts MAX_SIZE # 10014+
puts PI_APPROX # 315+
puts NAME # spinel16+
puts Config::VERSION # 4217+
puts Config::GREETING # hello18+
puts Config::ENABLED # true19+
20+
# Constants in expressions21+
puts MAX_SIZE + 1 # 10122+
puts NAME.length # 623+
puts Config::GREETING.upcase # HELLO24+
25+
puts "done"src/codegen.cmodifiedView file
Loading diff…