Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
  function CappedCrowdsale(uint256 _cap) public {
  ^ (Relevant source part starts here and spans across multiple lines).
 not valid for functions.oc tag @dev
Compilation failed. See above.

I got this same exact error when my token contract was not using the new constructor() convention.

What is odd, is after I switch the token contract to the new convention, the compiler was happy. The next day it did the same thing, broke and complained about my crowdsale contract not using the new convention. (weird it didn't complain about this the day before) This was last week. I resolved the issue by switching to constructor().

Now I did a git pull on my laptop to continue work today, and now it's not happy with the constructor call made to the inherited contract, CappedCrowdsale.

function CappedCrowdsale(uint256 _cap) public { ^ (Relevant source part 
starts here and spans across multiple lines).
    not valid for functions.oc tag @dev

Googling has not turned up anything helpful. And troubleshooting on my own has not turned up any positive outcomes. I'm not 100% sure the constructor convention causing this error as it's only deprecated. But perhaps something related around that?

not valid for functions.oc tag @dev Compilation failed. See above. - leaves me clueless

Edit: I've restarted my computer and now compile doesn't give any warning about the constructor convention. Only the 1 liner error above. Last week this occurred on my desktop. Today is on my laptop.

Edit x2: Narrow down the issue to the laptop. Same code base is working without issue on my desktop. Perhaps something needs updated/reinstalled? Will update when I figure it out. The warnings are separate, nonrelated, to the compile failure.

  • 1
    The constructor message is just a warning, the code should continue to work. The message about CappedCrowdsale is incomplete, add a few lines before it where more information should appear. Difference between desktop and laptop might be different solc versions.
    – Ismael
    Jun 7, 2018 at 12:25
  • The code does not work as I get Compilation failed. See above (I forgot to include that line on the very bottom - just now fixed). Solc versions are the same as it gets pulled from the package.json file in the tooling setup and there are no global instances installed via NPM. Jun 7, 2018 at 15:14
  • 1
    Are you on windows? Did you try to compile on linux? I remember having an issue with @dev tags on windows. For some reason tags cannot be by themselves at the end of a line, ie // @dev will fail but // @dev Dummy will work. This also happened with other tags like @title etc. This issue appears to be unrelated to the warnings.
    – Ismael
    Jun 7, 2018 at 16:50
  • 1
    Correct I'm on windows. I've had the same issue as you with no characters trailing @dev before as well. I do agree that the warnings and compile issues are unrelated as well. I've narrowed this down to the laptop; as the same project works without issue on my desktop. i will to try narrow down exactly what is breaking on my laptop and update here if I find the solution. Jun 7, 2018 at 22:31
  • Same project - still the same result. Tried removing and adding solc & truffle via yarn. Tried deleting the repo and cloning again. Did a NPM list -g -depth=0 to see global instances - none related solidity. Works on my desktop without issue though. Very odd. Sep 12, 2018 at 19:52

1 Answer 1


@dev & @title tags need trailing characters. As stated by Ismael

Breaks: @dev

Works: @dev constructor

The odd thing I haven't figured out, yet, is the difference between both my machines. Both being Windows 10. My laptop is the that throws the error. My desktop does not.

Your Answer

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

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