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

Method SetType

lang/ast/structs.go:12830–12836  ·  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

12828// change on expressions, if you attempt to set a different type than what has
12829// previously been set (when not initially known) this will error.
12830func (obj *ExprIf) SetType(typ *types.Type) error {
12831 if obj.typ != nil {
12832 return obj.typ.Cmp(typ) // if not set, ensure it doesn't change
12833 }
12834 obj.typ = typ // set
12835 return nil
12836}
12837
12838// Type returns the type of this expression.
12839func (obj *ExprIf) Type() (*types.Type, error) {

Callers 1

TestUnification1Function · 0.95

Calls 1

CmpMethod · 0.65

Tested by 1

TestUnification1Function · 0.76