kcl-lang / kcl

KCL Programming Language (CNCF Sandbox Project). https://kcl-lang.io
https://kcl-lang.io
Apache License 2.0
1.7k stars 119 forks source link

lazy eval not respected with manifests.yaml_stream #1176

Closed steeling closed 7 months ago

steeling commented 7 months ago

Following this example https://github.com/kcl-lang/examples/tree/main/abstraction

The following setup doesn't work:

file1.k:

schema MySchema:
   field1: any

obj = MySchema {
   field1 = obj2
}

obj2 = {
   x = 10
}

file2.k:

import manifests

manifests.yaml_stream([o.field1 for o in MySchema.instances()])

kcl file1.k file2.k renders error:

  |
6 | obj = MySchema {
  |  attribute 'field1' of MySchema is required and can't be None or Undefined

However this works: file3:

schema MySchema:
   field1: any

obj2 = {
   x = 10
}

obj = MySchema {
   field1 = obj2
}

Only difference above is placement of obj2.

Peefy commented 7 months ago

Thank you for your feedback ❤️. We are working hard to support it. It has been basically completed and is currently being tested.

The related PRs and Issues:

PR:

Issues: