From 4683a196d9cdcee84024ce6fb8bb73082c76eee8 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 29 Dec 2020 12:02:12 -0800 Subject: Fix regression for squiggly heredocs --- mrbgems/mruby-compiler/core/parse.y | 4 ++-- mrbgems/mruby-compiler/core/y.tab.c | 4 ++-- test/t/literals.rb | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 4a031abde..ebb18767a 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/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; diff --git a/mrbgems/mruby-compiler/core/y.tab.c b/mrbgems/mruby-compiler/core/y.tab.c index ea3cf2db7..2305c2bb6 100644 --- a/mrbgems/mruby-compiler/core/y.tab.c +++ b/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; diff --git a/test/t/literals.rb b/test/t/literals.rb index dad5c872a..682e5317a 100644 --- a/test/t/literals.rb +++ b/test/t/literals.rb @@ -190,6 +190,10 @@ QQ2 \tvvv vvv VVV + v3 = <<~VVV + v v v + vvv + VVV w = %W( 1 #{<