-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ruby/yarp] Fix heredocs inside %W and %w lists
The problem was that we were treating heredoc bodies as part of the %W list because we didn't push the scanning cursor past the heredoc after lexing out the here doc. To fix this, we changed the whitespace scanning function to quit scanning when it reaches a newline but only in the case that a heredoc is present. Additionally, we need to prevent double counting newlines in the case of a heredoc. For example: ```ruby %W(<<foo 123) foo ``` The newline after the `)` is counted as part of scanning the heredoc, so we added logic to prevent double counting the newline when scanning the rest of the %W list. ruby/prism@eb090d8126 Co-authored-by: Jemma Issroff <jemmaissroff@gmail.com>
- Loading branch information
Showing
6 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ProgramNode(0...30)( | ||
[], | ||
StatementsNode(0...30)( | ||
[ArrayNode(0...30)( | ||
[StringNode(4...5)(nil, (4...5), nil, "1"), | ||
InterpolatedStringNode(0...12)( | ||
nil, | ||
[EmbeddedStatementsNode(6...12)( | ||
(6...8), | ||
StatementsNode(8...19)( | ||
[InterpolatedStringNode(8...19)( | ||
(8...11), | ||
[StringNode(15...17)(nil, (15...17), nil, "2\n")], | ||
(17...19) | ||
)] | ||
), | ||
(11...12) | ||
)], | ||
nil | ||
), | ||
StringNode(13...14)(nil, (13...14), nil, "3"), | ||
StringNode(25...26)(nil, (25...26), nil, "4"), | ||
StringNode(27...28)(nil, (27...28), nil, "5")], | ||
(0...3), | ||
(29...30) | ||
)] | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters