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
Before 0.6, the so-called fallback function (which I'll call anonymous here to avoid confusion) was the only mechanism for handling calls for functions that didn't exist:
function () external payable {}
In 0.6, the anonymous function doesn't exist anymore, and it's replaced by the fallback and receive functions:
Not sure about the correct API here. My suggestion would be to have properties like isAnonymous, isFallbackKeyword and isReceiveKeyword (with better names).
A problem here is that the FunctionDefinition already has a lot of properties, and adding these three will probably add some redundancy too. But my suggestion is to just add them, and then do a cleanup of the API in the next major version.
The text was updated successfully, but these errors were encountered:
This may be separate issue, but there also seems to be problem with 0.5.x contracts that use receive as a regular function name. Reported at eth-gas-reporter #196
This:
pragma solidity^0.5.0;
contractA {
function receive(addressfrom, uint256amount) public;
}
...crashes with
/Users/cgewecke/code/koba/node_modules/solidity-parser-diligence/dist/ASTBuilder.js:127
return this.visit(ctx.children[0]);
^
TypeError: Cannot read property '0' of null
at ASTBuilder.ContractPart (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:127:35)
at ASTBuilder.visit (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:1304:38)
at ASTBuilder.<anonymous> (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:1292:19)
at Array.map (<anonymous>)
at ASTBuilder.visit (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:1291:16)
at ASTBuilder.ContractDefinition (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:113:22)
at ASTBuilder.visit (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:1304:38)
at ASTBuilder.<anonymous> (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:1292:19)
at Array.map (<anonymous>)
at ASTBuilder.visit (node_modules/solidity-parser-diligence/dist/ASTBuilder.js:1291:16)
Just a side-note that Solidity AST node, that is produced by SolcJS compiler, has kind property, that corresponds to used keyword, like function, receive, fallback or constructor. Since Solidity 0.7.1 there is a freeFunction value also possible.
Before 0.6, the so-called fallback function (which I'll call anonymous here to avoid confusion) was the only mechanism for handling calls for functions that didn't exist:
In 0.6, the anonymous function doesn't exist anymore, and it's replaced by the
fallback
andreceive
functions:Right now the parser doesn't seem to give information about this, so in prettier-solidity we had to do something like this: prettier-solidity/prettier-plugin-solidity#244
Not sure about the correct API here. My suggestion would be to have properties like
isAnonymous
,isFallbackKeyword
andisReceiveKeyword
(with better names).A problem here is that the
FunctionDefinition
already has a lot of properties, and adding these three will probably add some redundancy too. But my suggestion is to just add them, and then do a cleanup of the API in the next major version.The text was updated successfully, but these errors were encountered: