SIF
SIF copied to clipboard
terminate called after throwing an instance of 'nlohmann::detail::out_of_range'
Hi, I tried running "sif -a test.ast -j test.json" and get error below: terminate called after throwing an instance of 'nlohmann::detail::out_of_range' what(): [json.exception.out_of_range.403] key 'isConstructor' not found Aborted (core dumped)
The solc version is 0.5.0. (Source code)
pragma solidity >=0.4.24 <0.6.0;
contract Simple {
constructor () public {
}
function f(uint a) payable public {
if (a == 65) {
revert();
}
}
}
Could you kindly help me figure this out?
This is due to the incompatibility of Solidity compilers. The "isConstructor" keyword no longer exists from solc 5 onwards. You can try to produce the AST using solc 0.4.25.
In the meantime, we are working on supporting solc 5.
Here's a workaround of this problem on macOS:
Step 1: Install [email protected]:
Since solc v0.4.x does not work with boost 1.7, I encountered this problem. you'll need to instal boost 1.6. However, brew refused to install [email protected] because it's an old unsupported version. To install boost 1.6x, you'll need to use an external tap [1].
Use the following commands to add the repo of [email protected] in your brew tap:
brew tap bitshares/homebrew-boost https://github.com/bitshares/homebrew-boost.git
brew style --fix /usr/local/Homebrew/Library/Taps/bitshares/homebrew-boost/Formula/
Verify the installation using the brew search
command, and it should list the formula bitshares/boost/[email protected]
as shown below:
~> brew search [email protected]
==> Formulae
bitshares/boost/[email protected]
Install [email protected]:
brew install [email protected]
Step 2: Change the dependency of [email protected] :
We need to do a hack in .rb file of solidity@4:
[email protected] is in /usr/local/Homebrew/Library/Taps/ethereum/homebrew-ethereum/[email protected]
.
Open it with a text editor and change the the line depends_on "boost" => "1.60"
to depends_on "[email protected]"
Step 3: Install solidity@4:
brew install solidity@4
Verify your installation:
SIF> solc --version
solc, the solidity compiler commandline interface
Version: 0.4.26+commit.4563c3fc.Darwin.appleclang
SIF>
SIF appears to work fine with solc v0.4.26 using the contract below:
pragma solidity ^0.4.26;
contract MyContract {
uint value;
function getValue() external view returns (uint) {
return value;
}
}
[1]. https://github.com/bitshares/bitshares-core/pull/2254