Skip to content

Commit

Permalink
Fix to parse regex in default argument (#5481)
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust authored and RX14 committed Jan 2, 2018
1 parent d7273c7 commit 856220c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/compiler/parser/parser_spec.cr
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/compiler/crystal/syntax/parser.cr
Expand Up @@ -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
Expand Down

0 comments on commit 856220c

Please sign in to comment.