How to fix “Compilation failed” error in smart contract deployment?

PS D:\election> truffle migrate

Compiling .\contracts\Election.sol...

Compiling .\contracts\Migrations.sol...

Compilation warnings encountered:

/D/election/contracts/Election.sol:8:5: Warning: This declaration shadows an existing declaration. function Election () public { ^ (Relevant source part starts here and spans across multiple lines). /D/election/contracts/Election.sol:3:1: The shadowed declaration is here: contract Election { ^ (Relevant source part starts here and spans across multiple lines).

/D/election/contracts/Election.sol:8:5: SyntaxError: Functions are not allowed to have the same name as the contract. If you intend this to be a constructor, use "constructor(...) { ... }" to define it. function Election () public { ^ (Relevant source part starts here and spans across multiple lines). ,/D/election/contracts/Election.sol:8:5: Warning: This declaration shadows an existing declaration. function Election () public { ^ (Relevant source part starts here and spans across multiple lines). /D/election/contracts/Election.sol:3:1: The shadowed declaration is here: contract Election { ^ (Relevant source part starts here and spans across multiple lines).

Compilation failed. See above.

Truffle v5.0.3 (core: 5.0.3) Node v8.12.0

#blockchain

5 Likes21.10 GEEK