Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle compound assignment operators #63

Open
voltrevo opened this issue May 20, 2024 · 1 comment
Open

Handle compound assignment operators #63

voltrevo opened this issue May 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@voltrevo
Copy link
Collaborator

Eg when running this program:

template network() {
    signal input x;
    signal output y;

    var z = 3;
    z += x; // <----- compound assignment

    y <== z;
}

component main = network();

We get:

Error: RuntimeError(ItemNotDeclared("get_variable_value: DataAccess { name: \"random_3750075181\", access: [] }"))

Compound assignment doesn't need to be implemented for signals, that's handled as an error by circom, eg:

error[T2000]: Typing error found
    ┌─ "./src/assets/circuit.circom":173:5
    │
173 │     y += x;
    │     ^^^^^^ The operator does not match the types of the assigned elements.
 Assignments to signals do not allow the operator =, try using <== or <-- instead

Error: AnalysisError
@namnc
Copy link
Owner

namnc commented May 20, 2024

Yeah I think right now you can do this with Variable but not Signal (in original Circom).

This is a circom extension that we should think carefully about (compound assignment is still a cool feature).

@namnc namnc added the enhancement New feature or request label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants