Skip to content

Commit

Permalink
Fix return type.
Browse files Browse the repository at this point in the history
  • Loading branch information
azteca1998 committed Nov 14, 2024
1 parent cba2bd4 commit 7fb4d30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
8 changes: 2 additions & 6 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,8 @@ fn compile_func(
invocation
.branches
.iter()
.zip(helper.results())
.zip(helper.results()?)
.map(|(branch_info, result_values)| {
let result_values = result_values?;
assert_eq!(
branch_info.results.len(),
result_values.len(),
Expand All @@ -625,10 +624,7 @@ fn compile_func(

Ok(edit_state::put_results(
state.clone(),
branch_info
.results
.iter()
.zip(result_values.iter().copied()),
branch_info.results.iter().zip(result_values.into_iter()),
)?)
})
.collect::<Result<_, Error>>()?,
Expand Down
28 changes: 16 additions & 12 deletions src/libfuncs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Contains libfunc generation stuff (aka. the actual instructions).

use crate::{
error::{Error as CoreLibfuncBuilderError, Result},
error::{panic::ToNativeAssertError, Error as CoreLibfuncBuilderError, Result},
metadata::MetadataStorage,
types::TypeBuilder,
utils::BlockExt,
Expand Down Expand Up @@ -280,17 +280,21 @@ where
'this: 'ctx,
{
#[doc(hidden)]
pub(crate) fn results(self) -> impl Iterator<Item = NativeResult<Vec<Value<'ctx, 'this>>>> {
self.results.into_iter().enumerate().map(|(branch_idx, x)| {
x.into_iter()
.enumerate()
.map(|(arg_idx, x)| {
x.into_inner().to_native_assert_error(&format!(
"Argument #{arg_idx} of branch {branch_idx} doesn't have a value."
))
})
.collect()
})
pub(crate) fn results(self) -> Result<Vec<Vec<Value<'ctx, 'this>>>> {
self.results
.into_iter()
.enumerate()
.map(|(branch_idx, x)| {
x.into_iter()
.enumerate()
.map(|(arg_idx, x)| {
x.into_inner().to_native_assert_error(&format!(
"Argument #{arg_idx} of branch {branch_idx} doesn't have a value."
))
})
.collect()
})
.collect()
}

/// Return the initialization block.
Expand Down

0 comments on commit 7fb4d30

Please sign in to comment.