diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index d688cdc..718b2b7 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -475,11 +475,11 @@ impl Nac3 { if let Err(e) = composer.start_analysis(true) { // report error of __modinit__ separately - if !e.contains("") { - return Err(CompileError::new_err(format!( + return if !e.contains("") { + Err(CompileError::new_err(format!( "compilation failed\n----------\n{}", e - ))); + ))) } else { let msg = Self::report_modinit( &arg_names, @@ -489,10 +489,10 @@ impl Nac3 { &mut composer.unifier, &self.primitive, ); - return Err(CompileError::new_err(format!( + Err(CompileError::new_err(format!( "compilation failed\n----------\n{}", msg.unwrap_or(e) - ))); + ))) } } let top_level = Arc::new(composer.make_top_level_context()); diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index 03a10ee..23b609f 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -166,10 +166,10 @@ impl StaticValue for PythonValue { if ty_id == self.resolver.primitive_ids.option && name == "_nac3_option".into() { let obj = self.value.getattr(py, name.to_string().as_str())?; let id = self.resolver.helper.id_fn.call1(py, (&obj,))?.extract(py)?; - if self.id == self.resolver.primitive_ids.none { - return Ok(None) + return if self.id == self.resolver.primitive_ids.none { + Ok(None) } else { - return Ok(Some((id, obj))) + Ok(Some((id, obj))) } } let def_id = { *self.resolver.pyid_to_def.read().get(&ty_id).unwrap() }; diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 83c29ca..2a568a9 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -1691,7 +1691,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>( && id == ctx.primitives.option.get_obj_id(&ctx.unifier) { match val { - ValueEnum::Static(v) => match v.get_field("_nac3_option".into(), ctx) { + ValueEnum::Static(v) => return match v.get_field("_nac3_option".into(), ctx) { // if is none, raise exception directly None => { let err_msg = ctx.gen_string(generator, ""); @@ -1723,13 +1723,13 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>( .get_llvm_type(generator, value.custom.unwrap()) .into_pointer_type() .const_null(); - return Ok(Some(ctx.builder.build_load( + Ok(Some(ctx.builder.build_load( ptr, "unwrap_none_unreachable_load" - ).into())); + ).into())) } - Some(v) => return Ok(Some(v)), - } + Some(v) => Ok(Some(v)), + }, ValueEnum::Dynamic(BasicValueEnum::PointerValue(ptr)) => { let not_null = ctx.builder.build_is_not_null(ptr, "unwrap_not_null"); ctx.make_assert( diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index 3223611..a0c6192 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -812,17 +812,17 @@ impl<'a> Inferencer<'a> { { let custom = Some(self.primitives.int64); let v: Result = (*val).try_into(); - if v.is_ok() { - return Ok(Located { + return if v.is_ok() { + Ok(Located { location: args[0].location, custom, node: ExprKind::Constant { value: ast::Constant::Int(*val), kind: kind.clone(), }, - }); + }) } else { - return report_error("Integer out of bound", args[0].location) + report_error("Integer out of bound", args[0].location) } } } @@ -832,17 +832,17 @@ impl<'a> Inferencer<'a> { { let custom = Some(self.primitives.uint32); let v: Result = (*val).try_into(); - if v.is_ok() { - return Ok(Located { + return if v.is_ok() { + Ok(Located { location: args[0].location, custom, node: ExprKind::Constant { value: ast::Constant::Int(*val), kind: kind.clone(), }, - }); + }) } else { - return report_error("Integer out of bound", args[0].location) + report_error("Integer out of bound", args[0].location) } } } @@ -852,17 +852,17 @@ impl<'a> Inferencer<'a> { { let custom = Some(self.primitives.uint64); let v: Result = (*val).try_into(); - if v.is_ok() { - return Ok(Located { + return if v.is_ok() { + Ok(Located { location: args[0].location, custom, node: ExprKind::Constant { value: ast::Constant::Int(*val), kind: kind.clone(), }, - }); + }) } else { - return report_error("Integer out of bound", args[0].location) + report_error("Integer out of bound", args[0].location) } } }