current position:Home>VM error : Invalid opcode. How to solve it

VM error : Invalid opcode. How to solve it

2022-02-03 23:13:39 Q & A of Denglian community

When writing the contract, I encountered this problem as the title , I can't find the problem myself , I'd like to ask how to solve

 function Shapley_A1_VS_rest() public view returns (uint[] memory m){        uint len;        uint temp=0;        uint temp_VS;        uint temp_VS_A1;        for(len=0;len<VS_A1.length;len++){            temp_VS=VS[len];            temp_VS_A1=VS_A1[len];            temp=temp_VS-temp_VS_A1;            VS_A1_rest.push(temp);        }        m =  new uint[](VS_A1_rest.length);        for(uint i = 0; i < VS_A1_rest.length; i++){            m[i] = VS_A1_rest[i];        }    }

Take the answer 1:

This hint is usually that the array access exceeds the length .

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.

Random recommended