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
4 changes: 3 additions & 1 deletion prqlc/prqlc/src/semantic/resolver/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ impl pl::PlFold for Resolver<'_> {
let func = name.try_cast(|n| n.into_func(), None, "a function")?;

// fold function
let func = self.apply_args_to_closure(func, args, named_args)?;
let func = self
.apply_args_to_closure(func, args, named_args)
.with_span_fallback(span)?;
self.fold_function(func, span)?
}

Expand Down
4 changes: 2 additions & 2 deletions prqlc/prqlc/src/semantic/resolver/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ impl Resolver<'_> {
if let Some((name, _)) = named_args.into_iter().next() {
// TODO: report all remaining named_args as separate errors
return Err(Error::new_simple(format!(
"unknown named argument `{name}` to closure {:?}",
closure.name_hint
"unknown named argument `{name}` to function `{}`",
closure.as_debug_name()
)));
}

Expand Down
10 changes: 0 additions & 10 deletions prqlc/prqlc/tests/integration/bad_error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ 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
37 changes: 34 additions & 3 deletions prqlc/prqlc/tests/integration/error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,7 @@ 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.
// it's the sole argument — extra args used to panic on `exactly_one`.
assert_snapshot!(compile(r"from x | select (std.not {a} b)").unwrap_err(), @"
Error:
╭─[ :1:18 ]
Expand All @@ -580,3 +578,36 @@ fn not_with_extra_args() {
───╯
");
}

#[test]
fn unknown_named_arg() {
// A named argument that no parameter matches names the function and points
// at the call site.
assert_snapshot!(compile(r"from x | select (std.not {a} b:1)").unwrap_err(), @"
Error:
╭─[ :1:18 ]
1 │ from x | select (std.not {a} b:1)
│ ───────┬───────
│ ╰───────── unknown named argument `b` to function `not`
───╯
");
assert_snapshot!(compile(r"from x | select (std.not b:1)").unwrap_err(), @"
Error:
╭─[ :1:18 ]
1 │ from x | select (std.not b:1)
│ ─────┬─────
│ ╰─────── unknown named argument `b` to function `not`
───╯
");
assert_snapshot!(compile(r"from x | take 1 b:2").unwrap_err(), @"
Error:
╭─[ :1:10 ]
1 │ from x | take 1 b:2
│ ─────┬────
│ ╰────── unknown named argument `b` to function `take`
───╯
");
}
Loading