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

[Bug] The loader will return the incorrect number of scopes when there is a schema present #1477

Closed
Peefy opened this issue Jul 6, 2024 · 0 comments · Fixed by #1480
Closed
Assignees
Labels
bug Something isn't working semantic Issues or PRs related to kcl semantic and checker

Comments

@Peefy
Copy link
Contributor

Peefy commented Jul 6, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Write the following unit test in the loader crate

#[macro_export]
macro_rules! load_package_scopes_snapshot {
    ($name:ident, $src:expr) => {
        #[test]
        fn $name() {
            let p = load_packages(&LoadPackageOptions {
                paths: vec!["test.k".to_string()],
                load_opts: Some(LoadProgramOptions {
                    k_code_list: vec![$src.to_string()],
                    ..Default::default()
                }),
                load_builtin: false,
                ..Default::default()
            })
            .unwrap();
            insta::assert_snapshot!(format!("{:#?}", p.scopes.get(&p.pkg_scope_map["__main__"]).unwrap().children));
        }
    };
}

load_package_scopes_snapshot! {schema_scope_0, r#"opt = option
schema Person:
    name: str
    age: int

p = Person {
    name: "Alice"
    age: 18
}
"#}

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

The length of children is 2

3. What did you see instead (Required)

The length of children is 2

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

Version: 0.9.0-c020ab3eb4b9179219d6837a57f5d323
Platform: aarch64-apple-darwin
GitCommit: fdd797ac59b2b0a5259cafdf8850a0f6abbc2fce
@Peefy Peefy added bug Something isn't working semantic Issues or PRs related to kcl semantic and checker labels Jul 6, 2024
@Peefy Peefy added this to the v0.10.0 Release milestone Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semantic Issues or PRs related to kcl semantic and checker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants