Skip to content

Commit

Permalink
Add regression test for issue 2408.
Browse files Browse the repository at this point in the history
Fixes #2408.
  • Loading branch information
mfelsche committed Mar 5, 2022
1 parent c033449 commit 6ce4fd0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/libponyc-run/regression-2408/main.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
interface SafeOps[T]
fun addc(t: T): (T, Bool)
fun subc(t: T): (T, Bool)

class GenericSum[T: (Int & Integer[T] val & SafeOps[T])]
fun _plus_safe(x: T, y: T): (T, Bool) =>
x.addc(y)

fun sum(x: T, y: T): T ? =>
match _plus_safe(x, y)
// In the issue 2408 ponyc < 0.26 was reporting this pattern to never match
| (let res: T, false) => res
| (_, true) => error
else
// this else is only needed because ponyc does not recognize
// the match above as exhaustive
error
end

actor Main
new create(env: Env) =>
try
GenericSum[U8].sum(1, 2)?
end

0 comments on commit 6ce4fd0

Please sign in to comment.