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: incorrect unused identifier warning #4508

Open
crusso opened this issue Apr 22, 2024 · 1 comment
Open

bug: incorrect unused identifier warning #4508

crusso opened this issue Apr 22, 2024 · 1 comment
Assignees

Comments

@crusso
Copy link
Contributor

crusso commented Apr 22, 2024

This code says that e is unused even though it is used.

module {
  public func foo() : async () {
    var x = try {} catch (e) { throw e };
    x;
  };
};

This example seems somewhat minimal. For example without the var x = the error does not occur. With let instead of var it also does not occur.

Also, and perhaps related:

module {
  public func foo() : async () {
    try {} catch (e) { };
  };
};

does not report that e is unused.

https://dfinity.slack.com/archives/CPL67E7MX/p1713629264089809

@luc-blaeser
Copy link
Contributor

Thank you for reporting. The PR #4560 should fix this issue.

mergify bot pushed a commit that referenced this issue Jun 7, 2024
…gs on Type Check Errors) (#4560)

Fix for issue: #4508
* Correctly detect used and unused declaration in switch and try-catch clauses.

Only warn on unused identifiers if type-checking is error-free (#4561)
* Avoid potential spurious cascading warnings in the presence of type checker errors.

Updated:
* Expected warnings in Motoko test cases.
* Refactoring of the Motoko base library to comply with the improved detection: dfinity/motoko-base#636
luc-blaeser added a commit to dfinity/motoko-base that referenced this issue Jun 7, 2024
Refactor base library to avoid warnings of the improved unused
declaration detection, see bug fix
dfinity/motoko#4560 for
dfinity/motoko#4508.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants