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: a56f370b5ac1
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: 8d190f45503c
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 1, 2018

  1. Copy the full SHA
    7d9b1ca View commit details

Commits on May 2, 2018

  1. Merge pull request #6046 from asterite/bug/5966-macro-parse-newline

    Parser: fix parsing of macro argument followed by a newline
    asterite authored May 2, 2018
    Copy the full SHA
    8d190f4 View commit details
Showing with 3 additions and 1 deletion.
  1. +2 −0 spec/compiler/parser/parser_spec.cr
  2. +1 −1 src/compiler/crystal/syntax/parser.cr
2 changes: 2 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
@@ -804,6 +804,8 @@ describe "Parser" do
it_parses "macro foo;bar{% for x in y %}\\ \n body{% end %}\\ baz;end", Macro.new("foo", [] of Arg, Expressions.from(["bar".macro_literal, MacroFor.new(["x".var], "y".var, "body".macro_literal), "baz;".macro_literal] of ASTNode))
it_parses "macro foo; 1 + 2 {{foo}}\\ 3 + 4; end", Macro.new("foo", [] of Arg, Expressions.from([" 1 + 2 ".macro_literal, MacroExpression.new("foo".var), "3 + 4; ".macro_literal] of ASTNode))

it_parses "macro foo(\na = 0\n)\nend", Macro.new("foo", [Arg.new("a", default_value: 0.int32)], Expressions.new)

assert_syntax_error "macro foo; {% foo = 1 }; end"
assert_syntax_error "macro def foo : String; 1; end"

2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
@@ -2808,7 +2808,7 @@ module Crystal
elsif @token.type == :","
next_token_skip_space_or_newline
else
skip_space
skip_space_or_newline
if @token.type != :")"
unexpected_token @token.to_s, "expected ',' or ')'"
end