Given the following contract:
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
contract InnerContract {
uint256 public innerConstructedStartTokenId;
constructor() {
innerConstructedStartTokenId = _startTokenId();
}
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
}
contract Test is InnerContract {
uint256 public START_TOKEN_ID = 1;
constructor() InnerContract() {
}
function _startTokenId() internal view virtual override returns (uint256) {
return START_TOKEN_ID;
}
}
The return value of the function innerConstructedStartTokenId of the contract Test is 0, although it should be 1.
This issue disappears when return START_TOKEN_ID; is replaced with return 1;.
It seems that this is due to the YUL inliner that violates the order of statements.
Given the following contract:
The return value of the function
innerConstructedStartTokenIdof the contractTestis 0, although it should be 1.This issue disappears when
return START_TOKEN_ID;is replaced withreturn 1;.It seems that this is due to the YUL inliner that violates the order of statements.