Fix: update() called before setup() on startup#27
Draft
triss wants to merge 1 commit into
Draft
Conversation
triss
force-pushed
the
fix/26-update-before-setup
branch
from
July 23, 2026 11:32
1282ecd to
78af256
Compare
love.update(dt) ran unconditionally every frame, but setup() only ran later within the same frame's draw phase - so the user's update() callback could execute before setup() had a chance to initialize any state, causing nil errors on startup. Split the per-frame framework bookkeeping (mouse position, deltaTime, key, video looping) into L5_internal.updateFrameState(dt), which still runs unconditionally every frame including the one where setup() runs, so that state stays live during setup() as before. The user's update() callback now lives in the same branch as draw() - only reached once setup() has completed - so no flag needs to be shared across functions. Fixes L5lua#26 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
triss
force-pushed
the
fix/26-update-before-setup
branch
from
July 23, 2026 12:55
78af256 to
f46e457
Compare
triss
marked this pull request as ready for review
July 23, 2026 15:27
triss
marked this pull request as draft
July 23, 2026 15:34
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.
Summary
Fixes #26
love.update(dt)ran on startup and triggered user'supdate()beforesetup()had been run. This meant state initialised insetup()may not have been ready for update.Lifecycle of applications should be:
not
Solution
love.update(dt)'s per-frame framework bookkeeping (mouse position,deltaTime,key, video looping) into a newL5_internal.updateFrameState(dt), which still runs unconditionally every frame - including the framesetup()runs on - so that state stays live duringsetup()exactly as before.update()callback now lives in the same branch asdraw(), which is only reached oncesetup()has completed - soupdate()naturally can't fire beforesetup(), with no flag needing to be shared across functions.Test plan
attempt to perform arithmetic on global 'v' (a nil value)) on pre-fix code using the issue's exact repro script run vialovesetup()completing beforeupdate()firesmouseX,mouseY,deltaTime, andkeyare still live (non-default/non-nil) insidesetup()main.luaexample sketch to confirm no regression in normal draw-loop behavior