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

[Bugfix] Mixin use pkg.identfier merge error #28

Closed
Peefy opened this issue Aug 17, 2022 · 8 comments · Fixed by kcl-lang/kcl#159
Closed

[Bugfix] Mixin use pkg.identfier merge error #28

Peefy opened this issue Aug 17, 2022 · 8 comments · Fixed by kcl-lang/kcl#159
Assignees
Labels
bug Something isn't working

Comments

@Peefy
Copy link
Contributor

Peefy commented Aug 17, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  • test.k
import pkg

mixin XMixin:
    server: pkg.Server {}

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

Compile successed.

3. What did you see instead (Required)

KCL Compile Error[E2L23] : A complie error occurs during compiling
---> File test.k:4:5
4 |    server: pkg.Server {}
     5 ^  -> Failure
'pkg' refers to a value, but is being used as a type here

I use the code below to walk around and need KCLVM to fix this:

import pkg

mixin XMixin:
    if True:
        server: pkg.Server {}

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

kclvm version is 0.4.2

@Peefy
Copy link
Contributor Author

Peefy commented Aug 17, 2022

If server is deined in schema, we can write code as follows:

server: pkg.Server = pkg.Server {}

@Peefy
Copy link
Contributor Author

Peefy commented Aug 17, 2022

fixed in kcl-lang/kcl#159

@Peefy Peefy changed the title [Bugfix] Mixin use pkg.identier merge error [Bugfix] Mixin use pkg.identfier merge error Aug 17, 2022
@Peefy Peefy self-assigned this Aug 17, 2022
@LeoLiuYan
Copy link
Contributor

LeoLiuYan commented Aug 17, 2022

If server is deined in schema, we can write code as follows:

server: pkg.Server = pkg.Server {}

If code in pkg.Server as

schema NewServer:
    server:  frontend.Server {
        workloadType = "deployment"
    }

and, we write code in XMixin as

mixin XMixin:
    if True:
        server:  frontend.Server {
           image = "xxxx"
           mainContainer = {}
       }

then, we execute kusion compile, it reports

attribute 'image' of Server is required and can't be None or Undefined

When we execute kusion compile, the values in schema and mixin not merged?

@Peefy

@Peefy
Copy link
Contributor Author

Peefy commented Aug 17, 2022

If server is deined in schema, we can write code as follows:

server: pkg.Server = pkg.Server {}

If code in pkg.Server as

schema NewServer:
    server:  frontend.Server {
        workloadType = "deployment"
    }

and, we write code in XMixin as

mixin XMixin:
    if True:
        server:  frontend.Server {
           image = "xxxx"
           mainContainer = {}
       }

then, we execute kusion compile, it reports

attribute 'image' of Server is required and can't be None or Undefined

When we execute kusion compile, the values in schema and mixin not merged?

@Peefy

@LeoLiuYan Here, the Server instance will first be created in NewServer, where the check fails. U can write:

If code in pkg.Server as

schema NewServer:
    mixin [XMixin]
    server:  frontend.Server = frontend.Server {
        image = "default_image"
        workloadType = "deployment"
    }

and, we write code in XMixin as

mixin XMixin:
    if True:
        server:  frontend.Server {
           image = "xxxx"
           mainContainer = {}
       }

@Peefy Peefy added the bug Something isn't working label Aug 17, 2022
@LeoLiuYan
Copy link
Contributor

It works, but is redundant.
Is it possible to join first before the check, when a shema includes mixin?

@Peefy

@Peefy
Copy link
Contributor Author

Peefy commented Aug 17, 2022

It works, but is redundant. Is it possible to join first before the check, when a shema includes mixin?

@Peefy

@LeoLiuYan Sure, we will design and optimize this feature with corresponding language proposals in the future.

@LeoLiuYan
Copy link
Contributor

LeoLiuYan commented Aug 17, 2022

It works, but is redundant. Is it possible to join first before the check, when a shema includes mixin?
@Peefy

@LeoLiuYan Sure, we will design and optimize this feature with corresponding language proposals in the future.

Cool~ Expect to use this "sugar" feature!

@Peefy
Copy link
Contributor Author

Peefy commented Sep 2, 2022

Related KCLVM Issue: kcl-lang/kcl#92 @LeoLiuYan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants