Commit dd35d423
dd35d423df08Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Chained String#<< accumulator (the Rails view-emit pattern)
Type string <</concat/prepend as returning the string so a chained
io << a << b << c infers correctly, and unroll the chain into one
reassignment per argument against the root lvalue (value-semantics
strings can't thread self through an intermediate expression).
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- dd35d423df08
- Parent
- 6b49ae9ff07c
src/analyze.cmodifiedView file
@@ -705,6 +705,9 @@
705705
!strcmp(name, "center") || !strcmp(name, "ljust") || !strcmp(name, "rjust"))706706
return TY_STRING;707707
if (!strcmp(name, "*")) return TY_STRING;708+
/* in-place append / concat reassign the receiver and evaluate to it */709+
if ((!strcmp(name, "<<") || !strcmp(name, "concat") || !strcmp(name, "prepend")) && argc == 1)710+
return TY_STRING;708711
}709712
/* integer receiver methods */710713
if (recv >= 0 && rt == TY_INT) {src/codegen.cmodifiedView file
Loading diff…