Skip to content

Commit

Permalink
Fix to parse regex in default argument (#5481)
Browse files Browse the repository at this point in the history
makenowjust authored and RX14 committed Jan 2, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d7273c7 commit 856220c
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
@@ -867,6 +867,7 @@ describe "Parser" do
it_parses "a()/3", Call.new("a".call, "/", 3.int32)
it_parses "a() /3", Call.new("a".call, "/", 3.int32)
it_parses "a.b() /3", Call.new(Call.new("a".call, "b"), "/", 3.int32)
it_parses "def foo(x = / /); end", Def.new("foo", [Arg.new("x", regex(" "))])

it_parses "1 =~ 2", Call.new(1.int32, "=~", 2.int32)
it_parses "1.=~(2)", Call.new(1.int32, "=~", 2.int32)
1 change: 1 addition & 0 deletions src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
@@ -3446,6 +3446,7 @@ module Crystal
raise "splat argument can't have default value", @token if splat
raise "double splat argument can't have default value", @token if double_splat

slash_is_regex!
next_token_skip_space_or_newline

case @token.type

0 comments on commit 856220c

Please sign in to comment.