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

fix: throw an error when key is used a variable name because this cau… #257

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/transformers/visitors/checks/unsupportedVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export default {
`Zokrates does not support variables that begin with an underscore such as as _value.`,
node
);
if (node.name === 'key'){
throw new ZKPError(
`Zokrates does not support variables with the name key, please choose a different name.`,
node
);
}
},
},
};
8 changes: 4 additions & 4 deletions test/contracts/increments.zol
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ contract MyContract {
secret uint256 private a;
secret mapping(uint256 => uint256) private b;

function assign(secret uint256 param1, uint256 key, secret uint256 c) public {
function assign(secret uint256 param1, uint256 ky, secret uint256 c) public {
unknown a += param1;
unknown b[key] += c;
unknown b[ky] += c;
}

function decra(secret uint256 param2) public {
a -= param2;
}

function decrb(secret uint256 param2, uint256 key) public {
b[key] -= param2;
function decrb(secret uint256 param2, uint256 ky) public {
b[ky] -= param2;
}

function incra(secret uint256 param3) public {
Expand Down
Loading