motoko icon indicating copy to clipboard operation
motoko copied to clipboard

bug: incorrect unused identifier warning

Open crusso opened this issue 1 year ago • 1 comments

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

crusso avatar Apr 22 '24 09:04 crusso

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

luc-blaeser avatar Jun 05 '24 13:06 luc-blaeser