Require more precise type resolution in binary operation
In type checking phase, the type of a binary operation expression is only determined by the left hand side:
https://github.com/zksecurity/noname/blob/a2d31f7008cea52f6dda144a4db0864364318c90/src/type_checker/checker.rs#L389
However, in the following case, it can mistakenly seen a non constant expression as constant;
fn is_not_constant(val: Field) -> Field {
// val can be non constant
return 1 + val;
}
1 + val can be a non constant field type as val can be a non constant.
Therefore, when computing the types for the binary operations, it should take cares of the both sides.
mmm interesting, wondering if that means that "constant" shouldn't be in the type
yeah, I think we still need to propagate whether it is a constant or not. For example, the functions support const attribute that enforce the argument to be constant.