Repository navigation
A function that reaches program() or trigger() is refused where a program calls it - #90
Merged
Merged
Conversation
…gram calls it program() and trigger() written in a program's body were refused, but the same call in one of the script's own functions, called from a program, built with no error. Nothing in such a call is the game's, so it was worked out when the script was built: the trigger existed from the start of the game, whether or not the program ever reached the call. A victory trigger behind a wait and a condition fired on the first frame. The plan now follows the script's functions: a call that reaches trigger(), program(), hyperTriggers() or game(), directly or through other functions of the script, is never hoisted and is an error at the call, with the way there named. It covers a function called by name, an arrow kept in a const, one handed to forEach, a method, a function from another file and one through a namespace import, inside a program, a listener or a game() function. The same function called at the top of a file is the script's, as before. Fixes #89 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VEdp4VusnFfHbBoyhRPUTt
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #89.
What was wrong
program()andtrigger()written in a program's body were refused. The same call in one of the script's own functions, called from a program, built with no diagnostics. Nothing in such a call is the game's, so the planner hoisted it: it ran when the script was built, and the trigger existed from the start of the game whether or not the program ever reached the call.On main this builds clean and the map has an Always → Victory trigger that fires on the first frame.
What changes
The plan follows the script's functions. A call that reaches
trigger(),program(),hyperTriggers()orgame(), directly or through other functions of the script, is never hoisted, and is one error at the call:What I checked on main before the change, and what each does now:
setup(), a function or an arrow in aconstsetup()through a second functionsetup()imported, ormore.setup()through a namespace importsetup()inside a listener, at the top of a file or in a programsetup()inside agame()function[1, 2].forEach(setup),const n = setup()hyperTriggers()in a functiongame()in a functionThe prototype in the issue followed callees written as plain names. This one also resolves the call's signature, so methods and namespace imports are covered, and a standard-library function is treated as the script's own are.
A forbidden call anywhere in a function's body counts, including in a function written inside it, as it does in a program's own body.
For #88
With this on top of #88's head,
buildAutoMiningProgram()insideprogram()or a listener gives one error at the caller's line inmain.tsinstead of errors located inworkers.ts, and #88's standard-library tests pass unchanged.Testing
npm run typecheckclean;npx vitest run: 83 files pass.tests/script-structured.test.ts: every row of the table above, and that a top-level call and two functions that call each other (reaching neither) still build.🤖 Generated with Claude Code
https://claude.ai/code/session_01VEdp4VusnFfHbBoyhRPUTt