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
The code for the function being modified is inserted where the _ is placed in the modifier.
RequireExample.sol file:
pragma solidity ^0.5.11;
contract RequireExample {
address public owner;
constructor() public {
owner = msg.sender;
}
uint public number = 0;
bool public a = true;
bool public b = true;
bool public c = false;
bool public d = true;
modifier checka(){
c = true;
require(a);
_;
}
function requireb() public{
if (d){
d = false;
}
require(b);
}
function test(uint _n, bool _b) checka public {
requireb();
}
}
I'm not sure if the problem I'm seen is supposed to be like this.
Since the _; appeared at the end of the modifier, the code within the modifier should be added at the beginning of the function, right?
Otherwise, if modifiers are always placed at the end of the function, how do we know whether the modifier is doing pre-condition or post-condition checking?
The text was updated successfully, but these errors were encountered:
AnonymousMonkey2021
changed the title
IR, requires within modifiers seem to appear at the end.
IR, code within modifiers seem to always appear at the end of function.
Nov 18, 2019
AnonymousMonkey2021
changed the title
IR, code within modifiers seem to always appear at the end of function.
IR, code within modifiers seem to always appear at the end of functions.
Nov 18, 2019
Hi @JackHFeng. Thank you for your interest in Slither.
This is actually an output artifact.
Currently, Slither does not have a straightforward API to output properly the modfier's cfg into in the function using it (which requires some control-flow tricks to handle the _ placeholder). The modifiers calls are kept into function.modifiers_statements.
The IRs nodes generated by these calls are kept into a separate CFG. When the slithir printer outputs the information, it shows all the nodes without any order:
To get the pre-condition/post-condition, an analysis must iterate over the function.modifiers_statements, and properly extract them. There is a specific node type for the modifier's placeholder: NodeType.PLACEHOLDER.
We are working towards a better API to handle modifiers calls at the analysis level, but right now it's documentation is not up to date. Feel free to join our slack (#ethereum) if you want direct support on this API.
The code for the function being modified is inserted where the _ is placed in the modifier.
RequireExample.sol file:
And this is the result from IR.
I'm not sure if the problem I'm seen is supposed to be like this.
Since the _; appeared at the end of the modifier, the code within the modifier should be added at the beginning of the function, right?
Otherwise, if modifiers are always placed at the end of the function, how do we know whether the modifier is doing pre-condition or post-condition checking?
The text was updated successfully, but these errors were encountered: