Fix regression for squiggly heredocs
MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -4700,12 +4700,12 @@ parse_string(parser_state *p)
pylval.nd = nd;
if (head) {
hinf->indented = push(hinf->indented, cons((node*)spaces, nd->cdr));
- if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !hinf->line_head))
+ if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !line_head))
hinf->indent = spaces;
}
return tHD_STRING_MID;
}
- if (hinf && hinf->line_head) {
+ if (hinf && hinf->line_head && empty) {
if (ISSPACE(c)) {
if (hinf->indent_char == -1)
hinf->indent_char = c;

MODIFY
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
@@ -11085,12 +11085,12 @@ parse_string(parser_state *p)
pylval.nd = nd;
if (head) {
hinf->indented = push(hinf->indented, cons((node*)spaces, nd->cdr));
- if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !hinf->line_head))
+ if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !line_head))
hinf->indent = spaces;
}
return tHD_STRING_MID;
}
- if (hinf && hinf->line_head) {
+ if (hinf && hinf->line_head && empty) {
if (ISSPACE(c)) {
if (hinf->indent_char == -1)
hinf->indent_char = c;

MODIFY
test/t/literals.rb
test/t/literals.rb
@@ -190,6 +190,10 @@ QQ2
\tvvv
vvv
VVV
+ v3 = <<~VVV
+ v v v
+ vvv
+ VVV
w = %W( 1 #{<<WWW} 3
www
@@ -232,6 +236,7 @@ ZZZ
assert_equal ["u1u\n", "u2u\n", "u\#{3}u\n"], u
assert_equal "\nvvv\nvvv\n", v1
assert_equal "\tvvv\n vvv\n", v2
+ assert_equal "v v v\n vvv\n", v3
assert_equal ["1", "www\n", "3", "4", "5"], w
assert_equal [1, "foo 222 333\n 444\n5\n bar\n6\n", 9], x
assert_equal "", z

Fix regression for squiggly heredocs