From 3ad07260f369dc285e5ae856b78a58c3b13ee622 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 26 Nov 2025 21:12:11 -0500 Subject: Close loophole in `when` statements that allowed mutating inner field members --- test/values.tm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/values.tm') diff --git a/test/values.tm b/test/values.tm index 86f34a89..9f86c012 100644 --- a/test/values.tm +++ b/test/values.tm @@ -3,6 +3,8 @@ struct Inner(xs:[Int32]) struct Outer(inner:Inner) +enum HoldsList(HasList(xs:[Int32])) + func sneaky(outer:Outer) (&outer.inner.xs)[1] = 99 @@ -45,3 +47,9 @@ func main() assert foo.inner.xs == [99, 20, 30] assert copy.inner.xs == [10, 20, 30] + do + x := HoldsList.HasList([10, 20, 30]) + when x is HasList(list) + (&list)[1] = 99 + + assert x == HoldsList.HasList([10, 20, 30]) -- cgit v1.2.3