core: Fix __inv__ for i8-based boolean operands
This commit is contained in:
parent
8404d4c4dc
commit
00d1b9be9b
@ -1308,7 +1308,14 @@ pub fn gen_unaryop_expr_with_values<'ctx, G: CodeGenerator>(
|
||||
let val = val.into_int_value();
|
||||
match op {
|
||||
ast::Unaryop::Invert | ast::Unaryop::Not => {
|
||||
ctx.builder.build_not(val, "not").map(Into::into).unwrap()
|
||||
let not = ctx.builder.build_not(val, "not").unwrap();
|
||||
let not_bool = ctx.builder.build_and(
|
||||
not,
|
||||
not.get_type().const_int(1, false),
|
||||
"",
|
||||
).unwrap();
|
||||
|
||||
not_bool.into()
|
||||
}
|
||||
_ => val.into(),
|
||||
}
|
||||
|
@ -455,6 +455,12 @@ def test_ndarray_inv():
|
||||
output_ndarray_int32_2(x_int32)
|
||||
output_ndarray_int32_2(y_int32)
|
||||
|
||||
x_bool = np_full([2, 2], True)
|
||||
y_bool = ~x_bool
|
||||
|
||||
output_ndarray_bool_2(x_bool)
|
||||
output_ndarray_bool_2(y_bool)
|
||||
|
||||
def test_ndarray_eq():
|
||||
x = np_identity(2)
|
||||
y = x == np_full([2, 2], 0.0)
|
||||
|
Loading…
Reference in New Issue
Block a user