fix(lua-5.4): 1-arg os.difftime in 6 imported scripts#6
Merged
Conversation
Sweep of an audit miss. The initial pattern checks across PRs #1, #3, and #5 didn't catch the nested-paren form os.difftime( os.time() - X ) because the regex couldn't see through the inner parentheses; the issue surfaced on the announcements batch (#5) and got fixed there for three scripts. This PR closes the rest of the gap on master. Pattern: os_difftime( os_time() - SOMETIME ) >= delay inside onTimer handlers. Lua 5.4 strict-checks os.difftime arity and errors at runtime; the smoke harness has been silently passing because its ~5-10s window doesn't always trigger an onTimer firing while the listener is bad-shaped (it would error on first tick on a real deploy). Replaced with the equivalent direct subtraction (os_time() - X), same fix pattern as the announcements batch. Affected files: - scripts/cmd_pm2offliners/cmd_pm2offliners.lua:278 (PR #3) - scripts/etc_banner_mod/etc_banner_mod.lua:143 (PR #5) - scripts/etc_EventAnnouncer/etc_EventAnnouncer.lua:160, 180 (PR #5) - scripts/etc_mainecho/etc_mainecho.lua:121 (PR #1) - scripts/etc_messenger/etc_messenger.lua:133 (PR #1) - scripts/etc_wunschbrett/etc_wunschbrett.lua:134 (PR #1) Smoke harness against luadch-ng/luadch v3.1.1: 10 / 10 PASS. Future-proofing: for upcoming import batches use a multiline-aware audit that walks all os.difftime call sites and inspects the full arglist between the matched parens, not a flat regex.
This was referenced May 6, 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.
Sweep of an audit miss. The initial pattern check across PRs #1, #3, and #5 missed the nested-paren form `os.difftime( os.time() - X )` because the regex didn't see through the inner parentheses. The issue surfaced on the announcements batch (#5) and got fixed there for three scripts. This PR closes the rest of the gap on master.
The bug
Pattern: `os_difftime( os_time() - SOMETIME ) >= delay` inside onTimer handlers.
Lua 5.4 strict-checks `os.difftime` arity (must be 2 args). The upstream wrote one expression-arg pattern that reduced to a single number and 5.4 errors at runtime: `bad argument #2 to 'difftime' (number expected, got no value)`.
The smoke harness has been silently passing because its ~5-10s window doesn't always trigger an onTimer firing while the listener is bad-shaped. On a real deploy it would error on the first tick.
Fix
Replaced `os_difftime( os_time() - X )` with the equivalent direct subtraction `(os_time() - X)`. Same pattern that landed in the announcements PR (#5).
Affected files
7 occurrences across 6 files. +7 / -7 lines.
Test plan
Future-proofing
For upcoming import batches I'm using a multiline-aware audit (awk that skips block-comment regions) that walks every `os.difftime` call site and inspects the full arglist between the matched parens, instead of a flat regex.