Repository navigation
Lua hot reload: removed closures, classes and callbacks apply with a warning - #1556
Merged
Merged
Conversation
…warning A removed function a running version stored as a value, or a class-table slot nothing binds any more, keeps its old body only for what the map made before; the new code cannot reach it. The payload now applies and warns, instead of refusing, as it does for package init it cannot run again. A surviving function which leaves a slot warns when its body changes. Order-group checks and the rejection of a changed stored function are unchanged.
…cklog item for closures inserted among others
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Oct 24, 2026
Merged
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.
Removing a closure, a class or a callback no longer needs a restart: the payload applies and warns what keeps the old body. This changes what a payload refuses, so it is a PR of its own.
Before
A payload refused when something a running map may still hold was no longer bound by any function of the edit:
destroyForGroupCallbacklost the__wurst_destroyslots of theForGroupclosures an edit removed.In Castle Fight's history this was in 7 of the commits still refused, so removing any closure, class or callback meant a restart.
Now
The payload applies, with a warning per function in
payload.warnings(), which the editor shows:function <name> was removed, but what the map made before keeps its old body (<places>): restart the map to drop it.function <name> changed, but what the map made before keeps its old body (<places>): restart the map to drop it.for a surviving function whose body changed and which left a slot.What the map made before (a timer's or listener's closure object, a callback registered with the engine) keeps running the old body until it is gone or the map restarts; the new code cannot reach it. A class table is flat (every inherited method is assigned, no
__indexchain), so a slot no function binds is never dispatched by the new program. This is how the payload already treats what it cannot apply, such as a changed package init: a warning to restart, not a refusal.The editor (the language server's hot reload) shows a payload's warnings as one note (
LuaHotReloadSession.warningNote,payloadWarningsAreOneNote): removing a class warns once for each of its methods, which were as many notifications.Unchanged: every check about closures told apart by their order (moves, removals within an order group), and the refusal of a changed function which a running version stores as a value, since the new code still reaches that value. A surviving function whose body is unchanged warns of nothing: the slots it left still hold that very body (it was refused before).
Evidence
Replaying Castle Fight's last 30 commits which change Wurst code: 23 accepted, up from 21 on master with #1555; the two commits refused only for removed closures (and the slots the removed classes left) now apply with the warning. Of the 7 still refused, 6 insert a closure before others told apart by their order and 1 changes a global's type. The docs' "Edits of a real project" now has the replay with each of today's changes, and BACKLOG.md a proposal for the order-group insertions, which need a decision on a trade-off.
In the game, on the 3.0.1.24371 client, single player: the test map's suite with a fourteenth payload, PASS 67 of 67. The payload removes a function whose closure the map stored at the start, with its one call; the compiler warns that the stored closure keeps its old body, the map applies the payload and prints nothing it could not apply, and the stored closure still returns its old 42.
Tests:
removedStoredFunctionWarnsFromBaselineAndHistory,removedCallbackAdapterWarns,removedMethodWarnsUnlessItsSlotIsRebound,survivingFunctionWhichAbandonsOldSlotsWarns(four cases),sessionRemembersSlotsOfAnEarlierPayload,closureOwnerDistinguishesSameNamedNestedParameterTypesnow assert the warnings; newunchangedFunctionWhichAbandonsASlotWarnsOfNothing, andremovedClosureKeepsRunningItsOldBodyInTheMap, which applies such a payload in Lua: the closure kept in a global still returns its old body, the rest of the map runs the new code.Unit tests, Windows, on master with #1555:
LuaHotReloadTests(127),LuaBackendAuditTests(300),LuaTranslationTests(152),DeterministicChecks(38),HotReloadPipelineTests(6). Linux is covered by PR CI; macOS is unverified.