Skip to content

Commit

Permalink
fix: handle nested forloops codegeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
dwebchapey committed Aug 12, 2022
1 parent e56e050 commit 87d9e8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/codeGenerators/orchestration/nodejs/toOrchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default function codeGenerator(node: any, options: any = {}): any {
let condition = `${node.condition.leftExpression.name} ${node.condition.operator} ${node.condition.rightExpression.value};`
let loopExpression = ` ${node.loopExpression.expression.rightHandSide.subExpression.name} ${node.loopExpression.expression.rightHandSide.operator}`;
let loopBody;
if ( !!node.body.statements[0] && node.body.statements[0].nodeType == 'IfStatement')
if ( !!node.body.statements[0] && (node.body.statements[0].nodeType == 'IfStatement' || node.body.statements[0].nodeType == 'ForStatement'))
loopBody = `${codeGenerator(node.body)}`;
else
loopBody = `${codeGenerator(node.body.statements.statements)}
Expand Down
8 changes: 4 additions & 4 deletions test/contracts/for-for.zol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ pragma solidity ^0.8.0;

contract Test {

secret uint private z;
secret uint256 private z;

function add(uint j) public {
uint i;
uint k;
function add(uint256 j) public {
uint256 i;
uint256 k;
for(i =0 ; i<5 ; i++) {
for(k=0; k<2; k++) {
z += j;
Expand Down

0 comments on commit 87d9e8a

Please sign in to comment.