fix: ZC1075 skips flag-led expansions#1421
Merged
Merged
Conversation
A flag-led parameter expansion such as `${(%):-default}` or `${(P)…}`
carries a flag plus a default that the parser cannot resolve to a
subject, so it leaves the expansion's Left nil and `${ }` as the rendered
text. ZC1075 then flagged it as an elision hazard, but a `(%)` prompt
expansion with a `:-` default never produces an empty word, so the
"quote it" advice is wrong.
When the parser could not resolve the expansion subject (Left is nil),
ZC1075 now skips it rather than guessing. Ordinary scalars and array
elements still fire. Removes 1 finding from the violation baseline
(zinit); regression test added.
redteamx
approved these changes
Jun 25, 2026
redteamx
left a comment
Collaborator
There was a problem hiding this comment.
Approved on review. Flag-led-expansion FP confirmed; nil-subject skip, baseline drift reviewed (zinit ${(%):-} prompt-default), regression test added.
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.
What
Stop ZC1075 ("quote this expansion") from flagging a flag-led parameter expansion the parser cannot fully model.
${(%):-default}parses to an expansion with a%flag, a nil subject (Left), and${ }as rendered text — the parser drops the:-default. ZC1075 then flagged it as an elision hazard. But a(%)prompt expansion with a:-default never yields an empty word, so the advice is wrong.When the parser could not resolve the subject (
Leftis nil), ZC1075 now skips the expansion instead of guessing.Why
The flagged forms (
${(%):-…},${(P)…}) carry a default or width modifier that guarantees a non-empty result, so quoting against elision is meaningless. Without the parsed subject, the kata has no basis to judge elision, so skipping is the conservative correct choice. Confirmed against real zsh:${(%):-fallback}always printsfallback.Verification
$plain) and array elements (${arr[1]}) still fire; normal${var:-default}and split flags${(f)x}keep their existing skips.read -q ${(%):-"?…"}).pkg/katas/katatests/fp_round7_test.go;go test ./...passes,golangci-lint0 issues, sweeps clean.