From 139c873b1a8c781c6f686ab06d9008e8fa25a517 Mon Sep 17 00:00:00 2001 From: Kaan <81116098+kaan650@users.noreply.github.com> Date: Thu, 22 Oct 2026 14:58:01 +0300 Subject: [PATCH] Fix strict mode losing effect errors that are not strings (#104) Co-authored-by: centau <83140718+centau@users.noreply.github.com> --- src/graph.luau | 7 ++++--- test/tests.luau | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/graph.luau b/src/graph.luau index be76dc1..4cd10ad 100644 --- a/src/graph.luau +++ b/src/graph.luau @@ -21,10 +21,11 @@ export type Node = { local scopes = { n = 0 } :: { [number]: Node, n: number } -- scopes stack -local function efn(err: string) - local trace = debug.traceback(err, 2) +local function efn(err: unknown) + local message = tostring(err) + local trace = debug.traceback(message, 2) - if string.find(err, "^effect error stacktrace") then -- if effect error is nested + if string.find(message, "^effect error stacktrace") then -- if effect error is nested trace = string.gsub(" " .. trace, "\n", function() -- indent entire error return "\n " end) diff --git a/test/tests.luau b/test/tests.luau index 8cda87b..a8bf2e0 100644 --- a/test/tests.luau +++ b/test/tests.luau @@ -3196,6 +3196,15 @@ TEST("strict", wrap_root(function() CHECK(not ok) end + do CASE "error with a non-string value" + local ok, err = pcall(effect, function() + error({}) + end) + + CHECK(not ok) + CHECK(string.find(err, "table: ")) + end + do CASE "duplicate properties" local ok = pcall(function() create "TextLabel" {