Skip to content

Commit

Permalink
compiler: handle overriden glob value errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Oct 31, 2023
1 parent c270bc8 commit 0bc14d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions d2compiler/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4256,6 +4256,23 @@ x: {
`, `d2/testdata/d2compiler/TestCompile2/globs/double-glob-err-val.d2:4:3: invalid "near" field`)
},
},
{
name: "double-glob-override-err-val",
run: func(t *testing.T) {
assertCompile(t, `
(** -> **)[*]: {
label.near: top-center
}
(** -> **)[*]: {
label.near: invalid
}
x: {
a -> b
}
`, `d2/testdata/d2compiler/TestCompile2/globs/double-glob-override-err-val.d2:6:2: invalid "near" field`)
},
},
}

for _, tc := range tca {
Expand Down
4 changes: 3 additions & 1 deletion d2ir/d2ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ func (f *Field) LastPrimaryRef() Reference {
for i := len(f.References) - 1; i >= 0; i-- {
if f.References[i].Primary() {
if f.References[i].DueToLazyGlob() {
lastGlobSet = f.References[i]
if lastGlobSet == nil {
lastGlobSet = f.References[i]
}
} else {
return f.References[i]
}
Expand Down

0 comments on commit 0bc14d4

Please sign in to comment.