zclconf / go-cty

A type system for dynamic values in Go applications
MIT License
348 stars 71 forks source link

include NilType in .WithoutOptionalAttributesDeep #173

Closed jbardin closed 11 months ago

jbardin commented 11 months ago

NilType is a valid type which was missed when listing all types under WithoutOptionalAttributesDeep. It should generally not appear here, but seems safe to account for in this case to prevent panics. If the NilType is not valid, then the caller will have to deal with that anyway.

apparentlymart commented 11 months ago

I prefer to make NilType panic when used for anything other than representing the total absence of a type. It always represents a bug in the calling program, so I'd rather let the caller know they have a bug and decide how to fix it.

jbardin commented 11 months ago

Fair enough! Not every method panics, so I wasn't certain which way to go here. I'll figure which caller should be validating the type before this call.

apparentlymart commented 11 months ago

I did make an exception for RawEquals because it is trying to create a notion of "type identity" for more convenient testing, but otherwise any allowances for cty.NilType are probably a historical mistake.