4

Enum's are not working in solc? Just tried to compile demo contract from gihub documentation :

contract test {
  enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill };
  function test()
  {
     choices = ActionChoices.GoStraight;
  }
  function getChoice() returns (uint d)
  {
     d = uint256(choices);
  }
  ActionChoices choices;
}

And getting error:

Error: Function, variable, struct or modifier declaration expected.
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill };

1 Answer 1

5

seems that if semicolon is removed, it works. Contract should look like:

contract test {
  enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
  function test()
  {
     choices = ActionChoices.GoStraight;
  }
  function getChoice() returns (uint d)
  {
      d = uint256(choices);
  }
  ActionChoices choices;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.