Skip to content

Commit

Permalink
Parser: Rename arg* to param* (#12235)
Browse files Browse the repository at this point in the history
  • Loading branch information
potomak authored Sep 26, 2022
1 parent 78fb6e0 commit e05516f
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 119 deletions.
9 changes: 5 additions & 4 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ module Crystal
assert_syntax_error "def foo(x, *); 1; end", "named parameters must follow bare *"
it_parses "def foo(x, *, y, &); 1; end", Def.new("foo", args: ["x".arg, "".arg, "y".arg], body: 1.int32, splat_index: 1, block_arg: Arg.new(""), yields: 0)

assert_syntax_error "def foo(var = 1 : Int32); end", "the syntax for a parameter with a default value V and type T is `arg : T = V`"
assert_syntax_error "def foo(var = x : Int); end", "the syntax for a parameter with a default value V and type T is `arg : T = V`"
assert_syntax_error "def foo(var = 1 : Int32); end", "the syntax for a parameter with a default value V and type T is `param : T = V`"
assert_syntax_error "def foo(var = x : Int); end", "the syntax for a parameter with a default value V and type T is `param : T = V`"

it_parses "def foo(**args)\n1\nend", Def.new("foo", body: 1.int32, double_splat: "args".arg)
it_parses "def foo(x, **args)\n1\nend", Def.new("foo", body: 1.int32, args: ["x".arg], double_splat: "args".arg)
Expand Down Expand Up @@ -1915,8 +1915,9 @@ module Crystal
assert_syntax_error "/foo)/", "invalid regex"
assert_syntax_error "def =\nend"
assert_syntax_error "def foo; A = 1; end", "dynamic constant assignment. Constants can only be declared at the top level or inside other types."
assert_syntax_error "{1, ->{ |x| x } }", %(unexpected token: "|")
assert_syntax_error "{1, ->do\n|x| x\end }", %(unexpected token: "|")
assert_syntax_error "{1, ->{ |x| x } }", "unexpected token: \"|\", proc literals specify their parameters like this: ->(x : Type) { ... }"
assert_syntax_error "{1, ->do\n|x| x\end }", "unexpected token: \"|\", proc literals specify their parameters like this: ->(x : Type) { ... }"
assert_syntax_error "{1, ->{ |_| x } }", "unexpected token: \"|\", proc literals specify their parameters like this: ->(param : Type) { ... }"

assert_syntax_error "1 while 3", "trailing `while` is not supported"
assert_syntax_error "1 until 3", "trailing `until` is not supported"
Expand Down
Loading

0 comments on commit e05516f

Please sign in to comment.