Skip to content

Commit

Permalink
Merge pull request #119 from amaanq/param-fix
Browse files Browse the repository at this point in the history
Param fix
  • Loading branch information
Yoann Padioleau authored Jun 6, 2023
2 parents 7cccc30 + f3a8104 commit 8867111
Show file tree
Hide file tree
Showing 5 changed files with 12,128 additions and 12,111 deletions.
28 changes: 19 additions & 9 deletions corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func g1[T, U any, V interface{}, W Foo[Bar[T]]](a Foo[T]) {}
func g1[T, U any, V interface{}, W Foo[Bar[T]]](a Foo[T]) {}
func g2(a foo.bar[int]) {}
func f[A int|string, B ~int, C ~int|~string]()
func f2(a File, b, c, d Thing) int {}

--------------------------------------------------------------------------------

Expand All @@ -265,10 +266,8 @@ func f[A int|string, B ~int, C ~int|~string]()
(identifier)
(type_identifier))
(parameter_declaration
(type_identifier))
(parameter_declaration
(type_identifier))
(parameter_declaration
(identifier)
(identifier)
(identifier)
(type_identifier)))
(type_identifier)
Expand Down Expand Up @@ -305,9 +304,8 @@ func f[A int|string, B ~int, C ~int|~string]()
(function_declaration
(identifier)
(type_parameter_list
(parameter_declaration
(type_identifier))
(parameter_declaration
(identifier)
(identifier)
(type_identifier))
(parameter_declaration
Expand All @@ -334,8 +332,7 @@ func f[A int|string, B ~int, C ~int|~string]()
(identifier)
(type_parameter_list
(parameter_declaration
(type_identifier))
(parameter_declaration
(identifier)
(identifier)
(type_identifier))
(parameter_declaration
Expand Down Expand Up @@ -389,7 +386,20 @@ func f[A int|string, B ~int, C ~int|~string]()
(type_identifier))
(negated_type
(type_identifier)))))
(parameter_list)))
(parameter_list))
(function_declaration
(identifier)
(parameter_list
(parameter_declaration
(identifier)
(type_identifier))
(parameter_declaration
(identifier)
(identifier)
(identifier)
(type_identifier)))
(type_identifier)
(block)))

================================================================================
Single-line function declarations
Expand Down
3 changes: 1 addition & 2 deletions corpus/types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ type g2[T, U any, V interface{}, W Foo[Bar[T]]] struct {}
(type_identifier)
(type_parameter_list
(parameter_declaration
(type_identifier))
(parameter_declaration
(identifier)
(identifier)
(type_identifier))
(parameter_declaration
Expand Down
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ module.exports = grammar({
')'
),

parameter_declaration: $ => prec.left(-1, seq(
parameter_declaration: $ => prec.left(seq(
commaSep(field('name', $.identifier)),
field('type', $._type),
)),
Expand Down
2 changes: 1 addition & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
},
"parameter_declaration": {
"type": "PREC_LEFT",
"value": -1,
"value": 0,
"content": {
"type": "SEQ",
"members": [
Expand Down
Loading

0 comments on commit 8867111

Please sign in to comment.