Constructor syntax error in VSCode


Right after initiating a new project thanks to truffle init, I get the following error message for the constructor:

Syntax error: Expected ".", "[", "constant", "internal", "private", "public", comment, end of line, identifier, or whitespace but "(" found.

The weirdest thing is that I have an older project from 5 months ago, and there, the constructor is not highlighted at all.

I checked my .prettierrc, .eslintrc, .vscode/settings.json, my Solidity linter… Every single configuration is the same and I cannot explain why I got this new error.

Does anyone have an idea of why this is happening? Thanks!

[EDIT] I also get this error from a random other Test.sol:

[EDIT2] The issue is actually described here (even though it’s closed) and it’s still exactly what’s happening to me: constructor and emit cause misleading highlights:

1 Like

Solved it!
For some reason, the compiler thought I wanted to compile with version 0.4.17 even though I specified in truffle-config.js that I wanted to use the 0.6.4.
It turns out a global install of solc wasn’t enough, and I had to specifically npm install solc@0.6.4 in order to make it work locally.

1 Like

Hi @tnguyen42,

Well done on resolving!!

I assume that it was the compiler setting in the VSCode plugin:

1 Like