Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions prqlc/prqlc/src/semantic/resolver/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,14 @@ impl pl::PlFold for Resolver<'_> {
}

// special case: handle the syntax !{tuple..} via resolve_column_exclusion
pl::ExprKind::FuncCall(pl::FuncCall { name, args, .. })
if (name.kind.as_ident()).is_some_and(|i| i.to_string() == "std.not")
&& matches!(args[0].kind, pl::ExprKind::Tuple(_)) =>
pl::ExprKind::FuncCall(pl::FuncCall {
name,
args,
named_args,
}) if (name.kind.as_ident()).is_some_and(|i| i.to_string() == "std.not")
&& args.len() == 1
&& named_args.is_empty()
&& matches!(args[0].kind, pl::ExprKind::Tuple(_)) =>
{
let arg = args.into_iter().exactly_one().unwrap();
self.resolve_column_exclusion(arg)?
Expand Down
10 changes: 10 additions & 0 deletions prqlc/prqlc/tests/integration/bad_error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ fn nested_groups() {
");
}

#[test]
fn not_with_named_arg() {
// A named argument to `std.not` isn't column-exclusion syntax. Both of these
// used to panic — the first on `exactly_one`, the second on indexing
// `args[0]` with no positional args at all. They're errors now, but the
// message has no span and `Debug`-prints the ident.
assert_snapshot!(compile(r"from x | select (std.not {a} b:1)").unwrap_err(), @r#"Error: unknown named argument `b` to closure Some(["std", "not"])"#);
assert_snapshot!(compile(r"from x | select (std.not b:1)").unwrap_err(), @r#"Error: unknown named argument `b` to closure Some(["std", "not"])"#);
}

#[test]
fn just_std() {
assert_snapshot!(compile(r###"
Expand Down
26 changes: 26 additions & 0 deletions prqlc/prqlc/tests/integration/error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,29 @@ fn append_by_name_unnamed() {
───╯
");
}

#[test]
fn not_with_extra_args() {
// A tuple argument to `std.not` is column-exclusion syntax, but only when
// it's the sole argument — extra args used to panic on `exactly_one`. The
// named-argument forms are in `bad_error_messages::not_with_named_arg`,
// since the message they produce still needs improving.
assert_snapshot!(compile(r"from x | select (std.not {a} b)").unwrap_err(), @"
Error:
╭─[ :1:18 ]
1 │ from x | select (std.not {a} b)
│ ──────┬──────
│ ╰──────── Too many arguments to function `not`
───╯
");
assert_snapshot!(compile(r"from x | select (std.not {a} {b})").unwrap_err(), @"
Error:
╭─[ :1:18 ]
1 │ from x | select (std.not {a} {b})
│ ───────┬───────
│ ╰───────── Too many arguments to function `not`
───╯
");
}
Loading