Skip to content
Snippets Groups Projects
Commit 65900b36 authored by Aaron Councilman's avatar Aaron Councilman Committed by rarbore2
Browse files

Fix type-checking of select to handle non-concrete condition type

parent 43b90e94
No related branches found
No related tags found
1 merge request!56Fix type-checking of select to handle non-concrete condition type
......@@ -688,26 +688,19 @@ fn typeflow(
return Error(String::from("Ternary node must have exactly three inputs."));
}
if let Concrete(id) = inputs[0] {
match op {
TernaryOperator::Select => {
match op {
TernaryOperator::Select => {
if let Concrete(id) = inputs[0] {
if !types[id.idx()].is_bool() {
return Error(String::from(
"Select ternary node input cannot have non-bool condition input.",
));
}
let data_ty = TypeSemilattice::meet(inputs[1], inputs[2]);
if let Concrete(data_id) = data_ty {
return Concrete(data_id);
} else {
return data_ty;
}
}
TypeSemilattice::meet(inputs[1], inputs[2])
}
}
Error(String::from("Unhandled ternary types."))
}
Node::Call {
control: _,
......
fn test(x : prod(i32, f32), b: bool) -> prod(i32, f32)
zero = constant(u64, 0)
one = constant(i32, 1)
two = constant(u64, 2)
three = constant(f32, 3.0)
f_ctrl = fork(start, 10)
idx = thread_id(f_ctrl, 0)
mod2 = rem(idx, two)
is_even = eq(mod2, zero)
field0 = read(res, field(0))
field1 = read(res, field(1))
add = add(field0, one)
mul = mul(field1, three)
upd0 = write(res, add, field(0))
upd1 = write(res, mul, field(1))
select = select(is_even, upd0, upd1)
j_ctrl = join(f_ctrl)
res = reduce(j_ctrl, x, select)
r = return(j_ctrl, res)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment