-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Overview
Currently in starlight in the contracts, the only returns are the ones at the end. However, we should support that some functions return early.
Tasks
Describe which contracts are affected
// SPDX-License-Identifier: CC0
pragma solidity ^0.8.0;
contract Assign {
secret uint256 private a;
uint256 private b;
function add( uint256 value) public returns (uint256, uint256) {
if (value < 5) {
return (2,3);
}
encrypt unknown a += value;
return (1, 5);
}
function remove(secret uint256 value, uint256 value1) public returns (uint256, uint256) {
b += value1;
a -= value;
return (b, a);
}
}
Describe the bug that should be fixed
For the above contract, in the Shield contract we get: if (value < 5) {}
This is because in the code generator toContract, an empty string is output for a node that has nodeType return. The returns are handled separately in the FunctionDefinition node, but this is only captures returns at the end of the function.
Definition of done
When is this task complete?
The above function should have the correct logic captured in the shield contract and work successfully on testing.