Commit 87bb556c

87bb556ca4b0Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Add ivar/global/const write nodes to tail-statement no-value list

InstanceVariableOperatorWriteNode (and other write node types) were missing from emit_stmt_tail_inner's list of "no usable tail value" statements. When such a node appeared as the last statement in a method body, the compiler tried to emit it as a value expression, which hit the unsupported() fallback in emit_expr.

Adds InstanceVariableWriteNode, InstanceVariableOperatorWriteNode, InstanceVariableOrWriteNode, InstanceVariableAndWriteNode, GlobalVariableWriteNode, ConstantWriteNode, LocalVariableOrWriteNode, and LocalVariableAndWriteNode to the non-tail-value list so they are emitted as plain statements at tail position (the method's trailing default return covers the return value).

Fixes 12 previously-ERR tests including module_ivar_op_write, poly_local_is_a_string_narrow, recursive_block_forward_value, etc.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

Details

Commit
87bb556ca4b0
Parent
86aadadc63a8

src/codegen.cmodifiedView file

@@ -12172,6 +12172,14 @@
1217212172 the trailing default return covers the method's value. */
1217312173 if (!strcmp(ty, "LocalVariableWriteNode") ||
1217412174 !strcmp(ty, "LocalVariableOperatorWriteNode") ||
12175+ !strcmp(ty, "LocalVariableOrWriteNode") ||
12176+ !strcmp(ty, "LocalVariableAndWriteNode") ||
12177+ !strcmp(ty, "InstanceVariableWriteNode") ||
12178+ !strcmp(ty, "InstanceVariableOperatorWriteNode") ||
12179+ !strcmp(ty, "InstanceVariableOrWriteNode") ||
12180+ !strcmp(ty, "InstanceVariableAndWriteNode") ||
12181+ !strcmp(ty, "GlobalVariableWriteNode") ||
12182+ !strcmp(ty, "ConstantWriteNode") ||
1217512183 !strcmp(ty, "WhileNode") || !strcmp(ty, "UntilNode") ||
1217612184 (!strcmp(ty, "CallNode") && nt_ref(nt, id, "receiver") < 0 &&
1217712185 emit_output_call(c, id, b, indent))) {