You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What operating system and processor architecture are you using (go env)?
Any
What did you do?
Parsing src/builtin/builtin.go with go/parser package.
What did you expect to see?
Parameters of func make(Type, size IntegerType) Type are parsed as:
First parameter: name empty, datatype Type
Second parameter: name size, datatype IntegerType
What did you see instead?
Parameters of func make(Type, size IntegerType) Type are parsed as:
First parameter: name Type, datatype IntegerType
Second parameter: name size, datatype IntegerType
Notice different data type of the first parameter.
Additional data
Given the make can accept 3 arguments (given the way it is used), this does not matter. Every tool eating output of the go/parser must test the number of arguments and based on that determine what data types are/can be actually used.
If it is a bug, it can be fixed as:
funcmake(typeType, sizeIntegerType) Type
or
funcmake(Type, IntegerType) Type
The text was updated successfully, but these errors were encountered:
I can not disagree with what it says. The thing is the way the function make is parsed. For me, it is more useful to declare the function as make(Type, IntegerType) Type. This way I can check if the first parameter is Type. If it is, I can return the first argument as the make's result type.
Type is here for the purposes of documentation only. It is a stand-in for any Go type, but represents the same type for any given function invocation.
type Type int
ALTree
changed the title
builtin.make function is parsed incorrectly
go/parser: builtin.make function is parsed incorrectly
May 13, 2017
What version of Go are you using (
go version
)?Any
What operating system and processor architecture are you using (
go env
)?Any
What did you do?
Parsing
src/builtin/builtin.go
withgo/parser
package.What did you expect to see?
Parameters of
func make(Type, size IntegerType) Type
are parsed as:Type
size
, datatypeIntegerType
What did you see instead?
Parameters of
func make(Type, size IntegerType) Type
are parsed as:Type
, datatypeIntegerType
size
, datatypeIntegerType
Notice different data type of the first parameter.
Additional data
Given the
make
can accept 3 arguments (given the way it is used), this does not matter. Every tool eating output of thego/parser
must test the number of arguments and based on that determine what data types are/can be actually used.If it is a bug, it can be fixed as:
or
The text was updated successfully, but these errors were encountered: