dappuniversity / election

A Decentralized Ethereum Voting Application Tutorial
563 stars 506 forks source link

truffle compile error #42

Open kaitojas opened 4 years ago

kaitojas commented 4 years ago

I got a compile error when i compile election.sol, it show's like this

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

/home/js/election/contracts/Election.sol:24: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). ,/home/js/election/contracts/Migrations.sol:11:3: 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 Migrations() { ^ (Relevant source part starts here and spans across multiple lines). ,/home/js/election/contracts/Migrations.sol:11:3: SyntaxError: No visibility specified. Did you intend to add "public"? function Migrations() { ^ (Relevant source part starts here and spans across multiple lines). ,/home/js/election/contracts/Migrations.sol:15:3: SyntaxError: No visibility specified. Did you intend to add "public"? function setCompleted(uint completed) restricted { ^ (Relevant source part starts here and spans across multiple lines). ,/home/js/election/contracts/Migrations.sol:19:3: SyntaxError: No visibility specified. Did you intend to add "public"? function upgrade(address new_address) restricted { ^ (Relevant source part starts here and spans across multiple lines). ,/home/js/election/contracts/Election.sol:29:28: TypeError: Data location must be "storage" or "memory" for parameter in function, but none was given. function addCandidate (string _name) private { ^----------^

Maniddarky commented 3 years ago

put function addCandidate (string memory _name) private {