Skip to content

Commit

Permalink
apply @hdwalters suggestions
Browse files Browse the repository at this point in the history
Co-Authored-By: hdwalters <[email protected]>
  • Loading branch information
b1ek and hdwalters committed Dec 24, 2024
1 parent 6ef629c commit d7f268c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modules/function/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl SyntaxModule<ParserMetadata> for FunctionDeclaration {
// Parse the body
token(meta, "{")?;
let (index_begin, index_end, is_failable) = skip_function_body(meta, declared_failable, &returns_tok)?;
if (!is_failable) && declared_failable {
if !is_failable && declared_failable {
return error!(meta, returns_tok, "Infallible functions must not have a '?' after the type name");
}
// Create a new context with the function body
Expand Down
6 changes: 5 additions & 1 deletion src/modules/function/declaration_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ use crate::utils::cc_flags::{CCFlags, get_ccflag_name};
use crate::utils::context::Context;
use crate::utils::function_interface::FunctionInterface;

pub fn skip_function_body(meta: &mut ParserMetadata, declared_failable: bool, returns_tok: &Option<Token>) -> Result<(usize, usize, bool), Failure> {
pub fn skip_function_body(
meta: &mut ParserMetadata,
declared_failable: bool,
returns_tok: &Option<Token>
) -> Result<(usize, usize, bool), Failure> {
let index_begin = meta.get_index();
let mut is_failable = false;
let mut scope = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/function/invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl SyntaxModule<ParserMetadata> for FunctionInvocation {
self.is_failable = function_unit.is_failable;
if self.is_failable {
match syntax(meta, &mut self.failed) {
Ok(_) => {},
Ok(_) => (),
Err(Failure::Quiet(_)) => return error!(meta, tok => {
message: "This function can fail. Please handle the failure",
comment: "You can use '?' in the end to propagate the failure"
Expand Down

0 comments on commit d7f268c

Please sign in to comment.