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

Conversation

He1pa
Copy link
Contributor

@He1pa He1pa commented Apr 25, 2024

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

2. What is the scope of this PR (e.g. component or file name):

kclvm/parser/src/lib
kclvm/sema/src/resolver/scope

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  1. resolver cache clear impl bug. Insert pkgpath in to invalidated_set while cause line 616 always be true and the rest of this function will never be executed. It will pop_front and continue until the queue is empty.
if invalidated_set.contains(&cur_node.pkgpath) {
       continue;
}
  1. fix: fix parse cache. First update all AST information. When constructing pkg recursively, it will try to get AST information from the cache(line 382 self.load_import_package()). In the previous implementation, the old version of AST was obtained in recursion, and then the new version of AST was added to the main package, resulting in inconsistent AST versions of the same file in the main package and other pkgs.
  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

…n cache to not be cleared correctly, causing an error in the AdvancerResolver.

Signed-off-by: he1pa <18012015693@163.com>
…ting pkg recursively, it will try to get AST information from the cache. In the previous implementation, the old version of AST was obtained in recursion, and then the new version of AST was added to the main package, resulting in inconsistent AST versions of the same file in the main package and other pkgs.

Signed-off-by: he1pa <18012015693@163.com>
@He1pa He1pa added parser Issues or PRs related to kcl parser debug Issues or PRs related to kcl debug enhancement resolver labels Apr 26, 2024
@He1pa He1pa marked this pull request as ready for review April 26, 2024 02:55
kclvm/parser/src/lib.rs Outdated Show resolved Hide resolved
kclvm/parser/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coveralls
Copy link
Collaborator

coveralls commented Apr 26, 2024

Pull Request Test Coverage Report for Build 8843858341

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 16 of 16 (100.0%) changed or added relevant lines in 2 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.006%) to 71.454%

Files with Coverage Reduction New Missed Lines %
kclvm/sema/src/resolver/scope.rs 1 72.81%
kclvm/tools/src/LSP/src/state.rs 1 86.15%
Totals Coverage Status
Change from base Build 8843448896: 0.006%
Covered Lines: 52738
Relevant Lines: 73807

💛 - Coveralls

@Peefy Peefy merged commit 8b29815 into kcl-lang:main Apr 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug Issues or PRs related to kcl debug enhancement parser Issues or PRs related to kcl parser resolver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants