Commit a3c671cd
a3c671cdb248Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
codegen: defined?($gvar) returns "global-variable" not "expression"
CRuby returns "global-variable" for any global variable read, whether set or not (the name itself is syntactically defined; the value reads as nil when unset). Add the GlobalVariableReadNode arm in compile_call_expr's DefinedNode dispatch.
Method case ("method") was already correct.
Fixes #987
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- a3c671cdb248
- Parent
- 9a958544a9bf
spinel_codegen.rbmodifiedView file
@@ -14009,6 +14009,12 @@
1400914009
end1401014010
return "((const char*)0)"1401114011
end14012+
if it_d == "GlobalVariableReadNode"14013+
# CRuby returns "global-variable" whether the gvar has been14014+
# assigned or not (gvars read as nil when unset, but the name14015+
# itself is always "defined" syntactically).14016+
return "\"global-variable\""14017+
end1401214018
if it_d == "CallNode" && @nd_receiver[inner_d] < 01401314019
mname_d = @nd_name[inner_d]1401414020
if find_method_idx(mname_d) >= 0test/defined_globals_methods.rbaddedView file
Loading diff…
test/defined_globals_methods.rb.expectedaddedView file
Loading diff…