Commit 0fdcf0e
Forward to v1.6.0 (#15)
* Prepare for a possible future 1.5.2 release
* function/stdlib: Check for negative indices in ElementFunc
Previously a negative index would lead to a panic.
* Update CHANGELOG.md
* convert: Experimental optional object attributes
Previously we required that when converting to an object type the input
must have at least the attributes from the target type, and optionally
additional attributes that would then be discarded.
We'll now allow creating an object type with one or more optional
attributes. These are optional only for conversion purposes: converting
to an object type with optional arguments will substitute a null value
for any attribute that doesn't exist in the source object type.
This being handled only under conversion is consistent with some other
similar cases: an object type is not conforming to a type constraint if
it has attributes that are not in the type constraint, even though a
conversion to that type constraint would be accepted. Likewise, a number
doesn't conform to the string type even though a conversion is available.
This distinction is so that cty applications can potentially bring their
own separate conversion rules if they wish, ignoring the convert package
in this repository.
For now this new capability is explicitly experimental and so not subject
to our typical backward-compatibility promises. The behavior of any
function producing or working with object types that have optional
attributes is subject to change even in future minor versions of this
package.
* Update CHANGELOG.md
* dependencies: use major version 4 of the underlying msgpack library
This is just in the interests of keeping things up-to-date and doesn't
really confer any specific benefit.
The underlying library now defaults to always using the full-length
encoding for integers provided as int64, so this change also includes
an explicit opt-in to the old behavior of selecting the most compact
integer representation possible, because for cty the different numeric
encodings are just a size optimization and have no semantic meaning.
* cty: Fix various quirks of handling sets with unknown values
Early in the implementation of cty I made an oversight which has,
unfortunately, played out as a variety of incorrect behaviors throughout
the cty functions: when a set contains unknown values, those unknown
values can potentially be standing in for values that are equal to others
in the set, and thus the effective length of the set can't be predicted.
Previously the Length function would return, in effect, the maximum
possible size of the set, which would result if all of the values
represented by the unknowns are non-equal. The caller might then get a
different known result from a call with unknowns than from a subsequent
call with those unknowns replaced with known values, which violates the
guarantees that cty intends to make when handling unknown values.
This changeset therefore starts by addressing that root bug: Length will
now return an unknown number if called on a set containing unknown values,
correctly representing that the final length is unpredictable.
This in turn had some downstream consequences for other functionality.
In particular, it should not have been possible to convert a set whose
length is unknown to a list, because it's not possible for a list to have
an unknown length. Therefore this changeset also includes a fix to the
convert package so that an unknown-length set converts to an unknown
list, which also addresses the related problem that a conversion from a
set to list can't predict where the unknown values will appear in the
sort order and thus can't predict the list indices even for the known
elements.
The rest of the changes here are similar adjustments to account for the
possibility of an unknown set length, in most cases similarly returning
an unknown result.
This changeset causes a difference in observable behavior from the
previous version, but it's not considered to be a breaking change because
the previous behavior was defective. With that said, callers that were
inadvertently depending on the defective behavior will find that their
calling application now behaves slightly differently, and so may wish to
make adjustments if the defective prior behavior was actually desirable
for some unusual situation.
As a pragmatic accommodation for existing callers, the Value.LengthInt
function is now defined as returning the maximum possible length in
situations where the length is unknown. This aligns with the number of
iterations a caller would encounter using an ElementIterator on such a
value, and also reflects a suitable capacity to use when allocating a
Go slice to append iterated elements into.
* Update CHANGELOG.md
* v1.6.0
* Update CHANGELOG.md
---------
Co-authored-by: Martin Atkins <[email protected]>
Co-authored-by: Kristin Laemmert <[email protected]>1 parent 8d5ce63 commit 0fdcf0e
File tree
27 files changed
+785
-57
lines changed- cty
- convert
- function/stdlib
- msgpack
- docs
27 files changed
+785
-57
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
1 | 18 | | |
2 | 19 | | |
3 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
| |||
458 | 466 | | |
459 | 467 | | |
460 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
461 | 479 | | |
462 | 480 | | |
463 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
| |||
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
74 | 93 | | |
75 | 94 | | |
76 | 95 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
146 | 154 | | |
147 | 155 | | |
148 | 156 | | |
| |||
182 | 190 | | |
183 | 191 | | |
184 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
185 | 214 | | |
186 | 215 | | |
187 | 216 | | |
| |||
381 | 410 | | |
382 | 411 | | |
383 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
384 | 439 | | |
385 | 440 | | |
386 | 441 | | |
| |||
476 | 531 | | |
477 | 532 | | |
478 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
479 | 578 | | |
480 | 579 | | |
481 | 580 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
141 | 148 | | |
142 | 149 | | |
143 | 150 | | |
| |||
173 | 180 | | |
174 | 181 | | |
175 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
176 | 187 | | |
177 | 188 | | |
178 | 189 | | |
| |||
492 | 503 | | |
493 | 504 | | |
494 | 505 | | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
495 | 511 | | |
496 | 512 | | |
497 | 513 | | |
| |||
872 | 888 | | |
873 | 889 | | |
874 | 890 | | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
875 | 895 | | |
876 | 896 | | |
877 | 897 | | |
| |||
1019 | 1039 | | |
1020 | 1040 | | |
1021 | 1041 | | |
1022 | | - | |
| 1042 | + | |
| 1043 | + | |
1023 | 1044 | | |
1024 | 1045 | | |
1025 | 1046 | | |
| |||
0 commit comments