Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

isConstructor() error in Initializable.sol #1440

Closed
elishadrion opened this issue Feb 7, 2020 · 2 comments
Closed

isConstructor() error in Initializable.sol #1440

elishadrion opened this issue Feb 7, 2020 · 2 comments

Comments

@elishadrion
Copy link

elishadrion commented Feb 7, 2020

Compiling or using the Initializable.sol isn't possible due to an error in the isConstructor() function. The function in question and the error are highlighted below ;

  /// @dev Returns true if and only if the function is running in the constructor
  function isConstructor() private view returns (bool) {
    // extcodesize checks the size of the code stored in an address, and
    // address returns the current address. Since the code is still not
    // deployed when running a constructor, any checks on its code size will
    // yield zero, making it an effective way to detect if a contract is
    // under construction or not.
    uint256 cs;
    assembly { cs := extcodesize(address) } <--
    return cs == 0;
  }

This is invalid in Solidity as in address is a reserved keyword.

Given the context, it seems it should be ;

    uint256 cs;
    address _addr = address(this);
    assembly { cs := extcodesize(_addr) }
    return cs == 0;
@frangio
Copy link
Contributor

frangio commented Feb 7, 2020

Thank you for reporting! This will be fixed in the 2.7 release.

@frangio
Copy link
Contributor

frangio commented Feb 7, 2020

It was fixed in #1413.

@frangio frangio closed this as completed Feb 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants