Closed Peefy closed 5 months ago
Since data2 is defined after data1 struct during compilation it isn't finding the data2 struct because it is used before the declaration.
I tried to recreate the issue I do get the same error but when I tried to rearrange the code like this:
schema Data:
name: str
version?: str
# Global version
version = "v0.1.0"
data2: Data {
name = "1"
version = version
}
data1: Data {
name = data2.name
}
it gives the expected output:
version: v0.1.0
data2:
name: '1'
version: v0.1.0
data1:
name: '1'
I am not sure what is expected here? @Peefy
Since data2 is defined after data1 struct during compilation it isn't finding the data2 struct because it is used before the declaration.
I tried to recreate the issue I do get the same error but when I tried to rearrange the code like this:
schema Data: name: str version?: str # Global version version = "v0.1.0" data2: Data { name = "1" version = version } data1: Data { name = data2.name }
it gives the expected output:
version: v0.1.0 data2: name: '1' version: v0.1.0 data1: name: '1'
I am not sure what is expected here? @Peefy
You are right!
Enhancement
For the following KCL code (test.k):
I want to get the expected YAML data:
Instead of the error message: