ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

Unhelpful error message for variable capture in match expressions

Open Theodus opened this issue 8 years ago • 2 comments

When a let or var is omitted from a variable capture in a match expression, as shown by this code:

actor Main
  new create(env: Env) =>
    let a: (I64 | None) = 7

    env.out.print(match a
      | n: I64 => n.string()
      else ""
    end)

the compiler gives this error:

Error:
/home/theodus/dev/wat/main.pony:6:19: syntax error: unterminated match expression
    env.out.print(match a
                  ^
    Info:
    /home/theodus/dev/wat/main.pony:7:10: expected terminating end before here
          | n: I64 => n.string()
             ^

It should probably be changed to something like "variable capture requires let or var declaration".

Theodus avatar Dec 21 '16 18:12 Theodus