MCPcopy
hub / github.com/purpleidea/mgmt / SetType

Method SetType

lang/ast/structs.go:11542–11548  ·  view source on GitHub ↗

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has pre

(typ *types.Type)

Source from the content-addressed store, hash-verified

11540// change on expressions, if you attempt to set a different type than what has
11541// previously been set (when not initially known) this will error.
11542func (obj *ExprVar) SetType(typ *types.Type) error {
11543 if obj.typ != nil {
11544 return obj.typ.Cmp(typ) // if not set, ensure it doesn't change
11545 }
11546 obj.typ = typ // set
11547 return nil
11548}
11549
11550// Type returns the type of this expression.
11551func (obj *ExprVar) Type() (*types.Type, error) {

Callers 1

TestUnification1Function · 0.95

Calls 1

CmpMethod · 0.65

Tested by 1

TestUnification1Function · 0.76