1

I am trying to execute a contract provided as a tutorial for Remix at the following link: https://gangachris.com/posts/a-look-into-remix-ide/ The contract is:

 pragma solidity ^0.4.20;

contract Cars{
   struct Car{
      bytes32 make;
      unint year;
   }

   mapping(address => Car[]) public carOwners;

   function registerCar(bytes32 _make, uint r) public {
      carOwners[msg.sender].push(Car({ make: _make,
                                       year: yr}));
   }
   function changeOwnership(address toOwner, uint index) public returns (bool){
      if(carOwners[msg.sender].length == 0) {
         return false;
      }
      if(carOwners[msg.sender].length > index + 1) {
         return false;
      }
      carOwners[toOwner].push(carOwners[msg.sender][index]);
    }
    function getCarMake(address owner, uint index) public view returns (bytes32 carMake) {
       if(carOwners[owner].length == 0) {
          return;
       }
       if(carOwners[owner].length > index + 1){
          return;
       }
       carMake = carOwners[owner][index].make;
     }
}

I found by search that it’s a Remix problem and not associated with Solidity. Some body please guide me.

Zulfi.

6
  • 1
    what is the error you get? how do you try to access it? what function are you calling? Nov 4, 2018 at 19:59
  • After fixing two obvious typos with your code ("unint" and "r" variable) it compiles just fine in Remix. Nov 4, 2018 at 20:02
  • 1
    This code doesn't compile because of a couple typos. Once those are fixed, the static analysis warning you mentioned does appear. It's safe to ignore, but I'm not sure why it appears. (Those functions cannot be marked constant/view.)
    – user19510
    Nov 4, 2018 at 20:03
  • Perhaps the Solidity compiler's understanding of push is poor? If you're interested in doing so, I would recommend filing an issue in the Solidity repo on GitHub.
    – user19510
    Nov 4, 2018 at 20:04
  • 1
    Correction: the static analysis seems to come directly from Remix (github.com/ethereum/remix/blob/…). If you're interested, file an issue there.
    – user19510
    Nov 4, 2018 at 20:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.