You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I'd like to express my gratitude to the KCL development team for creating such a powerful and innovative language. KCL has greatly improved our configuration management processes, and we appreciate your continuous efforts to enhance the language.
Bug Report
1. Minimal reproduce step (Required)
Create a new KCL file with the following content:
schemaContainer:
item: ItemschemaItem:
name: strschemaEntry:
title: strschemaItemLike:
name: strentry_to_item=lambdainputs: Entry -> Item{Item{name=inputs.title}}item_like_to_item=lambdainputs: ItemLike -> Item{Item{name=inputs.name}}# This compiles successfullyContainer{item={name="foo"}}# This also compiles successfullyContainer{item=Item{name="foo"}}# This causes a Compile ErrorContainer{item=entry_to_item({title="foo"})}# This compiles successfullyContainer{item=entry_to_item(Entry{title="foo"})}# This compiles successfullyContainer{item=item_like_to_item({name="foo"})}
I expected all of the Container instantiations to compile successfully, especially the one using entry_to_item({title = "foo"}). Since entry_to_item is defined as a lambda that takes an Entry and returns an Item, and Container.item is of type Item, this should be a valid assignment.
3. What did you see instead (Required)
The compilation fails with an error message for the line:
Container{item=entry_to_item({title="foo"})}
The error message states:
Cannotaddmember'title'toschema'Item'
This error is unexpected because:
The lambda entry_to_item is correctly typed to accept an Entry and return an Item.
The inline object {title = "foo"} matches the structure of Entry.
Similar constructions with item_like_to_item work correctly.
4. What is your KCL components version? (Required)
KCL version: 0.9.5
Additional Notes:
This behavior suggests an inconsistency in type inference or structural typing implementation.
The error can be avoided by explicitly typing the argument: entry_to_item(Entry {title = "foo"}), but this shouldn't be necessary given the lambda's type signature.
This inconsistency makes the language behavior less predictable and may lead to confusion for users.
The issue can be reproduced in the KCL Playground, which makes it easier for the development team to investigate.
The text was updated successfully, but these errors were encountered:
First of all, I'd like to express my gratitude to the KCL development team for creating such a powerful and innovative language. KCL has greatly improved our configuration management processes, and we appreciate your continuous efforts to enhance the language.
Bug Report
1. Minimal reproduce step (Required)
Alternatively, you can reproduce this issue using the KCL Playground:
http://101.42.3.224/-/play/index.html?id=efe9b08292ef976de5ffda37dbbc800d7ac11b8b
2. What did you expect to see? (Required)
I expected all of the Container instantiations to compile successfully, especially the one using
entry_to_item({title = "foo"})
. Sinceentry_to_item
is defined as a lambda that takes anEntry
and returns anItem
, andContainer.item
is of typeItem
, this should be a valid assignment.3. What did you see instead (Required)
The compilation fails with an error message for the line:
The error message states:
This error is unexpected because:
entry_to_item
is correctly typed to accept anEntry
and return anItem
.{title = "foo"}
matches the structure ofEntry
.item_like_to_item
work correctly.4. What is your KCL components version? (Required)
KCL version: 0.9.5
Additional Notes:
entry_to_item(Entry {title = "foo"})
, but this shouldn't be necessary given the lambda's type signature.The text was updated successfully, but these errors were encountered: