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

bug: lambda expression return value type error #1674

Closed
zong-zhe opened this issue Oct 8, 2024 · 0 comments · Fixed by #1679
Closed

bug: lambda expression return value type error #1674

zong-zhe opened this issue Oct 8, 2024 · 0 comments · Fixed by #1679
Assignees
Labels
bug Something isn't working resolver

Comments

@zong-zhe
Copy link
Contributor

zong-zhe commented Oct 8, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

The main.k, compile it by kcl run main.k

schema Cluster:
    name: str
    extra: int

a: Cluster = { name = "abc", extra = 6 }

enrich = lambda value {
    [a]
}

result_typesafe: [Cluster] = enrich({name = "abc", extra = 6 })

2. What did you expect to see? (Required)

The result

a:
  name: abc
  extra: 6
result_typesafe:
- name: abc
  extra: 6

3. What did you see instead (Required)

The type error

error[E2G22]: TypeError
  --> /main.k:16:38
   |
16 | result_typesafe: [Cluster] = enrich({name = "abc", extra = 6 })
   |                                      ^ expected Cluster, got str(abc)
   |

  --> /main.k:16:1
   |
16 | result_typesafe: [Cluster] = enrich({name = "abc", extra = 6 })
   | ^ variable is defined here, its type is Cluster, but got str(abc)
   |


error[E2G22]: TypeError
  --> /main.k:16:52
   |
16 | result_typesafe: [Cluster] = enrich({name = "abc", extra = 6 })
   |                                                    ^ expected Cluster, got int(6)
   |

  --> /main.k:16:1
   |
16 | result_typesafe: [Cluster] = enrich({name = "abc", extra = 6 })
   | ^ variable is defined here, its type is Cluster, but got int(6)
   |

4. What is your KCL components version? (Required)

kcl v0.10.0

@zong-zhe zong-zhe self-assigned this Oct 8, 2024
@zong-zhe zong-zhe added the bug Something isn't working label Oct 8, 2024
@zong-zhe zong-zhe added this to KCL 2024 Oct 8, 2024
@zong-zhe zong-zhe added this to the v0.11.0 Release milestone Oct 8, 2024
@zong-zhe zong-zhe removed their assignment Oct 8, 2024
@Peefy Peefy self-assigned this Oct 10, 2024
@Peefy Peefy added the resolver label Oct 10, 2024
@github-project-automation github-project-automation bot moved this to Done in KCL 2024 Oct 10, 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 resolver
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants