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

No linting errors when defining data as array of schema #63

Closed
kubernegit opened this issue Dec 19, 2024 · 5 comments
Closed

No linting errors when defining data as array of schema #63

kubernegit opened this issue Dec 19, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@kubernegit
Copy link

I wanted to define some data as an array of a given schema like this:

schema Container:
    a: "b"

data = [Container][{x: "b"}]

In kcl I get the following error message:

4 | data = [Container][{a: "b"}]
  |                    ^ expected int, got {str(a):str(b)}

I assume that what I tried to do is not supported in kcl. This bug report is about the vscode extension plugin not indicating any linting errors. Everything looks fine until I try to compile it.

kcl version: 0.10.10
kcl vscode plugin version: v0.2.2

If someone knows if there is a way how to get the above running, I would be glad to know. :)

@Peefy Peefy added the bug Something isn't working label Dec 19, 2024
@He1pa
Copy link
Contributor

He1pa commented Dec 20, 2024

Here, {a: "b"} be seem as index of arrary [Container], so expected int here.

I guess you want

schema Container:
    a: "b"

data : [Container] = [{x: "b"}]
# or
data : [Container] = [Container{x: "b"}]
# or
data = [Container{x: "b"}]

@He1pa
Copy link
Contributor

He1pa commented Dec 20, 2024

I also get lint error from ide.
image

Can you provide more info. Like the program struct. Sometims kcl.mod will affect IDE. And we log some info here
image
Could you provide the log again?

@kubernegit
Copy link
Author

kubernegit commented Dec 20, 2024

To reproduce the issue I moved the snippet to a dedicated folder.

#main.k 
schema Container:
    a: "b"

data = [Container][{x: "b"}]

The issue is there even with no kcl.mod file. When running kcl mod init it creates the following file, but the issue persists.

[package]
name = "deleteme"
edition = "v0.10.0"
version = "0.0.1"

Logs from the vscode language server:

[Info  - 12:11:32 PM] on did open file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:50 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:50 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:51 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:52 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:52 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:53 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:53 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:54 PM] on did_change file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")
[Info  - 12:13:54 PM] on did save file: AbsPathBuf("/home/[private-username]/repositories/deleteme/main.k")

I forgot to mention the following:
Arch: x64
OS: Ubuntu 24.04.1 LTS
vscode version: 1.96.2

@He1pa
Copy link
Contributor

He1pa commented Dec 23, 2024

which version is your kcl lsp? you can get it by kcl-language-server --version

@kubernegit
Copy link
Author

Thank you, your hint solved the issue. When I updated kcl I forgot to update the lsp. With kcl-language-server --version I got

Error: kcl-language-server 0.9.0-beta.1

Then, using the instructions I updated the language server. It now prints

kcl-language-server Version: 0.11.0-c020ab3eb4b9179219d6837a57f5d323
Platform: x86_64-unknown-linux-gnu
GitCommit: bc74f86d4af33d0e3591c7dcda748535ab436469

It works as expected.

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

No branches or pull requests

3 participants