From 778aa4e7dfd616743f3b9e18e10bb53f5d441f5f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 9 May 2022 00:11:03 +0200 Subject: Mutable field access --- tests/typ/code/dict.typ | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'tests/typ/code') diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ index 80097761..182f53d9 100644 --- a/tests/typ/code/dict.typ +++ b/tests/typ/code/dict.typ @@ -17,10 +17,14 @@ --- // Test lvalue and rvalue access. { - let dict = (a: 1, b: 1) - dict("b") += 1 - dict("c") = 3 - test(dict, (a: 1, b: 2, c: 3)) + let dict = (a: 1, "b b": 1) + dict("b b") += 1 + dict.state = (ok: true, err: false) + test(dict, (a: 1, "b b": 2, state: (ok: true, err: false))) + test(dict.state.ok, true) + dict("state").ok = false + test(dict.state.ok, false) + test(dict.state.err, false) } --- @@ -58,3 +62,14 @@ // Error: 12-16 expected identifier or string, found boolean // Error: 17-18 expected expression, found colon {(:1 b:"", true::)} + +--- +// Error: 3-15 cannot mutate a temporary value +{ (key: value).other = "some" } + +--- +{ + let object = none + // Error: 3-9 expected dictionary, found none + object.property = "value" +} -- cgit v1.2.3