Commit b8825f5e
b8825f5e0883Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
dir and compile-time is_a? on concrete builtin receivers
__dir__-> the source file's directory as a literal (mirrors the legacy generator), typed String.x.is_a?(Class)/ kind_of? / instance_of? on a concrete builtin receiver (String/Integer/Float/Symbol/Array/Hash/Range) resolves to a true/false constant at compile time (with the receiver still evaluated), covering ancestors like Numeric/Comparable/Enumerable/Object.
make test: 186 pass / 6 fail / 652 error (was 185 / 6 / 653); kernel_dir green, no regressions.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- b8825f5e0883
- Parent
- 0d2870c78eee
src/analyze.cmodifiedView file
@@ -216,6 +216,9 @@
216216
if (emi > 0 && is_blk_param_call(c, id, emi)) return yield_value_type(c, emi);217217
}218218
219+
/* __dir__ -> the source directory (a string) */220+
if (recv < 0 && !strcmp(name, "__dir__") && argc == 0) return TY_STRING;221+
219222
/* proc {} / lambda {} / Proc.new {} -> a first-class Proc value */220223
if (is_proc_literal(c, id)) return TY_PROC;221224
src/codegen.cmodifiedView file
Loading diff…