d2ir: Fix lazy globs being applied in reverse

This commit is contained in:
Anmol Sethi 2023-08-16 15:34:48 -07:00
parent 8455a7da8d
commit d90f8253df
No known key found for this signature in database
GPG key ID: 8CEF1878FF10ADEB
12 changed files with 6645 additions and 5462 deletions

View file

@ -359,6 +359,20 @@ func (c *compiler) overlay(base *Map, f *Field) {
f.Composite = base
}
func (g *globContext) prefixed(dst *Map) *globContext {
g2 := *g
g2.refctx = g.refctx.Copy()
prefix := d2ast.MakeKeyPath(RelIDA(g2.refctx.ScopeMap, dst))
g2.refctx.Key = g2.refctx.Key.Copy()
if g2.refctx.Key.Key != nil {
prefix.Path = append(prefix.Path, g2.refctx.Key.Key.Path...)
}
if len(prefix.Path) > 0 {
g2.refctx.Key.Key = prefix
}
return &g2
}
func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) {
var globs []*globContext
if len(c.globContextStack) > 0 {
@ -366,36 +380,13 @@ func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) {
if NodeBoardKind(dst) == BoardLayer {
for _, g := range previousGlobs {
if g.refctx.Key.HasTripleGlob() {
// Same as below but reset applied too.
g2 := *g
g2.refctx = g.refctx.Copy()
g2.appliedFields = make(map[string]struct{})
g2.appliedEdges = make(map[string]struct{})
prefix := d2ast.MakeKeyPath(RelIDA(g2.refctx.ScopeMap, dst))
g2.refctx.Key = g2.refctx.Key.Copy()
if g2.refctx.Key.Key != nil {
prefix.Path = append(prefix.Path, g2.refctx.Key.Key.Path...)
}
if len(prefix.Path) > 0 {
g2.refctx.Key.Key = prefix
}
globs = append(globs, &g2)
globs = append(globs, g.prefixed(dst))
}
}
} else if NodeBoardKind(dst) != "" {
// Make all globs relative to the scenario or step.
for _, g := range previousGlobs {
g2 := *g
g2.refctx = g.refctx.Copy()
prefix := d2ast.MakeKeyPath(RelIDA(g2.refctx.ScopeMap, dst))
g2.refctx.Key = g2.refctx.Key.Copy()
if g2.refctx.Key.Key != nil {
prefix.Path = append(prefix.Path, g2.refctx.Key.Key.Path...)
}
if len(prefix.Path) > 0 {
g2.refctx.Key.Key = prefix
}
globs = append(globs, &g2)
globs = append(globs, g.prefixed(dst))
}
} else {
globs = append(globs, previousGlobs...)
@ -492,7 +483,7 @@ func (c *compiler) ensureGlobContext(refctx *RefContext) *globContext {
func (c *compiler) compileKey(refctx *RefContext) {
if refctx.Key.HasGlob() {
// These three printlns are for debugging infinite loops.
// These printlns are for debugging infinite loops.
// println("og", refctx.Edge, refctx.Key, refctx.Scope, refctx.ScopeMap, refctx.ScopeAST)
for _, refctx2 := range c.globRefContextStack {
// println("st", refctx2.Edge, refctx2.Key, refctx2.Scope, refctx2.ScopeMap, refctx2.ScopeAST)
@ -508,11 +499,19 @@ func (c *compiler) compileKey(refctx *RefContext) {
}()
c.ensureGlobContext(refctx)
}
oldFields := refctx.ScopeMap.FieldCountRecursive()
oldEdges := refctx.ScopeMap.EdgeCountRecursive()
if len(refctx.Key.Edges) == 0 {
c.compileField(refctx.ScopeMap, refctx.Key.Key, refctx)
} else {
c.compileEdges(refctx)
}
if oldFields != refctx.ScopeMap.FieldCountRecursive() || oldEdges != refctx.ScopeMap.EdgeCountRecursive() {
for _, gctx2 := range c.globContexts() {
// println(d2format.Format(gctx2.refctx.Key), d2format.Format(refctx.Key))
c.compileKey(gctx2.refctx)
}
}
}
func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) {

View file

@ -697,21 +697,18 @@ func (m *Map) EnsureField(kp *d2ast.KeyPath, refctx *RefContext, create bool, c
var fa []*Field
err := m.ensureField(i, kp, refctx, create, gctx, c, &fa)
if err != nil {
return fa, err
}
if len(fa) > 0 && create && c != nil {
for _, gctx2 := range c.globContexts() {
c.compileKey(gctx2.refctx)
}
}
return fa, nil
return fa, err
}
func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext, create bool, gctx *globContext, c *compiler, fa *[]*Field) error {
filter := func(f *Field, passthrough bool) bool {
ks := d2format.Format(d2ast.MakeKeyPath(BoardIDA(f)))
if gctx != nil {
var ks string
if refctx.Key.HasTripleGlob() {
ks = d2format.Format(d2ast.MakeKeyPath(IDA(f)))
} else {
ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(f)))
}
// For globs with edges, we only ignore duplicate fields if the glob is not at the terminal of the keypath, the glob is on the common key or the glob is on the edge key.
if !kp.HasGlob() {
if !passthrough {
@ -1031,15 +1028,7 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext, c *compiler) ([]*Edge,
gctx = c.ensureGlobContext(refctx)
}
err := m.createEdge(eid, refctx, gctx, c, &ea)
if err != nil {
return ea, err
}
if len(ea) > 0 && c != nil {
for _, gctx2 := range c.globContexts() {
c.compileKey(gctx2.refctx)
}
}
return ea, nil
return ea, err
}
func (m *Map) createEdge(eid *EdgeID, refctx *RefContext, gctx *globContext, c *compiler, ea *[]*Edge) error {
@ -1179,7 +1168,12 @@ func (m *Map) createEdge2(eid *EdgeID, refctx *RefContext, gctx *globContext, sr
}
if gctx != nil {
ks := d2format.Format(d2ast.MakeKeyPath(BoardIDA(e)))
var ks string
if refctx.Key.HasTripleGlob() {
ks = d2format.Format(d2ast.MakeKeyPath(IDA(e)))
} else {
ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(e)))
}
if _, ok := gctx.appliedEdges[ks]; ok {
return nil, nil
}

View file

@ -49,10 +49,9 @@ func (m *Map) _tripleGlob(fa *[]*Field) {
}
continue
}
if NodeBoardKind(f) != "" {
continue
if NodeBoardKind(f) == "" {
*fa = append(*fa, f)
}
*fa = append(*fa, f)
if f.Map() != nil {
f.Map()._tripleGlob(fa)
}

View file

@ -482,6 +482,39 @@ c
assertQuery(t, m, 6, 0, nil, "")
},
},
{
name: "override/1",
run: func(t testing.TB) {
m, err := compile(t, `
**.style.fill: yellow
**.style.fill: red
a
`)
assert.Success(t, err)
assertQuery(t, m, 3, 0, nil, "")
assertQuery(t, m, 0, 0, "red", "a.style.fill")
},
},
{
name: "override/2",
run: func(t testing.TB) {
m, err := compile(t, `
***.style.fill: yellow
layers: {
hi: {
**.style.fill: red
# should be red, but it's yellow right now
a
}
}
`)
assert.Success(t, err)
assertQuery(t, m, 5, 0, nil, "")
assertQuery(t, m, 0, 0, "red", "layers.hi.a.style.fill")
},
},
}
runa(t, tca)

File diff suppressed because it is too large Load diff

View file

@ -1204,6 +1204,334 @@
"value": {}
}
}
},
{
"string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
},
"key_path": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:5:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:3:7",
"value": [
{
"string": "***",
"raw_string": "***"
}
],
"pattern": [
"*",
"",
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"context": {
"edge": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:10:14",
"src": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:5:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:3:7",
"value": [
{
"string": "***",
"raw_string": "***"
}
],
"pattern": [
"*",
"",
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"dst_arrow": ">"
},
"key": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:10:14",
"edges": [
{
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:10:14",
"src": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:5:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:3:7",
"value": [
{
"string": "***",
"raw_string": "***"
}
],
"pattern": [
"*",
"",
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
}
},
{
"string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
},
"key_path": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:5:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:3:7",
"value": [
{
"string": "***",
"raw_string": "***"
}
],
"pattern": [
"*",
"",
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"context": {
"edge": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:10:14",
"src": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:5:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:3:7",
"value": [
{
"string": "***",
"raw_string": "***"
}
],
"pattern": [
"*",
"",
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"dst_arrow": ">"
},
"key": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:10:14",
"edges": [
{
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:10:14",
"src": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:5:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:0:4-3:3:7",
"value": [
{
"string": "***",
"raw_string": "***"
}
],
"pattern": [
"*",
"",
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:4:8-3:5:9",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/3.d2,3:9:13-3:10:14",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
}
}
]
}

View file

@ -1560,83 +1560,6 @@
}
]
},
{
"name": "shape",
"primary": {
"value": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
}
]
},
{
"name": "p",
"composite": {
@ -1774,6 +1697,83 @@
}
}
]
},
{
"name": "shape",
"primary": {
"value": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
}
]
}
],
"edges": null
@ -1880,6 +1880,145 @@
}
}
}
},
{
"string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "x"
}
]
},
"key_path": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "scenarios"
}
]
}
},
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:0:0-0:2:2",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:0:0-2:1:20",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "scenarios"
}
]
}
},
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:0:0-0:2:2",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:4:4-2:1:20",
"nodes": [
{
"map_key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
]
}
}
}
}
}
]
},

782
testdata/d2ir/TestCompile/patterns/override/1.exp.json generated vendored Normal file
View file

@ -0,0 +1,782 @@
{
"fields": [
{
"name": "a",
"composite": {
"fields": [
{
"name": "style",
"composite": {
"fields": [
{
"name": "fill",
"primary": {
"value": {
"range": "TestCompile/patterns/override/1.d2,2:15:38-2:18:41",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/override/1.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
},
"key_path": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:21:22",
"key": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:15:16-1:21:22",
"value": [
{
"string": "yellow",
"raw_string": "yellow"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
},
"key_path": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:18:41",
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:15:38-2:18:41",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
},
"key_path": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:18:41",
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:15:38-2:18:41",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
}
]
}
],
"edges": null
},
"references": [
{
"string": {
"range": "TestCompile/patterns/override/1.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
},
"key_path": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:21:22",
"key": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,1:15:16-1:21:22",
"value": [
{
"string": "yellow",
"raw_string": "yellow"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
},
"key_path": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:18:41",
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:15:38-2:18:41",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
},
"key_path": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:18:41",
"key": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:13:36",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:0:23-2:2:25",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:3:26-2:8:31",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:9:32-2:13:36",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,2:15:38-2:18:41",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
}
]
}
],
"edges": null
},
"references": [
{
"string": {
"range": "TestCompile/patterns/override/1.d2,4:0:43-4:1:44",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
},
"key_path": {
"range": "TestCompile/patterns/override/1.d2,4:0:43-4:1:44",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,4:0:43-4:1:44",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/override/1.d2,4:0:43-4:1:44",
"key": {
"range": "TestCompile/patterns/override/1.d2,4:0:43-4:1:44",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/override/1.d2,4:0:43-4:1:44",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
}
]
}
],
"edges": null
}

2003
testdata/d2ir/TestCompile/patterns/override/2.exp.json generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -3466,124 +3466,6 @@
}
}
},
{
"string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:0:0-0:7:7",
"value": [
{
"string": "wrapper",
"raw_string": "wrapper"
}
]
},
"key_path": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:0:0-0:9:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:0:0-0:7:7",
"value": [
{
"string": "wrapper",
"raw_string": "wrapper"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:8:8-0:9:9",
"value": [
{
"string": "*",
"raw_string": "*"
}
],
"pattern": [
"*"
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:0:0-2:1:27",
"key": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:0:0-0:9:9",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:0:0-0:7:7",
"value": [
{
"string": "wrapper",
"raw_string": "wrapper"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:8:8-0:9:9",
"value": [
{
"string": "*",
"raw_string": "*"
}
],
"pattern": [
"*"
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "TestCompile/patterns/single-glob/defaults.d2,0:11:11-2:1:27",
"nodes": [
{
"map_key": {
"range": "TestCompile/patterns/single-glob/defaults.d2,1:1:14-1:12:25",
"key": {
"range": "TestCompile/patterns/single-glob/defaults.d2,1:1:14-1:6:19",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,1:1:14-1:6:19",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,1:8:21-1:12:25",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/single-glob/defaults.d2,9:15:85-9:22:92",

View file

@ -578,6 +578,67 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:12:19",
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:8:15-1:12:19",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
@ -716,6 +777,67 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:12:19",
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:8:15-1:12:19",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
@ -854,6 +976,67 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:12:19",
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:8:15-1:12:19",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
@ -992,6 +1175,67 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:12:19",
"key": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:8:15-1:12:19",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/triple-glob/defaults.d2,1:1:8-1:6:13",

File diff suppressed because it is too large Load diff