[Bug] Wrong References for the module variable
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
In the konfig repo https://github.com/kcl-lang/konfig/blob/main/models/kube/frontend/job.k
2. What did you expect to see? (Required)
The right reference list
3. What did you see instead (Required)
4. What is your KCL components version? (Required)
v0.10.7
Possibly this one is related too, running v0.10.7:
import .providers # module
resources = {
# v
# module
"providers": providers.installProviders # [Provider]
# v
# [Provider]
"vault-config": providers.vaultConfig # error
}
35 | "vault-config": providers.vaultConfig
| ^ attribute 'vaultConfig' not found in '[Provider]'
Actually resource.providers definition at top of resources uses a locally set providers. From one side it's kinda expected and what it should be, but it used to work before. Please share what the actual future behavior should be?
Also, @Peefy please note that 0.10.7 behaves strange with modules, they appear exposed similarly to variables. However this one is unexpected, since the scope for import ... identifiers should be better file only, but not anymore...
- sub/use_to_config.k (import ..config)
- sub/main.k (import .config)
.
├── config.k
├── kcl.mod
├── kcl.mod.lock
├── main.k
└── sub
├── config.k
├── main.k
└── use_top_config.k
This clashes with
|
1 | import ..config
| ^ the name 'config' is defined multiple times, 'config' must be defined only once
Yes, some recent bug fixes have caused these regression errors. We will fix it later and release it in v0.10.8+ and v0.11.x
Hello, @Peefy I'd like to kindly ask about any plans for this? Also what bothers me a bit, is an unclear migration path from from 0.9.8 to 0.11.x.
- First this issue which messes up variables with imports.
- Second is the ordered file load behavior. Let's say in
b.kclfile hasvar = trueand inmain.kclthere isoutput = varthis works fine on0.9.x. And in 0.11 seemed like the order is broken (or it could be actually I couldn't just say for sure becouse of broken imports), or maybe it tries to behave likecuethe file order doesn't matter.
Please could clarify this, since the scope for issues seems quite broad to me. So what the load behavior for KCL should actually be from now on?
Thank you!
I want to confirm, does the problem you mentioned only occur in the IDE, or does it occur in the IDE and during the compilation process? Regarding the module-related behaves, there are some updates in the IDE. But I don't think this should affect the normal compilation process.
Regarding file dependencies and loading order, for entry files, they are in order, for example, kcl run a.k b.k or entries in kcl.mod, there is an order between a and b. For dependent files, such as import c in a.k. The correct order should be c a b
@He1pa yep, this unfortunately not the language sever issue only. It's compilation issue too.
Thanks, though I referred to load order inside a directory, when you invoke dir/main.k which in turn might implicitly access vars from dir/a.k. Does this behavior persist in the new versions?
this comment describes compilation issue: https://github.com/kcl-lang/kcl/issues/1734#issuecomment-2455751382