I was playing around with ternary expressions and found following unreachable code error during the c and wasm witness code generation. I am using circom 2.1.8.
Commandscircom --wasm circuit.circom or circom --c circuit.circom
Circom File
// circuit.circom
pragma circom 2.1.8;
template main_template() {
signal input in;
signal output out;
out <-- (((in ? 1 : 0) ? 1 : 0));
}
component main = main_template();
For both circuit targets (c and wasm) I get following error:
thread 'main' panicked at compiler/src/intermediate_representation/translate.rs:687:9:
internal error: entered unreachable code: This expression is syntactic sugar
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
What I find particularly interesting is that when I create a temporary variable everything compiles as expected:
pragma circom 2.1.8;
template main_template() {
signal input in;
signal output out;
var tmp = (in ? 1 : 0);
out <-- (tmp ? 1 : 0);
// out <-- (((in ? 1 : 0) ? 1 : 0));
}
component main = main_template();
Is it not possible to have multiple nested ternary expressions in the condition part?
Or is this simply not implemented yet?
Personally, I find the triggered unreachable!("This expression is syntactic sugar") error confusing. The code is clearly reachable and I am unsure what the message This expression is syntactic sugar is referring to.
I was playing around with ternary expressions and found following unreachable code error during the
c
andwasm
witness code generation. I am using circom 2.1.8.Commands
circom --wasm circuit.circom
orcircom --c circuit.circom
Circom File
For both circuit targets (
c
andwasm
) I get following error:What I find particularly interesting is that when I create a temporary variable everything compiles as expected:
Is it not possible to have multiple nested ternary expressions in the condition part? Or is this simply not implemented yet?
Personally, I find the triggered
unreachable!("This expression is syntactic sugar")
error confusing. The code is clearly reachable and I am unsure what the messageThis expression is syntactic sugar
is referring to.