Skip to content

Commit

Permalink
Parser: correct to parse / following do as regex
Browse files Browse the repository at this point in the history
Fixed #4547
  • Loading branch information
makenowjust authored and asterite committed Jun 14, 2017
1 parent be85fa4 commit 74b1bb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Expand Up @@ -358,6 +358,10 @@ describe "Parser" do
it_parses "1.x; foo do\nend", [Call.new(1.int32, "x"), Call.new(nil, "foo", block: Block.new)] of ASTNode
it_parses "x = 1; foo.bar x do\nend", [Assign.new("x".var, 1.int32), Call.new("foo".call, "bar", ["x".var] of ASTNode, Block.new)]

it_parses "foo do\n//\nend", Call.new(nil, "foo", [] of ASTNode, Block.new(body: regex("")))
it_parses "foo x do\n//\nend", Call.new(nil, "foo", ["x".call] of ASTNode, Block.new(body: regex("")))
it_parses "foo(x) do\n//\nend", Call.new(nil, "foo", ["x".call] of ASTNode, Block.new(body: regex("")))

it_parses "foo !false", Call.new(nil, "foo", [Not.new(false.bool)] of ASTNode)
it_parses "!a && b", And.new(Not.new("a".call), "b".call)

Expand Down
1 change: 1 addition & 0 deletions src/compiler/crystal/syntax/parser.cr
Expand Up @@ -3743,6 +3743,7 @@ module Crystal
arg_index = 0
splat_index = nil

slash_is_regex!
next_token_skip_space
if @token.type == :"|"
next_token_skip_space_or_newline
Expand Down

0 comments on commit 74b1bb4

Please sign in to comment.