Skip to content

Commit

Permalink
better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
UnsignedByte committed Apr 17, 2024
1 parent d50e317 commit 75f2815
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions crates/ir/src/from_ast/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,12 @@ fn try_transform(ns: ast::Namespace) -> BuildRes<ir::Context> {
ns.bindings.iter().copied().map(ast::Expr::Concrete),
toplevel_id.clone(),
builder.diag(),
).map_err(
|mut e| {
let err = Error::misc(format!("Incorrect parameter bindings provided to top-level component {}", sig.name)).add_note(e.add_message("Parameter bindings should be provided via the `--bindings` flag in a `.toml` file."));
e.add_error(err);
e
}
)?
.into_iter()
.enumerate()
Expand Down
4 changes: 2 additions & 2 deletions tests/errors/binding/main-concrete.expect
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
1
---STDERR---
error: Default values for parameters in the main component must be concrete
┌─ tests/errors/binding/main-default.fil:2:19
┌─ tests/errors/binding/main-concrete.fil:2:19
2 │ comp main[?A=31, ?B=1+W]<'G:1>() -> () {
2 │ comp main[?A=31, ?B=1+A]<'G:1>() -> () {
│ ^ Parameter was not given a concrete value

Compilation failed with 1 errors.
Expand Down
2 changes: 1 addition & 1 deletion tests/errors/binding/main-concrete.fil
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// check default parameters in the main component
comp main[?A=31, ?B=1+W]<'G:1>() -> () {
comp main[?A=31, ?B=1+A]<'G:1>() -> () {

}
5 changes: 4 additions & 1 deletion tests/errors/binding/main-param.expect
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ error: `main' requires at least 1 parameters but 0 were provided
2 │ comp main[A]<'G:1>() -> () {
│ ^^^^ `main' requires at least 1 parameters but 0 were provided

Compilation failed with 1 errors.
error: Incorrect parameter bindings provided to top-level component main
= Parameter bindings should be provided via the `--bindings` flag in a `.toml` file.

Compilation failed with 2 errors.
Run with --show-models to generate assignments for failing constraints.

0 comments on commit 75f2815

Please sign in to comment.