Compilation Errors with bytes32 data type

Hi,
I am trying to compile the following Solidity program but getting incompatibility issues with bytes32.

My code is:

pragma solidity ^0.5.6.0;
contract peInKSub{
   bytes32 [] m_pendingIndex ;
   struct pendingConfirmation{
   bytes32 index;
   uint yetNeeded;
   bytes32 pendingOp;
}
pendingConfirmation pending;
function confirmAndCheck ( bytes32 _operation )public returns ( bool ) {
   pending.pendingOp = m_pendingIndex [ _operation ];
   // if we 're not yet working on this operation ,
   // switch over and reset the confirmation status .
   if ( pending . yetNeeded == 0) {
      pending . index = m_pendingIndex[_operation] . length ++;
      //m_pendingIndex [ pending . index ] = _operation ;
   }//if
}//fun
}//contract

I am getting following error messages:

solc prg46.sol
prg46.sol:14:38: Error: Type bytes32 is not implicitly convertible to expected type uint256.
pending.pendingOp = m_pendingIndex [ _operation ];
^--------^
prg46.sol:18:35: Error: Type bytes32 is not implicitly convertible to expected type uint256.
pending . index = m_pendingIndex[_operation] . length ++;
^--------^
prg46.sol:18:20: Error: Expression has to be an lvalue.
pending . index = m_pendingIndex[_operation] . length ++;
^---------------------------------^
prg46.sol:18:20: Error: Type uint8 is not implicitly convertible to expected type bytes32.
pending . index = m_pendingIndex[_operation] . length ++;

Somebody please guide me.

Zulfi.

1 Like

Hey, just like you wrote bytes32 [] m_pendingIndex ; so m_pendingIndex is an array, so you need to pass an index, such as 1 or 2.
BTW, I think you should pay attention to the type of the variables.

1 Like

Hi,
Thanks for your response. I got it from a paper. I tried different options but they did not work like type casting. You can consider it as an array of indexes. It was not a complete contract. I don’t know how to fix it. Please guide me.

Zulfi.

1 Like