From 93a2a2c6317fb77c2fd288692ac8c5d2c5875bd8 Mon Sep 17 00:00:00 2001 From: aaron <83140718+centau@users.noreply.github.com> Date: Sun, 6 Oct 2024 18:14:53 +0100 Subject: [PATCH] Make `root()` destroy scope if error occurs --- CHANGELOG.md | 1 + src/root.luau | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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