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

[Enhancement] Top level config unification backward reference. #247

Closed
Peefy opened this issue Oct 18, 2022 · 2 comments · Fixed by #1104 or #1213
Closed

[Enhancement] Top level config unification backward reference. #247

Peefy opened this issue Oct 18, 2022 · 2 comments · Fixed by #1104 or #1213
Assignees
Labels
codegen feat resolver runtime Issues or PRs related to kcl runtime including value and value opertions

Comments

@Peefy
Copy link
Contributor

Peefy commented Oct 18, 2022

Enhancement

For the following KCL code (test.k):

schema Data:
    name: str
    version?: str

data1: Data {
    name = data2.name
}

data2: Data {
    name = "1"
    version = version
}

# Global version
version = "v0.1.0"

I want to get the expected YAML data:

data1:
  name: '1'
data2:
  name: '1'
  version: v0.1.0
version: v0.1.0

Instead of the error message:

KCL Compile Error[E2L23] : A complie error occurs during compiling
---> File test.k:5:12
5 |    name = data2.name
           12 ^  -> Failure
name 'data2' is not defined
@Peefy Peefy added the resolver label Oct 18, 2022
@Peefy Peefy added this to the v0.4.4 Release milestone Oct 18, 2022
@Peefy Peefy modified the milestones: v0.4.4 Release, v0.4.5 Release Dec 4, 2022
@Peefy Peefy added help wanted Extra attention is needed long-term labels Feb 10, 2023
@Peefy Peefy modified the milestones: v0.4.5 Release, v0.4.6 Release Feb 10, 2023
@Peefy Peefy modified the milestones: v0.4.6 Release, v0.5.0 Release Apr 10, 2023
@Peefy Peefy removed this from the v0.5.0 Release milestone Jul 6, 2023
@Peefy Peefy added this to the v0.8.0 Release milestone Dec 26, 2023
@Peefy Peefy added codegen and removed long-term help wanted Extra attention is needed labels Dec 26, 2023
@Peefy Peefy added the feat label Jan 28, 2024
@octonawish-akcodes
Copy link
Contributor

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

@Peefy
Copy link
Contributor Author

Peefy commented Feb 1, 2024

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!

@Peefy Peefy assigned Peefy and unassigned zong-zhe Feb 29, 2024
@Peefy Peefy added the runtime Issues or PRs related to kcl runtime including value and value opertions label Feb 29, 2024
@Peefy Peefy modified the milestones: v0.8.0 Release, v0.9.0 Release Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen feat resolver runtime Issues or PRs related to kcl runtime including value and value opertions
Projects
None yet
3 participants