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: fix incremental compilation unwrap panic in AdvancerResolver #1247

Merged
merged 2 commits into from
Apr 26, 2024
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
28 changes: 19 additions & 9 deletions kclvm/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,22 +344,32 @@ impl Loader {
let workdir = compile_entries.get_root_path().to_string();
let mut pkgs = HashMap::new();
let mut pkg_files = Vec::new();
for entry in compile_entries.iter() {
// Get files from options with root.
// let k_files = self.get_main_files_from_pkg(entry.path(), entry.name())?;
let k_files = entry.get_k_files();
let maybe_k_codes = entry.get_k_codes();
// Load main package.
for (i, filename) in k_files.iter().enumerate() {
let mut m = if let Some(module_cache) = self.module_cache.as_ref() {
// update cache
if let Some(module_cache) = self.module_cache.as_ref() {
for entry in compile_entries.iter() {
let k_files = entry.get_k_files();
let maybe_k_codes = entry.get_k_codes();
// Load main package.
for (i, filename) in k_files.iter().enumerate() {
let m = parse_file_with_session(
self.sess.clone(),
filename,
maybe_k_codes[i].clone(),
)?;
let mut module_cache_ref = module_cache.write().unwrap();
module_cache_ref.insert(filename.clone(), m.clone());
m
}
}
}

for entry in compile_entries.iter() {
let k_files = entry.get_k_files();
let maybe_k_codes = entry.get_k_codes();
// Load main package.
for (i, filename) in k_files.iter().enumerate() {
let mut m = if let Some(module_cache) = self.module_cache.as_ref() {
let module_cache_ref = module_cache.read().unwrap();
module_cache_ref.get(filename).unwrap().clone()
} else {
parse_file_with_session(self.sess.clone(), filename, maybe_k_codes[i].clone())?
};
Expand Down
7 changes: 3 additions & 4 deletions kclvm/sema/src/resolver/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,12 @@ impl DependencyGraph {
if let Some(pkgpaths) = self.module_map.get(&module_file).cloned() {
let mut pkg_queue = VecDeque::new();
for pkgpath in pkgpaths.iter() {
invalidated_set.insert(pkgpath.clone());
pkg_queue.push_back(self.node_map.get(pkgpath));
}

let mut old_size = 0;
while old_size < invalidated_set.len() {
old_size = invalidated_set.len();
let mut old_size: i64 = -1;
while old_size < invalidated_set.len() as i64 {
old_size = invalidated_set.len() as i64;
let cur_node = loop {
match pkg_queue.pop_front() {
Some(cur_node) => match cur_node {
Expand Down
Loading