Commit 9f9082b5
9f9082b5133bMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · ~2 modified
Description
Merge pull request #299 from ryanseys/rs-fix-silent-fallback
fix: replace silent UnknownNode_* fallback with hard compile error
Details
- Commit
- 9f9082b5133b
- Parent
- 3f8973a7e8a5
- Merge parent
- 7b2fd09e6224
spinel_codegen.rbmodifiedView file
@@ -662,6 +662,11 @@
662662
if field == "unescaped"663663
@nd_unescaped[nid] = val664664
end665+
if field == "kind"666+
# UnsupportedNode carries the Prism node-type name here so667+
# codegen can surface a precise compile error.668+
@nd_content[nid] = val669+
end665670
end666671
667672
def set_int_field(nid, field, val)@@ -680,6 +685,11 @@
680685
if field == "start_line"681686
@nd_value[nid] = val682687
end688+
if field == "source_line"689+
# UnsupportedNode carries the source line so codegen can cite690+
# location in the compile error.691+
@nd_value[nid] = val692+
end683693
end684694
685695
def set_ref_field(nid, field, ref_id)@@ -17791,6 +17801,13 @@
1779117801
return "0"1779217802
end1779317803
t = @nd_type[nid]17804+
if t == "UnsupportedNode"17805+
# The parser emitted this sentinel because it hit a Prism node17806+
# type it doesn't know how to serialize. Refusing to compile is17807+
# far better than the historical silent "0".17808+
$stderr.puts "Spinel: cannot compile " + @nd_content[nid] + " at line " + @nd_value[nid].to_s + " (unsupported Ruby syntax)"17809+
exit(1)17810+
end1779417811
if t == "IntegerNode"1779517812
return @nd_value[nid].to_s1779617813
end@@ -25358,6 +25375,11 @@
2535825375
return2535925376
end2536025377
t = @nd_type[nid]25378+
if t == "UnsupportedNode"25379+
# Same loud-error path as compile_expr's UnsupportedNode arm.25380+
$stderr.puts "Spinel: cannot compile " + @nd_content[nid] + " at line " + @nd_value[nid].to_s + " (unsupported Ruby syntax)"25381+
exit(1)25382+
end2536125383
if t == "MultiWriteNode"2536225384
compile_multi_write(nid)2536325385
returnspinel_parse.cmodifiedView file
Loading diff…