Closed ryancragun closed 9 months ago
Hi @ryancragun! Thanks for working on this.
cty.NilType
is not a valid type -- it represents the absence of one -- and so I think it's reasonable for this to be a panic although I would agree that the panic message is not communicating that well.
The name NilType
is intended to communicate that it's similar to Go's native nil
for types like interfaces, where it literally represents "nothing" and most interactions with it will panic. The same is true for NilValue
which is the analogous concept for values. These "nothing" values exist for situations such as in functions that return cty.Type, error
where the error and the type are mutually exclusive. No "real" type should ever include cty.NilType
anywhere in it.
Sounds good. Here's another attempt of fixing the panic https://github.com/zclconf/go-cty/pull/171
Fix an issue where
WithoutOptionalAttributesDeep()
on acty.NilType
would result in a panic. This was discovered when usinggohcl
to decode a block that has attributes that are set to null.