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

StringLitExpression error for top level keys with dashes #1787

Open
nkabir opened this issue Dec 12, 2024 · 2 comments
Open

StringLitExpression error for top level keys with dashes #1787

nkabir opened this issue Dec 12, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request lang-design Issues or PRs related to kcl language design and KEPs

Comments

@nkabir
Copy link

nkabir commented Dec 12, 2024

kcl version 0.11.0-alpha.1

file: demo1.k

"my-color" = "red"

kcl demo1.k generates 'StringLitExpression' is an illegal expression for assignment

file: demo2.k

{
"my-color" = "red"
}

kcl demo2.k generates

my-color: red
@Peefy Peefy added enhancement New feature or request lang-design Issues or PRs related to kcl language design and KEPs labels Dec 12, 2024
@Peefy Peefy added this to the v0.11.0 Release milestone Dec 12, 2024
@He1pa
Copy link
Contributor

He1pa commented Dec 16, 2024

Literal strings cannot be used as identifiers, so they cannot be used as targets in assignment statements.

Are you asking how to use dashes in identifiers? This is not supported yet. If you write as my-color = "red", the dash will be confused with the minus sign.

@nkabir
Copy link
Author

nkabir commented Dec 17, 2024

Understood. But this works in the context of dictionaries. This is valid:

{
"my-color" = "red"
}

Are you asking how to use dashes in identifiers? This is not supported yet.

Yes. But it works if I place {} around the entire kcl file so it seems inconsistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lang-design Issues or PRs related to kcl language design and KEPs
Projects
None yet
Development

No branches or pull requests

4 participants