Skip to content

Commit

Permalink
Merge pull request #317 from EYBlockchain/lydia/contract_negation
Browse files Browse the repository at this point in the history
fix: ! as unary operator in the contract
  • Loading branch information
lydiagarms authored Jul 23, 2024
2 parents 8d563f7 + 2a58383 commit c23bf1a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/codeGenerators/contract/solidity/toContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ function codeGenerator(node: any) {
return `${codeGenerator(node.expression)}(${codeGenerator(node.arguments)})`;

case 'UnaryOperation':
if (node.operator === '!'){
return `${node.operator}${codeGenerator(node.subExpression)}`;
}
return `${codeGenerator(node.subExpression)} ${node.operator};`;

case 'EmitStatement':
Expand Down
39 changes: 39 additions & 0 deletions test/contracts/Booleans-public.zol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: CC0

pragma solidity ^0.8.0;

contract Assign {

secret bool private a;
secret bool private c;
bool public d;
bool public g;


function add( secret uint256 value, secret bool value_bool, bool value_publicbool) public {
secret bool l = true;
bool m = false;
c = a && m && d;
if(value > 10 && !c) {
c=true;
a= value_bool && value_publicbool;
}
if( value < 10) {
a =!c;
c= l || a || m;
}
}

function addPublic(uint256 value, bool value_publicbool) public {
if (value > 10) {
d = true;
g = value_publicbool;
}
if (value < 10) {
d = false;
g = !value_publicbool;
}
}


}

0 comments on commit c23bf1a

Please sign in to comment.