Home > Enterprise >  UnimplementedFeatureError: Copying of type struct
UnimplementedFeatureError: Copying of type struct

Time:08-12

I want to create the array variables that fill with the struct that I've created and unfortunately, I got the error. The error said that:

UnimplementedFeatureError: Copying of type struct Test.IncrementalPrice memory[2] memory to storage not yet supported.

Does anybody know what's wrong and how to fix this?

   contract Test {

     struct IncrementalPrice{
        uint256 prices;
        uint256 threshold;
     }

     IncrementalPrice[] price = [
        IncrementalPrice(0, 1000),
        IncrementalPrice(0.01 ether, 2000)
     ];
   }

CodePudding user response:

Hey first of all your make sure you code run in function or constructors

function setData() public {
  IncrementalPrice[] price = [
    IncrementalPrice(0, 1000),
    IncrementalPrice(0.01, 2000)
 ];

}

and you define your price var as int 256 so change

IncrementalPrice(0.01 ether, 2000)

to

IncrementalPrice(0.01, 2000)

Second, check your solidity version, solidity is a new language and changes very quickly, make sure you are using the latest version.

  • Related