title: solidity : error information Source file requires different compiler version
body: <p>When compiling the lottery.sol, met this compiler error,
  as a rookie to development, didn't quite understand the error, what's the solution to solve this compiler version issue, it's really frustrating...</p>
  <pre><code>Compiling contracts...
    Solc version: 0.6.12
    Optimizer: Enabled  Runs: 200
    EVM Version: Istanbul
  CompilerError: solc returned the following errors:
  
  /Users/liwei/.brownie/packages/smartcontractkit/chainlink-brownie-contracts@1.1.1/contracts/src/v0.6/vendor/SafeMathChainlink.sol:2:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
  pragma solidity &gt;=0.7.0 &lt;0.9.0;
  </code></pre>
  <p>lottery.sol</p>
  <pre><code>// SPDX-License-Identifier:MIT
  pragma solidity ^0.6.0;
  
  import &quot;@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol&quot;;
  import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;
  import &quot;@chainlink/contracts/src/v0.6/VRFConsumerBase.sol&quot;;
  import &quot;@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol&quot;;
  
  contract Lottery is VRFConsumerBase, Ownable {
      AggregatorV3Interface internal ethUsdPriceFeed;
      uint256 usdEntryFee;
      address[] public players;
      bytes32 internal keyHash; //public key to generate randomness,uniquely identify the chainlink node.
      uint256 internal fee;
      uint256 public randomness;
  
      enum LOTTERY_STATE {
          OPEN,
          CLOSED,
          CALCULATING_WINNER
      }
      LOTTERY_STATE public lottery_state;
  
      constructor(
          address _priceFeedAddress,
          address _VRFCoordinator, //contract to validate the random number
          address _link, //address to pay oracle gas
          uint256 _fee,
          bytes32 _keyhash
      ) public VRFConsumerBase(_vrfCoordinator, _link) {
          usdEntryFee = 50 * (10**18);
          ethUsdPriceFeed = AggregatorV3Interface(_priceFeedAddress);
          lottery_state = CLOSED;
          fee = _fee;
          keyhash = _keyhash;
      }
  
      function enter() public payable {
          require(lottery_state == OPEN);
          // require amount&gt;=entrance fee ($50 in Ether)
          require(msg.value &gt;= getEntranceFee(), &quot;Not enought ETH!&quot;);
          // push player's address into the the array
          players.push(msg.sender);
      }
  
      function getEntranceFee() public view returns (uint256) {
          (, int256 price, , , ) = ethUsdPriceFeed.latestRoundData();
          uint256 adjustedPrice = uint256(price) * (10**10); // 18 decimals
          // $50,$2,000 / ETH
          // 50/2,000
          // 50 *100000 / 20000
          uint256 costToEnter = (usdEntryFee * 10**18) / adjustedPrice; //usdEntryFee has additional 18 decimals
          return costToEnter;
      }
  
      function startLottery() public {
          require(lottery_state == CLOSED, &quot;Can't start a new lottery yet&quot;);
          lottery_state = LOTTERY_STATE.OPEN;
      }
  
      function endLottery() public {
          lottery_state = LOTTERY_STATE.CLOSED;
          require(
              LINK.balanceOf(address(this)) &gt;= fee,
              &quot;Not enough LINK - fill contract with faucet&quot;
          );
          bytes32 requestId = requestRandomness(keyHash, fee); // make the inital request for randomness
      }
  
      function fulfillRandomness(bytes32 _requestId, uint256 _randomness)
          internal
          override
      {
          require(
              lottery_state == LOTTERY_STATE.CALCULATING_WINNER,
              &quot;You are n't there yet !&quot;
          );
          require(_randomness &gt; 0, &quot;radnom-not-found !&quot;);
          uint256 indexOfWinner = _radonmness % players.length; // get the remainder,Modulo pattern
          recentWinner = players[indexOfWinner];
          rencentWinner.tranfer(address(this).balance);
  
          // reset the players array
  
          players = new address payable[](0);
          lottery_state = LOTTERY_STATE.CLOSED;
          randomness = _randomness;
      }
  }
  </code></pre>
  <p>After changing the compiler version as the error information suggested, it suggested switching the compiler version back.</p>
  <pre><code>New compatible solc version available: 0.8.11
  Compiling contracts...
    Solc version: 0.8.11
    Optimizer: Enabled  Runs: 200
    EVM Version: Istanbul
  CompilerError: solc returned the following errors:
  
  ParserError: Source file requires different compiler version (current compiler is 0.8.11+commit.d7f03943.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
   --&gt; /Users/liwei/.brownie/packages/OpenZeppelin/openzeppelin-contracts@3.4.0/contracts/access/Ownable.sol:3:1:
    |
  3 | pragma solidity &gt;=0.6.0 &lt;0.8.0;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  
  ParserError: Source file requires different compiler version (current compiler is 0.8.11+commit.d7f03943.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
   --&gt; /Users/liwei/.brownie/packages/smartcontractkit/chainlink-brownie-contracts@1.1.1/contracts/src/v0.6/VRFConsumerBase.sol:2:1:
    |
  2 | pragma solidity ^0.6.0;
    | ^^^^^^^^^^^^^^^^^^^^^^^
  
  (base) liwei@liweideMacBook-Pro smartcontract-lottery2022 % 
  </code></pre>