dfinity / motoko

Simple high-level language for writing Internet Computer canisters
Apache License 2.0
496 stars 98 forks source link

bug: incorrect unused identifier warning #4508

Open crusso opened 3 months ago

crusso commented 3 months ago

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 commented 1 month ago

Thank you for reporting. The PR https://github.com/dfinity/motoko/pull/4560 should fix this issue.