dfinity / motoko

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

BUG: mis-compilation of floating point literal patterns #4701

Open crusso opened 2 weeks ago

crusso commented 2 weeks ago

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

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