Repository navigation
Conversation
…er_is_uint` (#908) `_DIGIT_TEST` only matched `[[ "$x" == *[!0-9]* ]]`, so #899's `!=` guard form and its `_remember_is_uint "$x"` helper call -- both already shipped in lib-lock.sh, log.sh and session-start-hook.sh -- were invisible to `_guarded_names`. Today's uses all carry `10#`, so nothing was actually unsafe, but a future unguarded use behind either form would not have been caught. Extends `_DIGIT_TEST` with two more alternatives and adds must-fire fixtures for each new form plus a must-not-fire fixture guarding against a false match on a plain `!=` string comparison and a similarly-named helper. Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.
tests/test_arith_base_lint_332.py collects the names guarded as digits-only, so it can check that arithmetic on them uses
10#. Its_DIGIT_TESTonly matched the[[ "$x" == *[!0-9]* ]]form.#899 introduced two more guard shapes this lint could not see: the negated
[[ "$x" != *[!0-9]* ]]form, and the_remember_is_uint "$x"helper call (scripts/log.sh). Both already guard real shipped variables --_LOCK_SELF,_mtime,_pidin scripts/lib-lock.sh via the!=form, and ~11 call sites across scripts/log.sh and scripts/session-start-hook.sh via the helper -- and all of today's uses already carry10#at their one arithmetic site, so nothing was previously unsafe. This closes a pure lint-coverage gap for future code.What changed
_DIGIT_TESTwith two more regex alternatives: the!=form, and_remember_is_uint "$x".!=string comparison; a differently-named helper sharing only a prefix,_remember_is_uint_like)._DIGIT_TESTto describe all four guard shapes now recognized.Tests
Red: reverted the regex to its old
==-only form, ran the four new/related tests by-k-> 2 failed (the new must-fire tests), 2 passed (the must-not-fire tests, as expected either way).Green: restored the fix, ran the full file ->
15 passed in 0.19s.Full
pytestnot run: the lane_setup.py guard check found no cross-cutting guard matched for this file, so the targeted run above is the complete narrowed set.Review
Two concurrent read-only spawns (Explore, oss:auditor) against the committed commit, neither found any findings; tree_snapshot compare verdict clean before/after.
Adjacent (below the filing bar)
Closes #908
[AI-generated]