Skip to content

Commit

Permalink
Error on nonconformant return
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlinton committed Mar 24, 2022
1 parent 9b14549 commit 594cf4d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lang/syn/src/parser/program/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ pub fn parse_return(method: &syn::ItemFn) -> ParseResult<IxReturn> {
syn::Type::Path(ty) => ty,
_ => return Err(ParseError::new(ty.span(), "expected a return type")),
};
if &ty.path.segments.last().unwrap().ident.to_string() != "Result" {
return Err(ParseError::new(
ty.path.span(),
"expected instruction return type to be Result<T>",
));
}
// Assume unit return by default
let default_generic_arg = syn::GenericArgument::Type(syn::parse_str("()").unwrap());
let generic_args = match &ty.path.segments.last().unwrap().arguments {
Expand Down

0 comments on commit 594cf4d

Please sign in to comment.