You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if this is expected behaviour or just a missing case for handling variable imports to be in order.
Note that the same applies to connections also.
Hi.
At this point I feel like I am bothering you with daily issues :P
I tried pulling your fix (I tried commits a3fd4ec and 643b670). The a3fd4ec commit fails some e2e tests, but otherwise compiles fine. The 643b670 commit compiles fine.
However, neither of the commits fix the issue I mentioned, with the example I mentioned above.
In addition, I tried a few more examples that are creating issues (not sure if the same code is causing this or not)
main.d2 (v1)
x: {
grid-gap: 0
grid-rows: 2
grid-columns: 2
# elem is required to be a var, else will be the first one to be imported instead of in-order
vars: {
before_1: {
"before_1"
}
before_2: {
"before_2"
}
elem: {
"elem"
}
after_1: {
"after_1"
}
}
...${before_1}
...${before_2}
...${elem}
...${after_1}
}
y
# x.after_1 -> y
Note: The last line, which contains the connetion is commented
main.svg (v1)
main.d2 (v2)
x: {
grid-gap: 0
grid-rows: 2
grid-columns: 2
# elem is required to be a var, else will be the first one to be imported instead of in-order
vars: {
before_1: {
"before_1"
}
before_2: {
"before_2"
}
elem: {
"elem"
}
after_1: {
"after_1"
}
}
...${before_1}
...${before_2}
...${elem}
...${after_1}
}
y
x.after_1 -> y
Note: Connection is uncommented
main.svg (v2)
As you see, the element/connection declared before the variable substitution is always placed first.
Hi,
You were right, I ran install.sh in a hurry, instead of using the ./ci/release/build.sh --install. Fixed that and the 2 examples above work fine.
However, the order is still messed up.
main.d2
x: {
grid-gap: 0
grid-rows: 2
grid-columns: 2
# elem is required to be a var, else will be the first one to be imported instead of in-order
vars: {
before_1: {
"before_1"
}
before_2: {
"before_2"
}
elem: {
"elem"
}
after_1: {
"after_1"
}
}
...${before_1}
...${before_2}
...${elem}
...${after_1}
}
y
x.before_1 -> y
This is the same example as before, but the connection now originates from before_1 instead of after_1
As you can see in the image below, before_1 has now been moved to be the last element imported.
If I comment out the last line (the connection), the order is as it should be.
Activity
alixander commentedon Sep 25, 2024
another good find, thanks again @rutvora . variable substitution is indeed in the wrong order
rutvora commentedon Sep 25, 2024
Hi.
At this point I feel like I am bothering you with daily issues :P
I tried pulling your fix (I tried commits a3fd4ec and 643b670). The a3fd4ec commit fails some e2e tests, but otherwise compiles fine. The 643b670 commit compiles fine.
However, neither of the commits fix the issue I mentioned, with the example I mentioned above.
In addition, I tried a few more examples that are creating issues (not sure if the same code is causing this or not)
main.d2 (v1)
Note: The last line, which contains the connetion is commented
main.svg (v1)

main.d2 (v2)
Note: Connection is uncommented
main.svg (v2)

As you see, the element/connection declared before the variable substitution is always placed first.
alixander commentedon Sep 26, 2024
I've updated the playground to latest D2. Your first example:
https://play.d2lang.com/?script=KkssKrZSqOZSUEhKTcsvSo1PzUnNhQgoKCghiSlxKSjUcikoJKaVpBahqkIIQRTVcnFxVUBk9fT0VKqRTAGZAKJhUgitIG2AAAAA__8%3D&
Your second:
https://play.d2lang.com/?script=ZI7BTsMwEETv-xWjwpFEkGMO_Apy8aas5GTL2qWtqvw7crGLoQcf5vlpdk4jLgTsTHy3c_sRzzWZHuOIocZ3DYd5uRICHsCBZ0iE8edBjD2SYstw-HL2BA6RcZQQMksfjEksJujCxZN5r5bYQ5aY2HnoBFk6Nc9GyCXxZxmw5UmN315qBjYVba5gbbXhXhtaLe9ulBzbbzcltj-3CvmV8uv7_vFSV_wHww3k9lsoRSutRGeiU18Aulec6TsAAP__&
Maybe after you pulled, you didn't reinstall?
I really appreciate all these finds and your clear reports! ❤️
rutvora commentedon Sep 26, 2024
Hi,
You were right, I ran
install.shin a hurry, instead of using the./ci/release/build.sh --install. Fixed that and the 2 examples above work fine.However, the order is still messed up.
main.d2
This is the same example as before, but the connection now originates from
before_1instead ofafter_1As you can see in the image below,
before_1has now been moved to be the last element imported.If I comment out the last line (the connection), the order is as it should be.
alixander commentedon Sep 27, 2024
Darn, indeed. The solution was kind of a best-effort. I'll leave this open for a more robust solution. Thanks