diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d5b4e8..fd2f9c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Error stack traces being lost. +- `root()` now destroys the scope automatically if an error occurs during call. -------------------------------------------------------------------------------- diff --git a/src/root.luau b/src/root.luau index 14bfa52..bc5904d 100644 --- a/src/root.luau +++ b/src/root.luau @@ -29,7 +29,7 @@ local function root(fn: (destroy: () -> ()) -> T...): (() -> (), T...) pop_scope() if not result[1] then - refs[node] = nil + destroy() throw(`error while running root():\n\n{result[2]}`) end