soma.cell

E1004: match_fat_arrow

E1004 match_fat_arrow — => in a match arm — arms use ->.

A compile-time error of soma check, the checker of the Soma programming language (soma explain E1004).

The rule

In Soma, match arms are written pattern -> value; => is reserved for lambdas (x => x * 2). The parser reports one E1004 for each arm that uses =>. Replace => with -> in every arm.

A program that triggers it

wrong.cell

cell Shipping {
    on rate(zone: String) {
        return match zone {
            "domestic" => 500
            "europe" => 1200
            _ => 2500
        }
    }
}

What soma check prints:

$ soma check wrong.cell
error: match arms use '->', not '=>'
  --> wrong.cell:4:24
  |
4 |             "domestic" => 500
  |                        ^
  = code: E1004
error: match arms use '->', not '=>'
  --> wrong.cell:5:22
  |
5 |             "europe" => 1200
  |                      ^
  = code: E1004
error: match arms use '->', not '=>'
  --> wrong.cell:6:15
  |
6 |             _ => 2500
  |               ^
  = code: E1004
✗ 3 error(s), 0 warning(s).

The fix field of soma check --json: match arms use '->', not '=>'

Lines 4–6 are rewritten.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -2,7 +2,7 @@
     on rate(zone: String) {
         return match zone {
-            "domestic" => 500
-            "europe" => 1200
-            _ => 2500
+            "domestic" -> 500
+            "europe" -> 1200
+            _ -> 2500
         }
     }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.