d2 icon indicating copy to clipboard operation
d2 copied to clipboard

vars notation

Open bo-ku-ra opened this issue 1 year ago • 1 comments

why is this not allowed?

no plobrem

vars: {
  d2-config: {
    layout-engine: elk
  }
}

a

error

"vars" must be the last part of the key

vars.d2-config.layout-engine: elk

a

bo-ku-ra avatar Aug 03 '24 21:08 bo-ku-ra

"vars" must be the last part of the key

this message causes more confusion.

foo.vars: {
  bar
}

https://play.d2lang.com/?script=SsvP1ytLLCq2Uqjm5VJQSEos4uWq5eUCBAAA__8%3D&

bo-ku-ra avatar Aug 04 '24 00:08 bo-ku-ra

I have the same issue. Trying to use the Go API oracle to set vars but getting this error.

ash2k avatar May 13 '25 05:05 ash2k

it's not allowed because i don't want to give the impression this is allowed

vars: {
  a: 1
}

x1: ${a}

vars.a: 2

x1: ${a}

these will both be 2. As d2 is a declarative language, variable reassignment is not a feature.

alixander avatar May 15 '25 02:05 alixander