ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:85983] [Ruby trunk Bug#14584] Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
       [not found] <redmine.issue-14584.20180307200733@ruby-lang.org>
@ 2018-03-07 20:07 ` asterite
  2018-03-08  1:43 ` [ruby-core:85989] " s
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: asterite @ 2018-03-07 20:07 UTC (permalink / raw
  To: ruby-core

Issue #14584 has been reported by asterite (Ary Borenszweig).

----------------------------------------
Bug #14584: Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
https://bugs.ruby-lang.org/issues/14584

* Author: asterite (Ary Borenszweig)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Given this program:

~~~
text1 = <<~FOO
  one#{"   two   "}
  FOO

text2 = <<~FOO
one#{"   two   "}
FOO

p text1
p text2
~~~

The output is:

~~~
"one two   \n"
"one   two   \n"
~~~

The two should be equal.

I think the problem happens because squigly heredoc will remove the first two spaces from each line in the heredoc, but it seems to also be removing it from literals inside interpolation inside a heredoc.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:85989] [Ruby trunk Bug#14584] Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
       [not found] <redmine.issue-14584.20180307200733@ruby-lang.org>
  2018-03-07 20:07 ` [ruby-core:85983] [Ruby trunk Bug#14584] Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value asterite
@ 2018-03-08  1:43 ` s
  2018-03-08 14:57 ` [ruby-core:86051] " asterite
  2018-03-24 11:44 ` [ruby-core:86276] " naruse
  3 siblings, 0 replies; 4+ messages in thread
From: s @ 2018-03-08  1:43 UTC (permalink / raw
  To: ruby-core

Issue #14584 has been updated by sikachu (Prem Sichanugrist).


👍 I can confirm this bug exists in 2.5.0p0.

Also, it seems like the number of spaces it's removing is based on the gutter size as well (which is expected?)

~~~ ruby
# two spaces gutter, four leading spaces in literal
<<~FOO
  two#{"    four    "}
FOO
#=> "two  four    \n"

# two spaces gutter, five leading spaces in literal
<<~FOO
  two#{"     five     "}
FOO
#=> "two   five     \n"

# three spaces gutter, five leading spaces in literal
<<~FOO
   three#{"     five     "}
FOO
#=> "three  five     \n"
~~~

I don't have enough Ruby lexer knowledge to fix this, so I hope someone will be able to spare their time taking care of this 🙇‍♂️

----------------------------------------
Bug #14584: Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
https://bugs.ruby-lang.org/issues/14584#change-70854

* Author: asterite (Ary Borenszweig)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Given this program:

~~~
text1 = <<~FOO
  one#{"   two   "}
  FOO

text2 = <<~FOO
one#{"   two   "}
FOO

p text1
p text2
~~~

The output is:

~~~
"one two   \n"
"one   two   \n"
~~~

The two should be equal.

I think the problem happens because squigly heredoc will remove the first two spaces from each line in the heredoc, but it seems to also be removing it from literals inside interpolation inside a heredoc.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:86051] [Ruby trunk Bug#14584] Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
       [not found] <redmine.issue-14584.20180307200733@ruby-lang.org>
  2018-03-07 20:07 ` [ruby-core:85983] [Ruby trunk Bug#14584] Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value asterite
  2018-03-08  1:43 ` [ruby-core:85989] " s
@ 2018-03-08 14:57 ` asterite
  2018-03-24 11:44 ` [ruby-core:86276] " naruse
  3 siblings, 0 replies; 4+ messages in thread
From: asterite @ 2018-03-08 14:57 UTC (permalink / raw
  To: ruby-core

Issue #14584 has been updated by asterite (Ary Borenszweig).


Interestingly enough, it doesn't happen when you have:

~~~
text1 = <<~FOO
  one#{"   two   " * 1}
  FOO
~~~

So it seems Ruby does this only when the interpolation has a string literal, presumably to optimize that out and embed it into the resulting heredoc string.

----------------------------------------
Bug #14584: Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
https://bugs.ruby-lang.org/issues/14584#change-70916

* Author: asterite (Ary Borenszweig)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Given this program:

~~~
text1 = <<~FOO
  one#{"   two   "}
  FOO

text2 = <<~FOO
one#{"   two   "}
FOO

p text1
p text2
~~~

The output is:

~~~
"one two   \n"
"one   two   \n"
~~~

The two should be equal.

I think the problem happens because squigly heredoc will remove the first two spaces from each line in the heredoc, but it seems to also be removing it from literals inside interpolation inside a heredoc.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:86276] [Ruby trunk Bug#14584] Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
       [not found] <redmine.issue-14584.20180307200733@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2018-03-08 14:57 ` [ruby-core:86051] " asterite
@ 2018-03-24 11:44 ` naruse
  3 siblings, 0 replies; 4+ messages in thread
From: naruse @ 2018-03-24 11:44 UTC (permalink / raw
  To: ruby-core

Issue #14584 has been updated by naruse (Yui NARUSE).

Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: DONE

ruby_2_5 r62909 merged revision(s) 62723,62724.

----------------------------------------
Bug #14584: Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value
https://bugs.ruby-lang.org/issues/14584#change-71187

* Author: asterite (Ary Borenszweig)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
* Backport: 2.3: REQUIRED, 2.4: REQUIRED, 2.5: DONE
----------------------------------------
Given this program:

~~~ruby
text1 = <<~FOO
  one#{"   two   "}
  FOO

text2 = <<~FOO
one#{"   two   "}
FOO

p text1
p text2
~~~

The output is:

~~~
"one two   \n"
"one   two   \n"
~~~

The two should be equal.

I think the problem happens because squigly heredoc will remove the first two spaces from each line in the heredoc, but it seems to also be removing it from literals inside interpolation inside a heredoc.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-24 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-14584.20180307200733@ruby-lang.org>
2018-03-07 20:07 ` [ruby-core:85983] [Ruby trunk Bug#14584] Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value asterite
2018-03-08  1:43 ` [ruby-core:85989] " s
2018-03-08 14:57 ` [ruby-core:86051] " asterite
2018-03-24 11:44 ` [ruby-core:86276] " naruse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).