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

(imported) object overrides broken with list comprehension #1229

Closed
steeling opened this issue Apr 18, 2024 · 1 comment · Fixed by #1230
Closed

(imported) object overrides broken with list comprehension #1229

steeling opened this issue Apr 18, 2024 · 1 comment · Fixed by #1230
Labels
bug Something isn't working semantic Issues or PRs related to kcl semantic and checker

Comments

@steeling
Copy link

steeling commented Apr 18, 2024

I think specifically when using list comprehension with an imported object:

in temp/temp.k:

import crypto

schema MySchema:
    id: str = crypto.uuid()
    someField?: int

in test.k:

import temp

schema FinalSchema:
    _values: [temp.MySchema] = [{id: "hello"},{ id: "world" },{}]
    finalValues: [temp.MySchema] = [v{someField: i} for i, v in _values] # <- this list comprehension fails

f = FinalSchema{}
kcl test.k
Error: failed to compile the kcl package
Internal error, please report a bug to us: KCLError { message: "name '@temp' is not defined", ty: Compile }

However if I move MySchema into test.k it works, or if reference MySchema outside of list comprehension it works.

@steeling steeling changed the title object overrides broken in imports (imported) object overrides broken with list comprehension Apr 18, 2024
@Peefy
Copy link
Contributor

Peefy commented Apr 19, 2024

Hello @steeling , you can use the following code and I will fix it latter.

import temp

schema FinalSchema:
    _values: [temp.MySchema] = [{id: "hello"},{ id: "world" },{}]
    finalValues: [temp.MySchema] = [v | {someField: i} for i, v in _values] # note I've used `v | {someField: i}`

f = FinalSchema {}

@Peefy Peefy added bug Something isn't working codegen evaluator semantic Issues or PRs related to kcl semantic and checker and removed codegen evaluator labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semantic Issues or PRs related to kcl semantic and checker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants