diff options
Diffstat (limited to 'tests/typ/compiler/ops.typ')
| -rw-r--r-- | tests/typ/compiler/ops.typ | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/typ/compiler/ops.typ b/tests/typ/compiler/ops.typ index 4d3b071f..e148dd19 100644 --- a/tests/typ/compiler/ops.typ +++ b/tests/typ/compiler/ops.typ @@ -274,6 +274,38 @@ #test(b, 1) --- +// Test comma placement in destructuring assignment. +#let array = (1, 2, 3) +#((key: array.at(1)) = (key: "hi")) +#test(array, (1, "hi", 3)) + +#let array = (1, 2, 3) +#((array.at(1)) = ("hi")) +#test(array, (1, "hi", 3)) + +#let array = (1, 2, 3) +#((array.at(1),) = ("hi",)) +#test(array, (1, "hi", 3)) + +#let array = (1, 2, 3) +#((array.at(1)) = ("hi",)) +#test(array, (1, ("hi",), 3)) + +--- +// Test nested destructuring assignment. +#let a +#let b +#let c +#(((a, b), (key: c)) = ((1, 2), (key: 3))) +#test((a, b, c), (1, 2, 3)) + +--- +#let array = (1, 2, 3) +// Error: 3-17 cannot destructure string +#((array.at(1),) = ("hi")) +#test(array, (1, ("hi",), 3)) + +--- // Error: 3-6 cannot mutate a constant: box #(box = 1) |
