Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vars #1473

Merged
merged 40 commits into from
Jul 13, 2023
Merged

Vars #1473

merged 40 commits into from
Jul 13, 2023

Conversation

alixander
Copy link
Collaborator

closes #105

@alixander alixander requested a review from nhooyr July 11, 2023 20:41
Copy link
Contributor

@nhooyr nhooyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't implemented how I wanted it.

You_ can't compile vars before everything else. The var's map is a map just like any other D2 map and itself has to be compiled first. Vars should be resolved at the end and be defined on a per map basis, not a per board. Just like how variable scopes work.

If you define a variable in a for loop, it's only available in the for loop. You don't have to define it at the start of your function in order to make it available in your for loop.

d2compiler/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
@alixander alixander requested a review from nhooyr July 12, 2023 00:20
Copy link
Contributor

@nhooyr nhooyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for

vars: {
  my-var: ${my-var}
}

too

d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
@alixander alixander requested a review from nhooyr July 12, 2023 21:54
d2ir/compile.go Outdated Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Show resolved Hide resolved
@alixander alixander requested a review from nhooyr July 13, 2023 06:02
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2parser/parse.go Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
d2ir/compile.go Show resolved Hide resolved
d2ir/compile.go Show resolved Hide resolved
d2ir/compile.go Outdated Show resolved Hide resolved
@alixander alixander requested a review from nhooyr July 13, 2023 17:23
Copy link
Contributor

@nhooyr nhooyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left two comments

d2compiler/compile.go Outdated Show resolved Hide resolved
@alixander alixander requested a review from nhooyr July 13, 2023 21:27
d2compiler/compile.go Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
@alixander alixander merged commit 4adfb22 into terrastruct:master Jul 13, 2023
@alixander alixander deleted the vars branch July 13, 2023 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

syntax: variables
2 participants