fix: backtick parameter names in transform argument errors - #6165
Conversation
prql-bot
left a comment
There was a problem hiding this comment.
Change is correct and the snapshots match what the compiler emits — I verified the four who strings against the hand-written Reason::Expected arms a few lines below each try_cast, and grepped for other recorded copies of these messages (expected inner, left, right or full / position or name / early or late / csv or json); the four snapshots in error_messages.rs are the only ones, so nothing else goes stale.
One leftover of the same class, outside this diff and not a #6104 regression, so worth a separate PR rather than widening this one: take still names itself two different ways depending on which check fires. The range validation in semantic/lowering.rs — the Reason::Expected with expected: "a positive int range" — passes who: Some("take".to_string()) unbackticked, while transforms.rs backticks the same transform name in its expected: "int or range" arm. Both are reachable:
$ echo "from x | take 0..-1" | prqlc compile
╰────── take expected a positive int range, but found 0..-1
$ echo "from x | take y" | prqlc compile
╰── `take` expected int or range, but found this.x.y
Backticking the lowering.rs one would also touch four snapshots in tests/integration/sql.rs. Happy to push that as a follow-up if it's wanted.
#6104 moved
join'sside,append'sby,tuple_uniq'stakeandfrom_text'sformatonto enum types, and in the process the reachable error path for each moved from a hand-writtenError::new(Reason::Expected { … })to thewhoargument oftry_cast— which was spelled without backticks. The snapshot in that PR records the change:The hand-written arms are still there a few lines below each
try_cast, still spelled`take`/`side`/`by`/`format`, so the two paths in the same block disagree on how they name the parameter. Everything else intransforms.rsbackticks it too —parameterexpanding, `parameter `rolling,format!("`{name}`"). This restores the backticks on the fourtry_castcalls, so the reachable message matches what the rest of the file produces.The
Some("sort")cast at the top of the file is left alone: itswhois the transform, not a parameter, and it wasn't touched by #6104.I only found one existing snapshot covering any of these paths (
tuple_uniq_take_wrong), sotransform_param_not_a_literalpins the other three. Reaching the cast needs an argument that resolves but isn't a literal — a plain wrong literal likeside:"four"is now caught earlier by the enum type check and never gets here — so the new test uses s-strings.Verification
cargo test -p prqlc -p prqlc-parser— green (lib 78 passed / 1 ignored,tests/integration485 passed / 5 ignored, parser 97 passed).cargo clippy -p prqlc --all-targets,cargo fmt --check -p prqlc— clean.task prqlc:pull-requestcouldn't run here — it shells out tocargo insta, which isn't on the sandbox's PATH (ci: expose cargo-insta and cargo-nextest to the tend sandbox #6144). Rancargo testover the same packages instead.