forked from M-Labs/nac3
core: fix list_slice_assignment assert int type
This commit is contained in:
parent
8a6dc1c1e1
commit
80e56bc081
|
@ -7,7 +7,7 @@ use super::{
|
||||||
ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, ListValue, NDArrayValue,
|
ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, ListValue, NDArrayValue,
|
||||||
TypedArrayLikeAdapter, UntypedArrayLikeAccessor,
|
TypedArrayLikeAdapter, UntypedArrayLikeAccessor,
|
||||||
},
|
},
|
||||||
llvm_intrinsics, CodeGenContext, CodeGenerator,
|
llvm_intrinsics, CodeGenContext, CodeGenerator, Int, Int64, NIntModel,
|
||||||
};
|
};
|
||||||
use crate::codegen::classes::TypedArrayLikeAccessor;
|
use crate::codegen::classes::TypedArrayLikeAccessor;
|
||||||
use crate::codegen::stmt::gen_for_callback_incrementing;
|
use crate::codegen::stmt::gen_for_callback_incrementing;
|
||||||
|
@ -416,14 +416,27 @@ pub fn list_slice_assignment<'ctx, G: CodeGenerator + ?Sized>(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let cond_1 = ctx.builder.build_and(dest_step_eq_one, src_slt_dest, "slice_cond_1").unwrap();
|
let cond_1 = ctx.builder.build_and(dest_step_eq_one, src_slt_dest, "slice_cond_1").unwrap();
|
||||||
let cond = ctx.builder.build_or(src_eq_dest, cond_1, "slice_cond").unwrap();
|
let cond = ctx.builder.build_or(src_eq_dest, cond_1, "slice_cond").unwrap();
|
||||||
|
|
||||||
|
// TODO: Temporary fix. Rewrite `list_slice_assignment` later
|
||||||
|
// Exception params should have been i64
|
||||||
|
{
|
||||||
|
let param_model = NIntModel(Int64);
|
||||||
|
|
||||||
|
let src_slice_len =
|
||||||
|
Int::from(src_slice_len).s_extend_or_bit_cast(ctx, param_model, "src_slice_len");
|
||||||
|
let dest_slice_len =
|
||||||
|
Int::from(dest_slice_len).s_extend_or_bit_cast(ctx, param_model, "dest_slice_len");
|
||||||
|
let dest_idx_2 = Int::from(dest_idx.2).s_extend_or_bit_cast(ctx, param_model, "dest_idx_2");
|
||||||
|
|
||||||
ctx.make_assert(
|
ctx.make_assert(
|
||||||
generator,
|
generator,
|
||||||
cond,
|
cond,
|
||||||
"0:ValueError",
|
"0:ValueError",
|
||||||
"attempt to assign sequence of size {0} to slice of size {1} with step size {2}",
|
"attempt to assign sequence of size {0} to slice of size {1} with step size {2}",
|
||||||
[Some(src_slice_len), Some(dest_slice_len), Some(dest_idx.2)],
|
[Some(src_slice_len.value), Some(dest_slice_len.value), Some(dest_idx_2.value)],
|
||||||
ctx.current_loc,
|
ctx.current_loc,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let new_len = {
|
let new_len = {
|
||||||
let args = vec![
|
let args = vec![
|
||||||
|
|
Loading…
Reference in New Issue