effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Implement first draft of or-patterns

Open b-studios opened this issue 5 months ago • 1 comments

This is a first attempt to implement or patterns (such as requested by #805).

It also supports nested or patterns, but exhaustivity is not yet implemented.

b-studios avatar Jul 14 '25 10:07 b-studios

Please note that this generates code (after inlining) such as

      if (infixEq_85("c", "a")) {
        let tmp_1303570 = println_1("hello")
        l_1303481(tmp_1303570)
      } else {
        if (infixEq_85("c", "b")) {
          let tmp_1303572 = println_1("hello")
          l_1303481(tmp_1303572)
        } else {
          let tmp_1303573 = println_1("world")
          l_1303481(tmp_1303573)
        }
      }

while the following would be better (for sharing code)

      if (infixEq_85("c", "a") || infixEq_85("c", "b")) {
        let tmp_1303570 = println_1("hello")
        l_1303481(tmp_1303570)
      } else {
        let tmp_1303573 = println_1("world")
        l_1303481(tmp_1303573)
      }

b-studios avatar Jul 14 '25 10:07 b-studios