0

Can someone please help me understand why this smart contract compiles in ReMix?

What is the purpose of the word constant if it doesn't preclude the code from changing the state? I'm looking for a technical answer that explains why Solidity allows this, not just says "that's the way it is."

pragma solidity ^0.4.9;

contract ShouldNotCompile {
    address addr;
    function getSender() constant returns (address) {
        addr = msg.sender;
        return addr;
    }
}
Thomas Jay Rush
  • 9,943
  • 4
  • 31
  • 72

1 Answers1

0

As documentation states, enforcement of constant is simply not (yet?) implemented. It seems weird for me as well, I suppose, the devs just think this issue is of a lower priority.

Sergei Tikhomirov
  • 1,062
  • 8
  • 21
  • You're correct. This question also seems to be a duplicate of https://ethereum.stackexchange.com/questions/3029/does-soliditys-constant-keyword-do-anything –  Aug 02 '17 at 12:20