forked from Mirror/wren
If the function the fiber is created from takes a parameter, the value passed to the first call() or transfer() gets bound to that parameter. Also, this now correctly handles fibers with functions that take parameters. It used to leave the stack in a busted state. Now, it's a runtime error to create a fiber with a function that takes any more than one parameter.
25 lines
467 B
Plaintext
25 lines
467 B
Plaintext
var a = Fiber.new {|param|
|
|
System.print("a %(param)")
|
|
}
|
|
|
|
var b = Fiber.new {|param|
|
|
System.print("b before %(param)")
|
|
a.transfer()
|
|
System.print("b after")
|
|
}
|
|
|
|
var c = Fiber.new {|param|
|
|
System.print("c before %(param)")
|
|
b.transfer()
|
|
System.print("c after")
|
|
}
|
|
|
|
System.print("start") // expect: start
|
|
|
|
c.transfer()
|
|
// expect: c before null
|
|
// expect: b before null
|
|
// expect: a null
|
|
|
|
// Nothing else gets run since the interpreter stops after a completes.
|