Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solidity compiler error in VS Code #188

Closed
Killpit opened this issue Aug 10, 2020 · 1 comment
Closed

Solidity compiler error in VS Code #188

Killpit opened this issue Aug 10, 2020 · 1 comment

Comments

@Killpit
Copy link

Killpit commented Aug 10, 2020

I have the latest MacOS version and I have solidity compiler downloaded on my terminal (0.5.16+) and the text editor itself shows that it can support 0.4.17+ version. When I mention the latest version but it gives me the mistake that it is not supported. I've never encountered this mistake before and written codes in solidity 0.6.9

Error:

{ "resource": "/Users/atatekeli/Desktop/Programlama Dilleri/ETH Solidity/web3js/Hello.sol", "owner": "generated_diagnostic_collection_name#1", "severity": 8, "message": "/Users/atatekeli/Desktop/Programlama Dilleri/ETH Solidity/web3js/Hello.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.4.17+commit.bdeb9e52.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version\npragma solidity ^0.7.0;\n^---------------------^\n", "startLineNumber": 1, "startColumn": 2, "endLineNumber": 1, "endColumn": 2 }

{ "resource": "/Users/atatekeli/Desktop/Programlama Dilleri/ETH Solidity/web3js/Hello.sol", "owner": "generated_diagnostic_collection_name#0", "severity": 8, "message": "Source file requires different compiler version (current compiler is 0.4.17+commit.bdeb9e52.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version", "source": "solc", "startLineNumber": 1, "startColumn": 1, "endLineNumber": 1, "endColumn": 24 }

These texts are being shared for you guys to evaluate what's going wrong. All help will be appreciated

Here's the source code

pragma solidity ^0.6.9;

contract Voting{

struct Voters{
uint weight;
bool hasVoted;
}

struct Candidates{
string name;
uint voteCount;
}

mapping(address => Voters) voters; // voters[addres] = Voters
Candidates[] public candidatesList;
address public owner;

constructor(string memory _candidate1, string memory _candidate2, string  memory _candidate3)public{
    candidatesList.push(Candidates({name : _candidate1,voteCount : 0}));
    candidatesList.push(Candidates({name : _candidate2,voteCount : 0}));
    candidatesList.push(Candidates({name : _candidate3,voteCount : 0}));

    owner = msg.sender;
}

function authorizeVoter(address _address) public {
    require(msg.sender == owner);
    require(!voters[_address].hasVoted);

    voters[_address] = Voters({weight : 1, hasVoted : false});
}


function voteForCandidate(uint _index) public{
    candidatesList[_index].voteCount = candidatesList[_index].voteCount + voters[msg.sender].weight;
    if(voters[msg.sender].weight > 0){
        voters[msg.sender].weight = 0;
        voters[msg.sender].hasVoted = true;
    }
}

function getVoteForCandidate(uint _index) public view returns(uint){
    return candidatesList[_index].voteCount;
}

function getAllCandidatesWithVotes() public view returns (string memory, uint, string memory, uint, string memory, uint){
  return(candidatesList[0].name, candidatesList[0].voteCount,
    candidatesList[1].name, candidatesList[1].voteCount,
    candidatesList[2].name, candidatesList[2].voteCount);
}

}

@juanfranblanco
Copy link
Owner

juanfranblanco commented Aug 10, 2020

Hi @Killpit just use the context menu to put the latest as follows:

image
image

The plugin will not pick up your terminal installation, check the readme for further options. But this will solve most of your problems. Note the difference between workspace (your current project) and global (all the vscode solidity projects)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants