vendor: update hcl dependencies

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-04-14 12:55:59 +02:00
parent eb74b483bd
commit fb4417e14d
7 changed files with 104 additions and 65 deletions

View File

@ -127,6 +127,29 @@ func impliedObjectType(dec *json.Decoder) (cty.Type, error) {
if atys == nil {
atys = make(map[string]cty.Type)
}
if existing, exists := atys[key]; exists {
// We didn't originally have any special treatment for multiple properties
// of the same name, having the type of the last one "win". But that caused
// some confusing error messages when the same input was subsequently used
// with [Unmarshal] using the returned object type, since [Unmarshal] would
// try to fit all of the property values of that name to whatever type
// the last one had, and would likely fail in doing so if the earlier
// properties of the same name had different types.
//
// As a compromise to avoid breaking existing successful use of _consistently-typed_
// redundant properties, we return an error here only if the new type
// differs from the old type. The error message doesn't mention that subtlety
// because the equal type carveout is a compatibility concession rather than
// a feature folks should rely on in new code.
if !existing.Equals(aty) {
// This error message is low-quality because ImpliedType doesn't do
// path tracking while it traverses, unlike Unmarshal. However, this
// is a rare enough case that we don't want to pay the cost of allocating
// another path-tracking buffer that would in most cases be ignored,
// so we just accept a low-context error message. :(
return cty.NilType, fmt.Errorf("duplicate %q property in JSON object", key)
}
}
atys[key] = aty
}