Skip to content

[Bug] The config entry identifier key is deduced as str type instead of string literal type #336

@Peefy

Description

@Peefy

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Write the following code (main.k) and run:

  • main.k
schema Id:
    id?: int

schema Config:
    data?: {"A"|"B":Id}

c = Config {
    data = {
        A = Id()
        B = Id()
    }
}

Run the cmd:

kclvm_cli run main.k

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

The YAML output

c:
  data:
    A: {}
    B: {}

3. What did you see instead (Required)

KCL Compile Error[E2L23] : A complie error occurs during compiling
---> File main.k:8:4
8 |    data = {
    4 ^  -> Failure
expect {str(A)|str(B):Id}, got {str:Id}

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

kclvm version is 0.4.4; checksum: c5339e572207211e46477825e8aca903

5. Supplement

  • The following code works normally ("A" instead of A and "B" instead of B)
schema Id:
    id?: int

schema Config:
    data?: {"A"|"B":Id}

c = Config {
    data = {
        "A" = Id()
        "B" = Id()
    }
}

Metadata

Metadata

Assignees

Labels

type-systemIssues or PRs related to kcl type system

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions