IR, code within modifiers seem to always appear at the end of functions.
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
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();
}
}
```
And this is the result from IR.
```
Function RequireExample.test(uint256,bool)
Expression: requireb()
IRs:
INTERNAL_CALL, RequireExample.requireb()()
Expression: checka()
IRs:
INTERNAL_CALL, RequireExample.checka()()
Modifier Call None
```
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?
Contributor guide
Assessment
This issue has not been assessed yet.