Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0d616847856d
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 53c4b1e9d5a9
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 1, 2018

  1. Copy the full SHA
    248a260 View commit details

Commits on May 2, 2018

  1. Merge pull request #6048 from asterite/bug/6030-quoted-heredoc

    Parser: fixed quoted heredoc followed by call
    asterite authored May 2, 2018
    Copy the full SHA
    53c4b1e View commit details
Showing with 6 additions and 6 deletions.
  1. +3 −0 spec/compiler/parser/parser_spec.cr
  2. +3 −6 src/compiler/crystal/syntax/lexer.cr
3 changes: 3 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
@@ -1244,6 +1244,9 @@ describe "Parser" do

it_parses "<<-'HERE COMES HEREDOC'\n hello \\n world\n \#{1}\n HERE COMES HEREDOC", "hello \\n world\n\#{1}".string_interpolation

it_parses "<<-EOF.x\n foo\nEOF", Call.new(" foo".string_interpolation, "x")
it_parses "<<-'EOF'.x\n foo\nEOF", Call.new(" foo".string_interpolation, "x")

assert_syntax_error "<<-FOO\n1\nFOO.bar", "Unterminated heredoc: can't find \"FOO\" anywhere before the end of file"
assert_syntax_error "<<-FOO\n1\nFOO + 2", "Unterminated heredoc: can't find \"FOO\" anywhere before the end of file"

9 changes: 3 additions & 6 deletions src/compiler/crystal/syntax/lexer.cr
Original file line number Diff line number Diff line change
@@ -200,10 +200,9 @@ module Crystal
else
if char == '\'' && has_single_quote
found_closing_single_quote = true
peek = peek_next_char
if peek != '\r' && peek != '\n'
raise "expecting '\\n' or '\\r' after closing single quote"
end
end_here = current_pos
next_char
break
elsif has_single_quote
# wait until another quote
else
@@ -217,8 +216,6 @@ module Crystal
raise "expecting closing single quote"
end

end_here -= 1 if has_single_quote

here = string_range(start_here, end_here)

delimited_pair :heredoc, here, here, start, allow_escapes: !has_single_quote, advance: false