From 85cf491d74cba05c9d06830ebe26eba22f540e77 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Tue, 11 Jul 2023 14:56:09 -0700 Subject: [PATCH] quotes --- d2compiler/compile_test.go | 35 ++ d2graph/d2graph.go | 1 + d2ir/compile.go | 9 +- .../vars/basic/edge_label.exp.json | 5 +- .../TestCompile2/vars/basic/label.exp.json | 5 +- .../TestCompile2/vars/basic/nested.exp.json | 5 +- .../TestCompile2/vars/basic/number.exp.json | 11 +- .../vars/basic/quoted-var-quoted-sub.exp.json | 177 ++++++++++ .../vars/basic/quoted-var.exp.json | 330 ++++++++++++++++++ .../TestCompile2/vars/basic/style.exp.json | 5 +- .../TestCompile2/vars/boards/layer.exp.json | 10 +- .../TestCompile2/vars/boards/overlay.exp.json | 40 ++- .../TestCompile2/vars/boards/replace.exp.json | 10 +- .../vars/boards/scenario.exp.json | 10 +- .../vars/errors/nested-missing.exp.json | 11 + .../TestCompile2/vars/override/label.exp.json | 5 +- 16 files changed, 622 insertions(+), 47 deletions(-) create mode 100644 testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.exp.json create mode 100644 testdata/d2compiler/TestCompile2/vars/basic/quoted-var.exp.json create mode 100644 testdata/d2compiler/TestCompile2/vars/errors/nested-missing.exp.json diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index e9a59d6cc..d64283335 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -3290,6 +3290,41 @@ a -> b: ${x} assert.Equal(t, "im a var", g.Edges[0].Label.Value) }, }, + { + name: "quoted-var", + run: func(t *testing.T) { + g := assertCompile(t, ` +vars: { + primaryColors: { + button: { + active: "#4baae5" + } + } +} + +button: { + style: { + border-radius: 5 + fill: ${primaryColors.button.active} + } +} +`, "") + assert.Equal(t, `#4baae5`, g.Objects[0].Style.Fill.Value) + }, + }, + { + name: "quoted-var-quoted-sub", + run: func(t *testing.T) { + g := assertCompile(t, ` +vars: { + x: "hi" +} + +y: "hey ${x}" +`, "") + assert.Equal(t, `hey "hi"`, g.Objects[0].Label.Value) + }, + }, } for _, tc := range tca { diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 26413dcb3..f7aa7ec2b 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1651,6 +1651,7 @@ var SimpleReservedKeywords = map[string]struct{}{ "vertical-gap": {}, "horizontal-gap": {}, "class": {}, + "vars": {}, } // ReservedKeywordHolders are reserved keywords that are meaningless on its own and must hold composites diff --git a/d2ir/compile.go b/d2ir/compile.go index 3fa8f3edb..bcfabb346 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -116,8 +116,13 @@ func (c *compiler) resolveSubstitutions(refctx *RefContext) { if box.Substitution != nil { resolvedField := c.resolveSubstitution(varsMap, refctx.Key, box.Substitution) if resolvedField != nil { - refctx.Key.Value.UnquotedString.Value[i].String = go2.Pointer(resolvedField.Primary().String()) - subbed = true + // If lone and unquoted, replace with value of sub + if len(refctx.Key.Value.UnquotedString.Value) == 1 { + refctx.Key.Value = d2ast.MakeValueBox(resolvedField.Primary().Value) + } else { + refctx.Key.Value.UnquotedString.Value[i].String = go2.Pointer(resolvedField.Primary().String()) + subbed = true + } } } } diff --git a/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json index f7d87362c..77d0d380f 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json @@ -112,10 +112,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/edge_label.d2,4:8:33-4:9:34", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/edge_label.d2,2:5:14-2:13:22", "value": [ { - "string": "im a var" + "string": "im a var", + "raw_string": "im a var" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json index 5a0acd806..723fae322 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json @@ -89,10 +89,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/label.d2,4:4:29-4:5:30", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/label.d2,2:5:14-2:13:22", "value": [ { - "string": "im a var" + "string": "im a var", + "raw_string": "im a var" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json index d32d26e50..759360078 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json @@ -182,10 +182,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/nested.d2,9:14:85-9:15:86", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/nested.d2,4:14:49-4:17:52", "value": [ { - "string": "red" + "string": "red", + "raw_string": "red" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json index 37d67c845..a7a5fb0e5 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json @@ -108,13 +108,10 @@ }, "primary": {}, "value": { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/number.d2,5:15:44-5:16:45", - "value": [ - { - "string": "2" - } - ] + "number": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/number.d2,2:10:19-2:11:20", + "raw": "2", + "value": "2" } } } diff --git a/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.exp.json new file mode 100644 index 000000000..1004100aa --- /dev/null +++ b/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.exp.json @@ -0,0 +1,177 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,0:0:0-6:0:36", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,1:0:1-3:1:20", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,1:0:1-1:4:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,1:0:1-1:4:5", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,1:6:7-3:1:20", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,2:2:11-2:9:18", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,2:2:11-2:3:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,2:2:11-2:3:12", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,2:5:14-2:9:18", + "value": [ + { + "string": "hi", + "raw_string": "hi" + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,5:0:22-5:13:35", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,5:0:22-5:1:23", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,5:0:22-5:1:23", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,5:3:25-5:13:35", + "value": [ + { + "string": "hey \"hi\"" + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "y", + "id_val": "y", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,5:0:22-5:1:23", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var-quoted-sub.d2,5:0:22-5:1:23", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "hey \"hi\"" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.exp.json new file mode 100644 index 000000000..4b4d56a32 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.exp.json @@ -0,0 +1,330 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,0:0:0-15:0:168", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,1:0:1-7:1:77", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,1:0:1-1:4:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,1:0:1-1:4:5", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,1:6:7-7:1:77", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,2:2:11-6:3:75", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,2:2:11-2:15:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,2:2:11-2:15:24", + "value": [ + { + "string": "primaryColors", + "raw_string": "primaryColors" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,2:17:26-6:3:75", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,3:4:32-5:5:71", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,3:4:32-3:10:38", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,3:4:32-3:10:38", + "value": [ + { + "string": "button", + "raw_string": "button" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,3:12:40-5:5:71", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,4:6:48-4:23:65", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,4:6:48-4:12:54", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,4:6:48-4:12:54", + "value": [ + { + "string": "active", + "raw_string": "active" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,4:14:56-4:23:65", + "value": [ + { + "string": "#4baae5", + "raw_string": "#4baae5" + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,9:0:79-14:1:167", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,9:0:79-9:6:85", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,9:0:79-9:6:85", + "value": [ + { + "string": "button", + "raw_string": "button" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,9:8:87-14:1:167", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,10:2:91-13:3:165", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,10:2:91-10:7:96", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,10:2:91-10:7:96", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,10:9:98-13:3:165", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,11:4:104-11:20:120", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,11:4:104-11:17:117", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,11:4:104-11:17:117", + "value": [ + { + "string": "border-radius", + "raw_string": "border-radius" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,11:19:119-11:20:120", + "raw": "5", + "value": "5" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,12:4:125-12:40:161", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,12:4:125-12:8:129", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,12:4:125-12:8:129", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,4:14:56-4:23:65", + "value": [ + { + "string": "#4baae5", + "raw_string": "#4baae5" + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "button", + "id_val": "button", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,9:0:79-9:6:85", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/quoted-var.d2,9:0:79-9:6:85", + "value": [ + { + "string": "button", + "raw_string": "button" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "button" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "#4baae5" + }, + "borderRadius": { + "value": "5" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json index 11ae2fe4d..c5a5ae699 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json @@ -124,10 +124,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/style.d2,5:14:52-5:15:53", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/style.d2,2:17:26-2:20:29", "value": [ { - "string": "red" + "string": "red", + "raw_string": "red" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json index 7f3f693b1..6ca33821b 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json @@ -137,10 +137,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,7:8:51-7:9:52", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,2:5:14-2:13:22", "value": [ { - "string": "im a var" + "string": "im a var", + "raw_string": "im a var" } ] } @@ -271,10 +272,11 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,7:8:51-7:9:52", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,2:5:14-2:13:22", "value": [ { - "string": "im a var" + "string": "im a var", + "raw_string": "im a var" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json index 23431936c..06ce2bc1c 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json @@ -199,10 +199,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,10:7:89-10:8:90", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", "value": [ { - "string": "im x var" + "string": "im x var", + "raw_string": "im x var" } ] } @@ -231,10 +232,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,11:7:101-11:8:102", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,8:9:67-8:17:75", "value": [ { - "string": "im y var" + "string": "im y var", + "raw_string": "im y var" } ] } @@ -383,10 +385,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,19:7:173-19:8:174", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", "value": [ { - "string": "im x var" + "string": "im x var", + "raw_string": "im x var" } ] } @@ -415,10 +418,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,20:7:185-20:8:186", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,17:9:151-17:17:159", "value": [ { - "string": "im y var" + "string": "im y var", + "raw_string": "im y var" } ] } @@ -581,10 +585,11 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,19:7:173-19:8:174", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", "value": [ { - "string": "im x var" + "string": "im x var", + "raw_string": "im x var" } ] } @@ -612,10 +617,11 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,20:7:185-20:8:186", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,17:9:151-17:17:159", "value": [ { - "string": "im y var" + "string": "im y var", + "raw_string": "im y var" } ] } @@ -862,10 +868,11 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,10:7:89-10:8:90", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", "value": [ { - "string": "im x var" + "string": "im x var", + "raw_string": "im x var" } ] } @@ -893,10 +900,11 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,11:7:101-11:8:102", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,8:9:67-8:17:75", "value": [ { - "string": "im y var" + "string": "im y var", + "raw_string": "im y var" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json index fc75006dd..0637551ac 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json @@ -199,10 +199,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,10:7:98-10:8:99", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,8:9:67-8:26:84", "value": [ { - "string": "im replaced x var" + "string": "im replaced x var", + "raw_string": "im replaced x var" } ] } @@ -333,10 +334,11 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,10:7:98-10:8:99", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,8:9:67-8:26:84", "value": [ { - "string": "im replaced x var" + "string": "im replaced x var", + "raw_string": "im replaced x var" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json index 571e94ad8..aed67f583 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json @@ -137,10 +137,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,7:8:54-7:9:55", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,2:5:14-2:13:22", "value": [ { - "string": "im a var" + "string": "im a var", + "raw_string": "im a var" } ] } @@ -271,10 +272,11 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,7:8:54-7:9:55", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,2:5:14-2:13:22", "value": [ { - "string": "im a var" + "string": "im a var", + "raw_string": "im a var" } ] } diff --git a/testdata/d2compiler/TestCompile2/vars/errors/nested-missing.exp.json b/testdata/d2compiler/TestCompile2/vars/errors/nested-missing.exp.json new file mode 100644 index 000000000..96bef919a --- /dev/null +++ b/testdata/d2compiler/TestCompile2/vars/errors/nested-missing.exp.json @@ -0,0 +1,11 @@ +{ + "graph": null, + "err": { + "errs": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/vars/errors/nested-missing.d2,6:0:33-6:10:43", + "errmsg": "d2/testdata/d2compiler/TestCompile2/vars/errors/nested-missing.d2:7:1: could not resolve variable \"x.z\"" + } + ] + } +} diff --git a/testdata/d2compiler/TestCompile2/vars/override/label.exp.json b/testdata/d2compiler/TestCompile2/vars/override/label.exp.json index 9040dfa59..f1a1cb4be 100644 --- a/testdata/d2compiler/TestCompile2/vars/override/label.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/override/label.exp.json @@ -89,10 +89,11 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/override/label.d2,4:4:29-4:5:30", + "range": "d2/testdata/d2compiler/TestCompile2/vars/override/label.d2,2:5:14-2:13:22", "value": [ { - "string": "im a var" + "string": "im a var", + "raw_string": "im a var" } ] }