Make root() destroy scope if error occurs

This commit is contained in:
aaron 2024-10-06 18:14:53 +01:00
parent c4e1396684
commit 93a2a2c631
2 changed files with 2 additions and 1 deletions

View file

@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed ### Fixed
- Error stack traces being lost. - Error stack traces being lost.
- `root()` now destroys the scope automatically if an error occurs during call.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View file

@ -29,7 +29,7 @@ local function root<T...>(fn: (destroy: () -> ()) -> T...): (() -> (), T...)
pop_scope() pop_scope()
if not result[1] then if not result[1] then
refs[node] = nil destroy()
throw(`error while running root():\n\n{result[2]}`) throw(`error while running root():\n\n{result[2]}`)
end end