Skip to content

hotfix: fix uniqby regression tests broken on main#207

Merged
danieljohnmorris merged 1 commit into
mainfrom
hotfix/uniqby-tree-walker
May 12, 2026
Merged

hotfix: fix uniqby regression tests broken on main#207
danieljohnmorris merged 1 commit into
mainfrom
hotfix/uniqby-tree-walker

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

PR #195 (uniqby) merged with tests/regression_uniqby.rs failing on main. Two distinct issues:

  1. CLI arg parsing kept quotes inside list literals. parse_cli_arg did a naive split(',') of bracketed input, so ["apple","ant"] became [Text("\"apple\""), Text("\"ant\"")], i.e. each element still had its surrounding double quotes. uniqby (using hd s as the key) then keyed every element by ", kept only the first, and rendered as ["apple"]. Fix: strip surrounding "..." from string args and split on top-level commas only (quote-aware + bracket-aware) so nested lists and strings containing commas survive.

  2. PARITY_SRC used a multi-line function body the parser rejects. A bare expression on its own line after the conditional arm triggered ILO-P001 expected declaration, got Text("odd"). Rewritten as a single-line prefix ternary, which is the canonical ilo idiom for this shape:
    par n:n>t;?=(mod n 2) 0 "even" "odd"

Three example .ilo files (rsrt.ilo, sort-by-key.ilo, multiline-fn.ilo) had -- out: expectations written around the old buggy rendering (literal quotes preserved on string args). Updated to match the correct behaviour.

The uniqby tree-walker arm itself in src/interpreter/mod.rs was correct - the bug was upstream in CLI arg parsing. No interpreter changes needed.

This unblocks downstream PRs.

Test plan

  • cargo test --features cranelift --test regression_uniqby - 6/6 pass
  • cargo test --features cranelift - full suite green (no regressions)
  • cargo fmt --all -- --check - clean
  • cargo clippy --all-targets --features cranelift -- -D warnings - clean

PR #195 merged with regression_uniqby tests broken on main:

1. parse_cli_arg treated each comma-split chunk of a bracketed list as
   raw text, so `["apple","ant"]` became a list of strings with the
   literal double quotes still attached. uniqby then keyed every entry
   by `"` (the first char of the quoted form), kept just the first
   element, and rendered as `["apple"]`. Fix: strip surrounding `"..."`
   in parse_cli_arg and split on top-level commas only (respecting
   quotes and nested brackets) so list elements parse the way they read.

2. PARITY_SRC used a multi-line `par` body that the parser does not
   accept (bare expression after a newline triggers ILO-P001 expected
   declaration). Rewritten as a single-line prefix ternary, which is
   the canonical ilo idiom: `par n:n>t;?=(mod n 2) 0 "even" "odd"`.

Example expected outputs (rsrt, sort-by-key, multiline-fn) were written
around the old buggy behaviour and have been updated to reflect the
correct rendering with quotes stripped.

cargo test --features cranelift: all green.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 10 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/main.rs 77.77% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

@danieljohnmorris danieljohnmorris merged commit ef2bf52 into main May 12, 2026
5 checks passed
@danieljohnmorris danieljohnmorris deleted the hotfix/uniqby-tree-walker branch May 12, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant