Skip to content

Commit f6cf16d

Browse files
authored
fix(sema): add handling for event/error failures (#660)
fixes #659 ```bash error: wrong number of arguments for error AmazingContract.SimpleError(bool): expected 1, found 0 ╭▸ testdata/test.sol:9:9 │ 9 │ SimpleError(); │ ━━━━━━━━━━━━━ │ ╰ note: created at crates/sema/src/typeck/checker.rs:171:34, emitted at crates/sema/src/typeck/checker.rs:178:34 error: wrong number of arguments for event AmazingContract.SimpleEvent(bool): expected 1, found 2 ╭▸ testdata/test.sol:10:9 │ 10 │ SimpleEvent(true, false); │ ━━━━━━━━━━━━━━━━━━━━━━━━ │ ╰ note: created at crates/sema/src/typeck/checker.rs:171:34, emitted at crates/sema/src/typeck/checker.rs:178:34 error: aborting due to 2 previous errors ```
1 parent a7f28e8 commit f6cf16d

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

crates/sema/src/ty/print.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,23 +336,21 @@ impl<'gcx, W: fmt::Write> TySolcPrinter<'gcx, W> {
336336
self.print(ty)?; // TODO: `richIdentifier`
337337
self.buf.write_str(")")
338338
}
339-
TyKind::Error(tys, id) => self.print_function_like(tys, id.into()),
340-
TyKind::Event(tys, id) => self.print_function_like(tys, id.into()),
339+
TyKind::Error(tys, id) => {
340+
self.buf.write_str("error ")?;
341+
write!(self.buf, "{}", self.gcx.item_canonical_name(id))?;
342+
self.print_tuple(tys)
343+
}
344+
TyKind::Event(tys, id) => {
345+
self.buf.write_str("event ")?;
346+
write!(self.buf, "{}", self.gcx.item_canonical_name(id))?;
347+
self.print_tuple(tys)
348+
}
341349

342350
TyKind::Err(_) => self.buf.write_str("<error>"),
343351
}
344352
}
345353

346-
fn print_function_like(&mut self, parameters: &[Ty<'gcx>], id: hir::ItemId) -> fmt::Result {
347-
self.print_function(
348-
Some(id),
349-
parameters,
350-
&[],
351-
hir::StateMutability::NonPayable,
352-
solar_ast::Visibility::Internal,
353-
)
354-
}
355-
356354
fn print_function(
357355
&mut self,
358356
def: Option<hir::ItemId>,

0 commit comments

Comments
 (0)