You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cty: Silently ignore refinements of cty.DynamicVal
For historical reasons we cannot permit any refinements on cty.DynamicVal,
because existing callers expect that (marks notwithstanding) cty.DynamicVal
is the only possible unknown value of an unknown type, and so adding
refinements would invalidate that assumption.
In the initial implementation of refinements it was treated as a caller
programming error to try to refine cty.DynamicVal. However, that violates
the convention that cty.DynamicVal is usable as a broad placeholder value
that supports any operation that would be valid on at least one possible
value.
Instead, we'll now compromise by just silently ignoring any attempt to
refine cty.DynamicVal. The refinement operation will run to completion
without panicking but it will also completely ignore all of the refinement
builder calls and eventually just return another plain cty.DynamicVal
as the "refined" result.
This is consistent with our typical expectation that refinements are
propagated on a best-effort basis but can be silently discarded (or lose
some detail) when passing through operations that don't or can't support
them.
This means that it should now be safe to call Refine on any value, but
refining can still panic if the specific refinements selected don't make
sense for whatever value is being refined.
This also includes some direct tests of the Value.Refine API, since it
was previously only tested indirectly through other operations that
consume or manipulate refinements.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
# 1.14.1 (Unreleased)
2
2
3
+
*`cty`: It's now valid to use the `Refine` method on `cty.DynamicVal`, although all refinements will be silently discarded. This replaces the original behavior of panicking when trying to refine `cty.DynamicVal`.
0 commit comments