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

fix: replace "__main__" by package name when parse import statments in entry. #660

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kclvm/cmd/src/test_data/instances/test_inst_10/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a:
id: 102
7 changes: 7 additions & 0 deletions kclvm/cmd/src/test_data/instances/test_inst_10/kcl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kcl_cli_configs:
file:
- ./test_inst_101/main.k
- ${test_inst_102:KCL_MOD}/main.k
package_maps:
test_inst_102: ./src/test_data/instances/test_inst_10/test_inst_102

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "test_inst_101"
edition = "0.0.1"
version = "0.0.1"

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import test_inst_102 as k102

a = k102.K102 {
id: 102
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "test_inst_102"
edition = "0.0.1"
version = "0.0.1"

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
schema K102:
id: int

inst102 = K102.instances()
4 changes: 4 additions & 0 deletions kclvm/cmd/src/test_data/instances/test_inst_9/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a:
id: 92
inst92:
- id: 92
7 changes: 7 additions & 0 deletions kclvm/cmd/src/test_data/instances/test_inst_9/kcl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kcl_cli_configs:
file:
- ./test_inst_91/main.k
- ${test_inst_92:KCL_MOD}/main.k
package_maps:
test_inst_92: ./src/test_data/instances/test_inst_9/test_inst_92

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "test_inst_101"
edition = "0.0.1"
version = "0.0.1"

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import test_inst_92.sub as k92

a = k92.K92 {
id: 92
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "test_inst_102"
edition = "0.0.1"
version = "0.0.1"

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import sub as s

inst92 = s.K92.instances()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema K92:
id: int
2 changes: 2 additions & 0 deletions kclvm/cmd/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ fn test_instances_with_yaml() {
"test_inst_6",
"test_inst_7",
"test_inst_8",
"test_inst_9",
"test_inst_10",
];

for case in &test_cases {
Expand Down
2 changes: 1 addition & 1 deletion kclvm/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl Loader {

self.load_import_package(
&entry.path(),
kclvm_ast::MAIN_PKG.to_string(),
entry.name().to_string(),
&mut pkg_files,
&mut pkgs,
)?;
Expand Down
Loading