Commit d6d1ec88

d6d1ec889ccfMerged

Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

fix(codegen): infer SymbolNode as symbol in ivar init type, not string

infer_ivar_init_type returned string for SymbolNode while the general infer_type returned symbol. Reassigning an ivar to two different symbols then ran into update_ivar_type's "old != new_type" branch and demoted the field to poly, after which assigning a literal symbol to it became a C type error:

/tmp/_t.c:8:17: error: incompatible types when assigning to type 'sp_RbVal' from type 'long int' 8 | #define SPS_foo ((sp_sym)0) | ^

Adds test/symbol_ivar_reassign.rb.

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

Details

Commit
d6d1ec889ccf
Parent
1635e7c62c12

spinel_codegen.rbmodifiedView file

@@ -4373,7 +4373,7 @@
43734373 return "string"
43744374 end
43754375 if t == "SymbolNode"
4376- return "string"
4376+ return "symbol"
43774377 end
43784378 if t == "TrueNode"
43794379 return "bool"