motoko icon indicating copy to clipboard operation
motoko copied to clipboard

BUG: mis-compilation of floating point literal patterns

Open crusso opened this issue 1 year ago • 0 comments

Float point literal patterns are accepted by the type checker but not compiled correctly.

  • executed in the interpreter
  • non implemented in the compiler(s).

We should either rule them out or support them.

Repro:

https://m7sm4-2iaaa-aaaab-qabra-cai.raw.ic0.app/?tag=168118266

actor Echo {

  // Say the given phase.
  public query func check(number : Float) : async { #Zero; #NotZero } {
    switch (number) {
      case (0) #Zero;
      case (_) #NotZero;
    };
  };
};

Call check(0.0) produces Canister called ic0.trap with message: TODO: compile_lit_pat

Slack discussion: https://dfinity.slack.com/archives/CPL67E7MX/p1726572384749519

crusso avatar Sep 17 '24 16:09 crusso