Skip to content

Commit 84a3ca0

Browse files
authored
Merge pull request #1762 from alixander/array-class
d2ir: fix merging boards with array composites
2 parents 00f5eef + 6a4c7a5 commit 84a3ca0

4 files changed

Lines changed: 418 additions & 1 deletion

File tree

ci/release/changelogs/next.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
#### Improvements 🧹
44

55
#### Bugfixes ⛑️
6+
7+
- Fix importing files that override an existing value with an array. [#1762](https://github.com/terrastruct/d2/pull/1762)

d2ir/import_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ label: meow`,
199199
assert.Success(t, err)
200200
},
201201
},
202+
{
203+
name: "merge-arrays",
204+
run: func(t testing.TB) {
205+
_, err := compileFS(t, "index.d2", map[string]string{
206+
"index.d2": `x.class: [a]
207+
...@d
208+
`,
209+
"d.d2": `x.class: [b]`,
210+
})
211+
assert.Success(t, err)
212+
},
213+
},
202214
}
203215

204216
runa(t, tca)

d2ir/merge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func OverlayField(bf, of *Field) {
3030
if bf.Map() != nil && of.Map() != nil {
3131
OverlayMap(bf.Map(), of.Map())
3232
} else {
33-
bf.Composite = of.Composite.Copy(bf).(*Map)
33+
bf.Composite = of.Composite.Copy(bf).(Composite)
3434
}
3535
}
3636

0 commit comments

Comments
 (0)