You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
This is a critical compiler bug, Ergo expansion does not handle the name of parameters in clauses correctly.
This can be seen easily when executing a template in Cicero. For:
contract IOUContract over IOUContractModel {
clause verify(request : IOURequest) : Response {
// IOU-sepcific contraints
enforce contract.lender != contract.borrower
else throw ErgoErrorResponse{ message: "The lender and the borrower cannot be the same entity." };
enforce request.value > 0.0
else throw ErgoErrorResponse{ message: "The IOU's value must be non-negative." };
return Response{}
}
}
You get the expected result:
bash-3.2$ cicero execute
11:15:39 - info: Using current directory as template folder
11:15:39 - info: Loading a default sample.txt file.
11:15:39 - info: Loading a single default request.json file.
11:15:39 - info: Loading a default state.json file.
11:15:40 - info: Compiling Ergo logic
11:15:40 - info:
{
"clause": "corda-iou@0.0.0-b08d8a3de8d0e3836fb2fca95a287c081f5dfac0499151e5a51de1e4a3d7871c",
"request": {
"$class": "org.accordproject.sample.corda.iou.IOURequest",
"value": 10
},
"response": {
"$class": "org.accordproject.cicero.runtime.Response",
"transactionId": "4106a771-4095-4ff2-b224-cf636402c8d1",
"timestamp": "2018-09-17T15:15:40.611Z"
},
"state": {
"$class": "org.accordproject.cicero.contract.AccordContractState",
"stateId": "1"
},
"emit": []
}
But if you change the name of the parameter (e.g., from request to tx):
contract IOUContract over IOUContractModel {
clause verify(tx : IOURequest) : Response {
// IOU-sepcific contraints
enforce contract.lender != contract.borrower
else throw ErgoErrorResponse{ message: "The lender and the borrower cannot be the same entity." };
enforce tx.value > 0.0
else throw ErgoErrorResponse{ message: "The IOU's value must be non-negative." };
return Response{}
}
}
The compiler generates wrong code which does not execute properly:
bash-3.2$ cicero execute
11:16:35 - info: Using current directory as template folder
11:16:35 - info: Loading a default sample.txt file.
11:16:35 - info: Loading a single default request.json file.
11:16:35 - info: Loading a default state.json file.
11:16:35 - info: Compiling Ergo logic
11:16:36 - error: undefined
11:16:36 - info: undefined
The text was updated successfully, but these errors were encountered:
This is a critical compiler bug, Ergo expansion does not handle the name of parameters in clauses correctly.
This can be seen easily when executing a template in Cicero. For:
You get the expected result:
But if you change the name of the parameter (e.g., from
request
totx
):The compiler generates wrong code which does not execute properly:
The text was updated successfully, but these errors were encountered: