2.8. Scoping

Circom has a static scoping like in C or Rust. However, signals and components must have a global scoping and hence, they should be defined at the top level block of the template that defines them.

Regarding visibility, a signal x of a component c is also visible in the template t that has declared c, using the notation c.x.

template Circuit1() {
signal input in;
signal output out;
signal a;
a <== in*in;
out <== a+3;
}
template Circuit2() {
signal input in[2];
signal output out;
component op = Circuit1();
in[1] - in[0] ==> op.in;
op.out ==> out;
}

No access to signals of nested sub components is allowed. For instance, if c is build using another component d, the signals of d cannot be accessed from t.

A var can be defined at any block and its visibility is reduced to the block like in C or Rust.