Skip to content

fix: error when setting @local outside a locals context#131

Merged
rohal12 merged 4 commits into
mainfrom
fix/123-locals-outside-scope-error
Mar 26, 2026
Merged

fix: error when setting @local outside a locals context#131
rohal12 merged 4 commits into
mainfrom
fix/123-locals-outside-scope-error

Conversation

@rohal12
Copy link
Copy Markdown
Owner

@rohal12 rohal12 commented Mar 26, 2026

Summary

  • {set @var} at passage top level (outside {for}, widgets, {link}, {button}) now throws a clear error instead of silently discarding the value
  • {set} renders errors visibly via MacroError instead of silently returning null

Closes #123

Test plan

  • New test: shows error when setting @local outside a locals context
  • Verify {set @var} inside {for} loops still works correctly
  • Verify {set $var} and {set _var} at passage top level are unaffected

🤖 Generated with Claude Code

clem and others added 4 commits March 26, 2026 23:36
Spec for #128 — auto-unsubscribe event handlers registered after
storyinit on restart to prevent duplicate accumulation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Callers don't need to import the phase flag; the function is a
no-op when not in runtime phase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The default LocalsUpdateContext updater was a silent no-op, causing
{set @var} at passage top level to silently discard values. Now throws
a clear error telling authors that @Locals require a {for}, widget,
{link}, or {button} scope. Also makes {set} render errors visibly
via MacroError instead of silently returning null.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Release preview: merging this PR will publish v0.40.1 (patch bump from v0.40.0)

@rohal12 rohal12 enabled auto-merge March 26, 2026 15:55
@github-actions
Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.79% 2758 / 3545
🔵 Statements 76.88% 3020 / 3928
🔵 Functions 68.92% 508 / 737
🔵 Branches 73.99% 1508 / 2038
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/components/macros/Set.tsx 100% 100% 100% 100%
src/markup/render.tsx 89.47% 80% 100% 92% 77, 87, 125, 190-196, 211-212, 223, 244, 245, 249-250
Generated in workflow #201 for commit c9dbd98 by the Vitest Coverage Report Action

@rohal12 rohal12 merged commit af925c3 into main Mar 26, 2026
5 checks passed
@rohal12 rohal12 deleted the fix/123-locals-outside-scope-error branch March 26, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{set @var} silently fails at passage top level — locals context is no-op outside {for}/widgets

1 participant