Skip to content

Instantly share code, notes, and snippets.

@pdtwonotes
Created December 25, 2016 17:52
Show Gist options
  • Save pdtwonotes/2886ade22e34f24a242383550f5f0fff to your computer and use it in GitHub Desktop.
Save pdtwonotes/2886ade22e34f24a242383550f5f0fff to your computer and use it in GitHub Desktop.
Match all of a union
```
primitive A
primitive B
primitive C
type ABC is (A | B | C)
actor Main
var x: ABC = A
var n: USize = 0
new create( env: Env ) =>
n = match x
| A => 1
| B => 2
| C => 3
end
```
This gets the following error:
```
Error:
/home/pd/Develop/PonyLang/t/t.pony:10:7: right side must be a subtype of left side
n = match x
^
Info:
/home/pd/Develop/PonyLang/ponyc/packages/builtin/none.pony:1:1: None val is not a subtype of USize val
primitive None is Stringable
^
/home/pd/Develop/PonyLang/ponyc/packages/builtin/none.pony:1:1: not every element of (None val | USize val) is a subtype of USize val
primitive None is Stringable
^
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment