Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Integer literal bug #484

Closed
jeromesimeon opened this issue Dec 13, 2018 · 2 comments
Closed

Integer literal bug #484

jeromesimeon opened this issue Dec 13, 2018 · 2 comments

Comments

@jeromesimeon
Copy link
Member

The JavaScript code generation for integer literals is wrong.

This can be seen on the following unit test.
integertest.zip

To test:

bash-3.2$ ergorun ./model.cto ./logic.ergo --contractname org.accordproject.integertest.IntegerTest --contract ./contract.json --request ./request.json --state ./state.json 
12:34:47 - info:
{
  "response": {
    "test1": {
      "nat": 0
    },
    "test2": 0,
    "test3": 0,
    "$class": "org.accordproject.integertest.Response"
  },
  "state": {
    "$class": "org.accordproject.cicero.contract.AccordContractState",
    "stateId": "1"
  },
  "emit": []
}

Note the:

    "test1": {
      "nat": 0
    },

has an extraneous nat field.

@jeromesimeon
Copy link
Member Author

The issue can be seen on the generated JavaScript code:

bash-3.2$ ergoc ./model.cto ./logic.ergo 
Compiling Ergo './logic.ergo' -- creating './logic.js'

line 43 of the compiled logic.js:

      res2 = {"left" : concat(concat({"response": brand(["org.accordproject.integertest.Response"],concat(concat({"test1": {"nat": 0.0}}, {"test2": natPlus({"nat": 0.0}, {"nat": 0.0})}), {"test3": Math.trunc(vp1)}))}, {"state": vlstate}), {"emit": vlemit})};

shows the extraneous nat fields which are inconsistent with the serialization expected by JSON data validated with Concerto.

jeromesimeon added a commit to jeromesimeon/ergo that referenced this issue Dec 14, 2018
jeromesimeon added a commit that referenced this issue Dec 14, 2018
@jeromesimeon
Copy link
Member Author

Fixed in PR #486

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant