Skip to content

fix(parser): preserve adjacent arithmetic operator tokens - #786

Open
Prasad-178 wants to merge 3 commits into
vercel-labs:mainfrom
Prasad-178:fix/compact-arithmetic-operators
Open

Prasad-178 wants to merge 3 commits into
vercel-labs:mainfrom
Prasad-178:fix/compact-arithmetic-operators

Conversation

@Prasad-178

Copy link
Copy Markdown

Addresses item 1 of #758.

The arithmetic command parser now preserves adjacent compound operator tokens, including when the lexer puts the equals sign and its operand in the same token. Source positions keep separated operators such as > = distinct.

Verified compact and spaced forms of >=, <=, and >>= against GNU Bash. Regression tests also cover invalid separated comparisons. Typecheck, lint, 1,528 parser/interpreter/limit tests (one skipped), and 1,059 comparison tests passed locally.

@vercel

vercel Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@Prasad-178 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread packages/just-bash/src/parser/parser.ts Resolved
@auto-maintain

auto-maintain Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🤖 auto-maintain review

Automated, advisory triage for @Prasad-178's PR. Facts below are read from the GitHub API.

Check Result
Author's merged PRs (this repo) 0 — ⚠️ first-time contributor
Account established ✅ (age 1794d · 20 followers · 75 public repos)
Commits signed/verified ✅ 2/2
Changeset included ✅ (.changeset/compact-arithmetic-operators.md)

Review panel: 🟡 medium highest severity

just-bash maintainer code review: 🟡 medium

The source-aware operator fix regresses arithmetic parsing through the parser's pre-tokenized-input API.

  • packages/just-bash/src/parser/parser.ts:1167 — `parseTokens()` has no matching `_input`, so slicing it returns an empty gap and marks every token pair adjacent. Pre-tokenized `((i > =3))` is therefore reconstructed as valid `i >=3`; reused parsers may instead consult stale source text. Determine adjacency from token offsets when raw input is unavailable.

General code review: 🟡 medium

The source-aware operator fix breaks arithmetic parsing through the existing pre-tokenized parser path.

  • packages/just-bash/src/parser/parser.ts:1167 — `parseArithmeticCommand` now derives adjacency from `_input`, but `parseTokens()` never initializes it. Parsing tokens for `((i > =3))` with a fresh Parser therefore slices an empty string, treats the separated tokens as adjacent, and incorrectly accepts them as `>=`; reused parsers can instead consult stale source text.

Adversarial security: 🟢 low

No actionable security issues found in the complete diff.

Adversarial security (second opinion): 🟢 low

Parser-only change with no new I/O, execution, or dependency surface; offset arithmetic is in-bounds and failure modes fall back to the prior conservative spacing behavior, so no actionable security findings.

Standard Bash and host portability: 🟡 medium

The operator fix introduces a Bash-incompatible acceptance of adjacent single-quoted expressions.

  • packages/just-bash/src/parser/parser.ts:1174 — Adjacent fully single-quoted operands such as `((4>'=3'))` are incorrectly joined into `4>=3`. Bash preserves single quotes in arithmetic and rejects this syntax, but the lexer exposes the token value as `=3`, so `startsWith("=")` accepts it. Require the token to be unquoted before joining.

Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call.

@privatenumber privatenumber added awaiting-review Maintainer review or re-review is next. Does not imply approval or merge readiness. bug Something isn't working p2 Normal backlog action. Priority is not acceptance or a delivery promise. shell Parsing, quoting, expansion, pipelines, redirection, and shell execution labels Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review Maintainer review or re-review is next. Does not imply approval or merge readiness. bug Something isn't working p2 Normal backlog action. Priority is not acceptance or a delivery promise. shell Parsing, quoting, expansion, pipelines, redirection, and shell execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants