Desugar string literals in fcases during IL lowering
#145 (closed)
FixesThis seems to produce the right FlatCurry, but I would appreciate someone more familiar with the Curry to IL translation to check whether this desugaring is sound. The example from the issue, i.e.
wubbel :: String -> ()
wubbel s = fcase s of
"Blah" -> ()
now emits
FcaseStringLiteral.curry:2:12-3:16 Warning:
Pattern matches are non-exhaustive
In an fcase alternative:
Patterns not matched:
[]
(x : _) with x `notElem` ['B']
['B']
('B' : x : _) with x `notElem` ['l']
...
|
2 | wubbel s = fcase s of
| ^^^^^^^^^^...
and compiles to
Prog "FcaseStringLiteral" ["Prelude"] [] [Func ("FcaseStringLiteral","wubbel") 1 Public (FuncType (TCons ("Prelude","[]") [TCons ("Prelude","Char") []]) (TCons ("Prelude","()") [])) (Rule [1] (Case Flex (Var 1) [Branch (Pattern ("Prelude",":") [2,3]) (Case Flex (Var 2) [Branch (LPattern (Charc 'B')) (Case Flex (Var 3) [Branch (Pattern ("Prelude",":") [4,5]) (Case Flex (Var 4) [Branch (LPattern (Charc 'l')) (Case Flex (Var 5) [Branch (Pattern ("Prelude",":") [6,7]) (Case Flex (Var 6) [Branch (LPattern (Charc 'a')) (Case Flex (Var 7) [Branch (Pattern ("Prelude",":") [8,9]) (Case Flex (Var 8) [Branch (LPattern (Charc 'h')) (Case Flex (Var 9) [Branch (Pattern ("Prelude","[]") []) (Comb ConsCall ("Prelude","()") []),Branch (Pattern ("Prelude",":") [10,11]) (Comb FuncCall ("Prelude","failed") [])])]),Branch (Pattern ("Prelude","[]") []) (Comb FuncCall ("Prelude","failed") [])])]),Branch (Pattern ("Prelude","[]") []) (Comb FuncCall ("Prelude","failed") [])])]),Branch (Pattern ("Prelude","[]") []) (Comb FuncCall ("Prelude","failed") [])])]),Branch (Pattern ("Prelude","[]") []) (Comb FuncCall ("Prelude","failed") [])]))] []