Commit 3c017b41
3c017b411294Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified
Description
feat: error on global variable type mismatch
Emit a compile error when the same global variable is assigned different types (e.g. $x = 42 then $x = "hello").
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 3c017b411294
- Parent
- ffdcb606e990
spinel_codegen.rbmodifiedView file
@@ -5407,6 +5407,18 @@
54075407
if not_in(gname, @gvar_names) == 154085408
@gvar_names.push(gname)54095409
@gvar_types.push(gt)5410+
else5411+
# Check type consistency5412+
gi = 05413+
while gi < @gvar_names.length5414+
if @gvar_names[gi] == gname5415+
if @gvar_types[gi] != gt && gt != "int" && gt != "nil"5416+
$stderr.puts "Error: global variable " + gname + " type mismatch: " + @gvar_types[gi] + " vs " + gt5417+
exit(1)5418+
end5419+
end5420+
gi = gi + 15421+
end54105422
end54115423
end54125424
end