itemisCREATE / solidity-ide

Solidity plugin for Eclipse
Eclipse Public License 1.0
86 stars 25 forks source link

Adding receive und fallback functions to the grammar #325

Closed jthoene closed 4 years ago

jthoene commented 4 years ago

With version 0.6 the fallback function was splitted into a receive and a fallback function which are currently not supported by our grammar.

Example receive function:

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;

// This contract keeps all Ether sent to it with no way
// to get it back.
contract Sink {
    event Received(address, uint);
    receive() external payable {
        emit Received(msg.sender, msg.value);
    }
}

Example fallback function:

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.7.0;

contract Test {
    // This function is called for all messages sent to
    // this contract (there is no other function).
    // Sending Ether to this contract will cause an exception,
    // because the fallback function does not have the `payable`
    // modifier.
    fallback() external { x = 1; }
    uint x;
}