Skip to content

Fix promise then chaining and disallow using try/catch in 5.1 in async and generator functions#1150

Merged
Perryvw merged 11 commits intomasterfrom
try-catch-51
Oct 26, 2021
Merged

Fix promise then chaining and disallow using try/catch in 5.1 in async and generator functions#1150
Perryvw merged 11 commits intomasterfrom
try-catch-51

Conversation

@Perryvw
Copy link
Copy Markdown
Member

@Perryvw Perryvw commented Oct 25, 2021

Fixed a problem in Promise.prototype.then lualib implementation where chained promises on already rejected/succeeded promises were not correctly fulfilled/rejected.

Async and generators are implemented using Lua coroutines, which do not play well in combination with pcall which we use to implement try catch. Implementing this becomes incredibly difficult as the proposed solution is to implement pcall as starting a coroutine and then using yield to throw an error. The problem is this interferes with both async and generators, and would require us to increase complexity of our try/catch even more. Therefore I left it out of scope for now, but at least we want to warn in this case.

Closes #1105

@Perryvw Perryvw requested review from lolleko and tomblind October 25, 2021 20:53
@Perryvw Perryvw merged commit 1b9d48f into master Oct 26, 2021
@Perryvw Perryvw deleted the try-catch-51 branch October 26, 2021 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Promise tests down

1 participant