Commit e93dc94e

e93dc94ec48bMerged

Sam Ruby <[email protected]> · 5 months ago · 2 files · ~2 modified

Description

Address PR review: rational/imaginary literals, eager test init

  • node_is_pure_literal: also treat RationalNode / ImaginaryNode as side-effect-free literals, so a discarded return 3r / return 2i in a void function collapses to a bare return;.
  • return_void_and_nullable_object test: initialize Counter's @count eagerly in the class body (spinel and CRuby both honor it) and drop the reset helper, so the counter never reads an uninitialized ivar and no helper returns a misleading non-nil value. Output unchanged.

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

Details

Commit
e93dc94ec48b
Parent
70f7ed22e881

src/codegen_stmt.cmodifiedView file

@@ -1700,7 +1700,8 @@
17001700 return ty && (!strcmp(ty, "NilNode") || !strcmp(ty, "IntegerNode") ||
17011701 !strcmp(ty, "FloatNode") || !strcmp(ty, "StringNode") ||
17021702 !strcmp(ty, "SymbolNode") || !strcmp(ty, "TrueNode") ||
1703- !strcmp(ty, "FalseNode"));
1703+ !strcmp(ty, "FalseNode") || !strcmp(ty, "RationalNode") ||
1704+ !strcmp(ty, "ImaginaryNode"));
17041705 }
17051706
17061707 void emit_return(Compiler *c, int id, Buf *b, int indent) {