0

I am getting some errors related to bytes32. I tried to use the casting but it is not solving the proble. 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

My error messages are:

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.

0
m_pendingIndex[_operation] . length ++

That variable is bytes32 as defined here:

bytes32 [] m_pendingIndex ; 

As such, it is 32 bytes long and the length cannot the adjusted. You seem to be trying to increase it but that is not possible.

Hope it helps.

2
  • Sorry I am still getting the same errors: >solc prg46.sol prg46.sol:14:38: Error: bytes32 is not implicitly convertible to uint256. pending.pendingOp = m_pendingIndex [ _operation ]; ^--------^ :18:35: Error: bytes32 is not implicitly convertible to uint256. pending . index = m_pendingIndex[_operation] . length ; ^--------^ 18:20: Error: uint8 is not implicitly convertible to bytes32. pending . index = m_pendingIndex[_operation] . length ; ^---------------------------------^ – zak100 Mar 26 at 22:10
  • I removed the '++' from m_pendingIndex[_operation] . length ++, but still I am getting the same errors as shown above. – zak100 Mar 26 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.