This commit is contained in:
Gavin Nishizawa 2023-09-22 14:16:35 -07:00
parent 68901fa205
commit 20190c1224
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
2 changed files with 220 additions and 0 deletions

View file

@ -4061,6 +4061,20 @@ z: {
`, `d2/testdata/d2compiler/TestCompile2/vars/errors/spread-non-solo.d2:8:2: cannot substitute composite variable "x" as part of a string`)
},
},
{
name: "spread-mid-string",
run: func(t *testing.T) {
assertCompile(t, `
vars: {
test: hello
}
mybox: {
label: prefix${test}suffix
}
`, "")
},
},
}
for _, tc := range tca {

View file

@ -0,0 +1,206 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,0:0:0-8:0:66",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,1:0:1-3:1:24",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,1:0:1-1:4:5",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,1:0:1-1:4:5",
"value": [
{
"string": "vars",
"raw_string": "vars"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,1:6:7-3:1:24",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,2:2:11-2:13:22",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,2:2:11-2:6:15",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,2:2:11-2:6:15",
"value": [
{
"string": "test",
"raw_string": "test"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,2:8:17-2:13:22",
"value": [
{
"string": "hello",
"raw_string": "hello"
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,5:0:26-7:1:65",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,5:0:26-5:5:31",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,5:0:26-5:5:31",
"value": [
{
"string": "mybox",
"raw_string": "mybox"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,5:7:33-7:1:65",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,6:2:37-6:28:63",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,6:2:37-6:7:42",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,6:2:37-6:7:42",
"value": [
{
"string": "label",
"raw_string": "label"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,6:9:44-6:28:63",
"value": [
{
"string": "prefixhellosuffix"
}
]
}
}
}
}
]
}
}
}
}
]
},
"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": "mybox",
"id_val": "mybox",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,5:0:26-5:5:31",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/vars/errors/spread-mid-string.d2,5:0:26-5:5:31",
"value": [
{
"string": "mybox",
"raw_string": "mybox"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "prefixhellosuffix"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
"err": null
}