Lyricdev
GitHub

LYR-MIG0502

tasks became a scope

hint · spec 14-cli

A note of lyric fix --from-4: the spawns of a block and its run() are a TaskScope, whose close() waits for the tasks as run() did.

Explanation

Lyric 4's run() drove every task to its end. In Lyric 5 a program ends with main, and a task nobody waits for ends with it, so dropping run() would change what the program does. The migration writes a TaskScope: tasks.spawn(() => try worker()) for each spawn, try tasks.close(); for the run().

What differs: the first task that fails cancels the others, and close() throws its error, so the function now throws Error. Where a task should outlive its block, spawnDetached starts one nobody waits for.

Example

proposal[LYR-MIG0502] main.lyr:16:5: the tasks and 'run()' are a 'TaskScope': 'close()' waits for them as 'run()' did, and the first that fails cancels the others — where a task should outlive its block, 'spawnDetached' is one nobody waits for, and the program ends with 'main'