Closed edkolev closed 1 year ago
Here's a minimalistic example:
func notOk() (int, map[int]int) {}
tree-sitter parse ...
(source_file [0, 0] - [1, 0]
(function_declaration [0, 0] - [0, 34]
name: (identifier [0, 5] - [0, 10])
parameters: (parameter_list [0, 10] - [0, 12])
result: (parameter_list [0, 13] - [0, 31]
(parameter_declaration [0, 14] - [0, 30]
name: (identifier [0, 14] - [0, 17])
name: (identifier [0, 19] - [0, 22])
type: (array_type [0, 22] - [0, 30]
length: (identifier [0, 23] - [0, 26])
element: (type_identifier [0, 27] - [0, 30]))))
body: (block [0, 32] - [0, 34])))
Attached is a screenshot of log.html
I've run into the following issue: multiples return values of functions are not always parsed correctly.
For example:
func notOk() (int, map[int]int)
are parsed incorrectly intoTo reproduce:
func notOk() (int, map[int]int) { return 0, nil }
result: (parameter_list ( (parameter_declaration type: (slice_type [ ] element: (type_identifier))) , (parameter_declaration type: (map_type map [ key: (type_identifier) ] value: (type_identifier))) ))
result: (parameter_list ( (parameter_declaration name: (identifier) name: , type: (identifier) (array_type [ length: (identifier) ] element: (type_identifier))) ))
(source_file (package_clause package (package_identifier)) \n (comment) (function_declaration func name: (identifier) parameters: (parameter_list ( )) result: (parameter_list ( (parameter_declaration type: (slice_type [ ] element: (type_identifier))) , (parameter_declaration type: (map_type map [ key: (type_identifier) ] value: (type_identifier))) )) body: (block { (return_statement return (expression_list (nil) , (nil))) \n })) \n (function_declaration func name: (identifier) parameters: (parameter_list ( )) result: (parameter_list ( (parameter_declaration name: (identifier) name: , type: (identifier) (array_type [ length: (identifier) ] element: (type_identifier))) )) body: (block { (return_statement return (expression_list (int_literal) , (nil))) \n })) \n)