Skip to content

refine: remove the unused UnOp enum from the RQ IR - #6310

Open
prql-bot wants to merge 1 commit into
mainfrom
refine/remove-dead-rq-unop
Open

refine: remove the unused UnOp enum from the RQ IR#6310
prql-bot wants to merge 1 commit into
mainfrom
refine/remove-dead-rq-unop

Conversation

@prql-bot

@prql-bot prql-bot commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

prqlc::ir::rq::UnOp has no producers or consumers. RQ models unary operations the same way it models every other operation — ExprKind::Operator { name: "std.neg", args }, lowered from PL in lowering.rs and translated in sql/gen_expr.rs — so nothing ever builds an rq::UnOp, matches on one, or folds one. The only UnOp the compiler actually uses is prqlc_parser's pr::UnOp, re-exported through ir::pl; the RQ copy carries a different variant set (Neg/Not against pr::UnOp's Neg/Not/Add/EqSelf), which makes the shared name an active confusion hazard for anyone reading both IRs.

This deletes the enum and drops it from the ir::rq re-export list. It is a public item of the prqlc crate, so this is technically a breaking change to that surface — but since no API in the crate accepts or returns the type, nothing downstream can be holding a value of it that any prqlc call would consume.

No regression test: the removal is a pure deletion of an unreferenced type, and cargo check -p prqlc --all-targets is the check that it was in fact unreferenced. Found by the nightly rolling survey.

How "unused" was established

A workspace-wide search for UnOp (and for un_op/unop, case-insensitive) returns only the parser's pr::UnOp definition in parser/pr/ops.rs and its uses — parser/expr.rs, parser/pr/expr.rs, ir/pl/mod.rs, semantic/ast_expand.rs, codegen/ast.rs — plus the two lines this PR removes. RqFold has no fold method for it, and no field of Expr or ExprKind references it, so it is unreachable from schema_for!(rq::RelationalQuery) and the generated RQ JSON schema is unchanged despite the JsonSchema derive. No committed schema or snapshot mentions it either.

RQ represents unary operations as ExprKind::Operator, so rq::UnOp is never constructed, matched, or folded anywhere in the workspace. The live UnOp is prqlc_parser's pr::UnOp, re-exported through ir::pl.
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