lang: types: Improve docs for New and initialize the list

If we use this to generate a zero value, we want to make sure it's
completely initialized in case we use it subsequently. We also improve
the docs at the same time.
This commit is contained in:
James Shubin
2023-10-11 20:38:35 -04:00
parent d6a58f33f3
commit 3b46e88734
2 changed files with 6 additions and 1 deletions

View File

@@ -550,8 +550,12 @@ func NewType(s string) *Type {
return nil // error (this also matches the empty string as input)
}
// New creates a new Value of this type.
// New creates a new Value of this type. It will represent the "zero" value. It
// panics if you give it a malformed type.
func (obj *Type) New() Value {
if obj == nil {
panic("malformed type")
}
switch obj.Kind {
case KindBool:
return NewBool()