[Ethereum] Expected identifier, got ‘LParen’

contract-developmentsoliditytruffletruffle-contract

I try using IterableMapping by this example.
I have error when I compiling contract by truffle:

Expected identifier, got 'LParen'

This is my code:

pragma solidity ^0.4.15;

import "./itMapsLib.sol";

contract User
{
  using itMaps for itMaps.itMapUintAddress;

  itMaps.itMapAddressUint im_myAddressUintMap;

 function addOwner(address _key, uint value) returns (bool){
   im_myAddressUintMap.insert(_key, value);
   return true;
 }

  function allSum() returns (uint sum) 
  { 
  }
}

enter image description here

Best Answer

There is several problems with your code.

You copy paste the function prototype instead of calling it you should use im_myAddressUintMap.insert( key, value);

And you have to make this insert inside a function or inside the constructor ( function with the name of the contract )

function insert( address key, uint value ) public {
    im_myAddressUintMap.insert( key, value );
}

so the contract should be something like this

second import is to test on remix

pragma solidity ^0.4.15;

import "./itMapsLib.sol";  
//import "https://github.com/szerintedmi/solidity-itMapsLib/itMapsLib.sol";    

contract User
{
  using itMaps for itMaps.itMapAddressUint;

  itMaps.itMapAddressUint im_myAddressUintMap;

  function insert ( address key, uint value) public {
    im_myAddressUintMap.insert( key, value);
  }
}

Edit : you edited your contract. The last error you have is the incorrect import of using itMaps for itMaps.itMapUintAddress; you're using itMapAddressUint

Related Topic