Skip to content

Commit

Permalink
Add libponyc-run regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
mfelsche committed Feb 8, 2022
1 parent b5ca6b7 commit 0b584fc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/promises/promise.pony
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ actor Promise[A: Any #share]
let p: Promise[B] = outer

fun ref apply(value: A) =>
let fulfill' = f = _PendingFulFill[A, B]
let fulfill' = f = _PromiseFulFill[A, B]

try
let inner = (consume fulfill').apply(value)?
Expand Down Expand Up @@ -421,9 +421,9 @@ actor _Join[A: Any #share]
primitive _None


class iso _PendingFulFill[A: Any #share, B: Any #share] is Fulfill[A, Promise[B]]
class iso _PromiseFulFill[A: Any #share, B: Any #share] is Fulfill[A, Promise[B]]
"""
Fulfill returning a promise that is never fulfilled.
Fulfill discarding its input value of `A` and returning a promise of type `B`.
"""
new iso create() => None
fun ref apply(value: A): Promise[B] => Promise[B]
fun ref apply(value: A): Promise[B] => Promise[B]
24 changes: 24 additions & 0 deletions test/libponyc-run/promise-flatten-next-regression-3856/main.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use "promises"

actor FlattenNextProbe
new create(handler: Handler iso) =>
let promise = Promise[String]
// We need a call to next to be present with a call to flatten_next to trigger the issue during reachability analysis
promise.next[Any tag](recover this~behaviour() end)
(consume handler)(recover String end, promise)

be behaviour(value: String) =>
None


class Handler
fun ref apply(line: String, prompt: Promise[String]) =>
let p = Promise[String]
// BUG: Can't change the flatten_next
p.flatten_next[String]({ (x: String) => Promise[String] })


actor Main
new create(env: Env) =>
// BUG: Can't change this
let term = FlattenNextProbe(Handler)

0 comments on commit 0b584fc

Please sign in to comment.