From 2a45650dcc87c3bf047adaf030fd392bbe9fbb5e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 4 May 2022 23:04:19 +0200 Subject: Keyed pairs --- tests/typ/code/dict.typ | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/typ/code/dict.typ') diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ index 23af145f..00c78c17 100644 --- a/tests/typ/code/dict.typ +++ b/tests/typ/code/dict.typ @@ -7,8 +7,12 @@ // Empty {(:)} -// Two pairs. -{(a1: 1, a2: 2)} +// Two pairs and string key. +#let dict = (normal: 1, "spaced key": 2) +#dict + +#test(dict.normal, 1) +#test(dict("spaced key"), 2) --- // Test lvalue and rvalue access. @@ -39,14 +43,18 @@ // Error: 24-32 pair has duplicate key {(first: 1, second: 2, first: 3)} +--- +// Error: 17-23 pair has duplicate key +{(a: 1, "b": 2, "a": 3)} + --- // Simple expression after already being identified as a dictionary. -// Error: 9-10 expected named pair, found expression +// Error: 9-10 expected named or keyed pair, found expression {(a: 1, b)} // Identified as dictionary due to initial colon. -// Error: 4-5 expected named pair, found expression +// Error: 4-5 expected named or keyed pair, found expression // Error: 5 expected comma -// Error: 12-16 expected identifier +// Error: 12-16 expected identifier or string // Error: 17-18 expected expression, found colon {(:1 b:"", true::)} -- cgit v1.2.3