Skip to content

Commit

Permalink
Improve some from_ast errors (#2102)
Browse files Browse the repository at this point in the history
* fix a missing papercut test

* slightly improved handlig of ast errors

* formatting

* Revert "fix a missing papercut test"

This reverts commit c155487.
  • Loading branch information
nathanielnrn authored Jun 5, 2024
1 parent 54f63e9 commit 7eaf61e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions calyx-ir/src/from_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,24 @@ fn get_port_ref(port: ast::Port, comp: &Component) -> CalyxResult<RRC<Port>> {
.ok_or_else(|| Error::undefined(component, "cell".to_string()))?
.borrow()
.find(port)
.ok_or_else(|| Error::undefined(port, "port".to_string())),
.ok_or_else(|| {
Error::undefined(
Id::new(format!("{}.{}", component, port)),
"port".to_string(),
)
}),
ast::Port::This { port } => {
comp.signature.borrow().find(&port).ok_or_else(|| {
Error::undefined(port, "component port".to_string())
})
}
ast::Port::Hole { group, name: port } => match comp.find_group(group) {
Some(g) => g
.borrow()
.find(port)
.ok_or_else(|| Error::undefined(port, "hole".to_string())),
Some(g) => g.borrow().find(port).ok_or_else(|| {
Error::undefined(
Id::new(format!("{}.{}", g.borrow().name(), port)),
"hole".to_string(),
)
}),
None => comp
.find_static_group(group)
.ok_or_else(|| Error::undefined(group, "group".to_string()))?
Expand Down
2 changes: 1 addition & 1 deletion tests/errors/papercut/multi-done.expect
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
---STDERR---
Error: tests/errors/papercut/multi-done.futil
10 | read_done = mem_0.read_done;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined port name: read_done
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined port name: mem_0.read_done

0 comments on commit 7eaf61e

Please sign in to comment.