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

Feat(compiler-base): add error message. #164

Merged
merged 11 commits into from
Aug 29, 2022
Merged

Feat(compiler-base): add error message. #164

merged 11 commits into from
Aug 29, 2022

Conversation

zong-zhe
Copy link
Contributor

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

  • N
  • Y

issue #115

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

compiler_base/error_message.rs

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

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

add ErrorMessage to define the message displayed in diagnostics.
add TemplateLoader to load text template file ("*.ftl").

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

add unit test in compiler_base/tests.rs

6. Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@zong-zhe zong-zhe added documentation Improvements or additions to documentation error-handling Issues or PRs related to kcl error handling feat labels Aug 24, 2022
@zong-zhe zong-zhe added this to the v0.4.3 Release milestone Aug 24, 2022
@zong-zhe zong-zhe self-assigned this Aug 24, 2022
@github-actions
Copy link

github-actions bot commented Aug 24, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@zong-zhe
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

add error message loader based on fluent0.16.0.

issue #115
@coveralls
Copy link
Collaborator

coveralls commented Aug 24, 2022

Pull Request Test Coverage Report for Build 2933389271

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 587 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.4%) to 59.515%

Files with Coverage Reduction New Missed Lines %
kclvm/runtime/src/_kclvm.rs 3 25.0%
kclvm/runtime/src/stdlib/plugin.rs 3 0%
kclvm/runtime/src/_kclvm_addr.rs 7 0%
kclvm/span/src/symbol.rs 10 60.0%
kclvm/parser/src/parser/expr.rs 13 81.58%
kclvm/runtime/src/api/utils.rs 26 18.33%
kclvm/runtime/src/api/kclvm.rs 33 46.88%
kclvm/runtime/src/types/api.rs 40 0%
kclvm/runtime/src/value/val_plan.rs 50 0%
kclvm/compiler/src/codegen/llvm/node.rs 60 89.62%
Totals Coverage Status
Change from base Build 2908762349: -0.4%
Covered Lines: 21948
Relevant Lines: 36878

💛 - Coveralls

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.

Three important things:

  1. It is recommended to use anyhow::Result as a function return instead of .unwrap_or_else(|| bug!("error message")) Because it's not actually an internal compiler error but a user error.
  2. Whether it is a high-level or medium-level API, try to keep the interface as simple as possible, such as importing only one file and using one structure.
  3. Try the once_cell crate to init TempateMessageLoader.

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

Copy link
Contributor

@ldxdl ldxdl left a comment

Choose a reason for hiding this comment

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

LGM

@zong-zhe zong-zhe merged commit 194c9fc into kcl-lang:main Aug 29, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation error-handling Issues or PRs related to kcl error handling feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants