From d09fb5536b8d64b84e12b48bf1d2d14327534807 Mon Sep 17 00:00:00 2001 From: littensy <56808540+littensy@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:07:50 -0700 Subject: [PATCH] fix: set strict flags if `RunService.IsStudio` is true --- README.md | 2 +- packages/charm/src/index.d.ts | 4 ++-- packages/charm/src/init.luau | 12 ++++++------ rokit.toml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 35895ac..c630eae 100644 --- a/README.md +++ b/README.md @@ -602,7 +602,7 @@ Charm exposes the following global flags to customize behavior: | frozen | `true`\* | Enforces data immutability by deep-freezing tables passed to signals, excluding objects with metatables. | | trackInnerEffects | `true` | Whether nested effects should be tracked and cleaned up when the parent effect re-runs. This should only be disabled to debug issues during migration. | -The `strict` and `frozen` flags are automatically enabled in Roblox Studio and other development environments where the Luau optimization level is `O1` or lower. +The `strict` and `frozen` flags are automatically enabled in Roblox Studio. --- diff --git a/packages/charm/src/index.d.ts b/packages/charm/src/index.d.ts index 4e4ad8d..e4689e5 100644 --- a/packages/charm/src/index.d.ts +++ b/packages/charm/src/index.d.ts @@ -50,12 +50,12 @@ export const flags: { /** * Enforces synchronous, non-yielding behavior in signals and effects. * Also enables state validation in Charm Sync to catch sync errors early. - * Enabled if the optimization level is below 2, which is true in studio. + * Enabled by default in Roblox Studio. */ strict: boolean; /** * Enforces immutability of tables by deep-freezing table values. Enabled - * if the optimization level is below 2, which is true in studio. + * by default in Roblox Studio. */ frozen: boolean; /** diff --git a/packages/charm/src/init.luau b/packages/charm/src/init.luau index d47ede5..ff87785 100644 --- a/packages/charm/src/init.luau +++ b/packages/charm/src/init.luau @@ -68,22 +68,22 @@ local batchDepth = 0 -- Dependencies accessed during this time will link to the active subscriber. local activeSub: ReactiveNode? -local function isO2(): boolean - return debug.info(1, "n") ~= "isO2" +local function isStudio(): boolean + return game ~= nil and game:GetService("RunService"):IsStudio() end local flags = { --[[ Enforces synchronous, non-yielding behavior in signals and effects. Also enables state validation in Charm Sync to catch sync errors early. - Enabled if the optimization level is below 2, which is true in studio. + Enabled by default in Roblox Studio. ]] - strict = not isO2(), + strict = isStudio(), --[[ Enforces immutability of tables by deep-freezing table values. Enabled - if the optimization level is below 2, which is true in studio. + by default in Roblox Studio. ]] - frozen = not isO2(), + frozen = isStudio(), --[[ Whether parent effects should track inner effects and clean them up when the parent effect re-runs. This is usually desirable, but can be diff --git a/rokit.toml b/rokit.toml index 9348712..c99bf5d 100644 --- a/rokit.toml +++ b/rokit.toml @@ -1,6 +1,6 @@ [tools] wally = "UpliftGames/wally@0.3.2" -rojo = "rojo-rbx/rojo@7.6.1" +rojo = "rojo-rbx/rojo@7.7.0-rc.1" stylua = "johnnymorganz/stylua@2.5.2" luau-lsp = "johnnymorganz/luau-lsp@1.68.1" lute = "luau-lang/lute@1.0.0"