Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error assigning 0 to map value in Remix IDE. #2320

Closed
0xfps opened this issue Apr 18, 2022 · 2 comments
Closed

Error assigning 0 to map value in Remix IDE. #2320

0xfps opened this issue Apr 18, 2022 · 2 comments

Comments

@0xfps
Copy link

0xfps commented Apr 18, 2022

Description

OOG Error when trying to assign 0 to a struct value.

Environment

  • Compiler version: 0.8.7
  • Target EVM version (as per compiler settings): default
  • Framework/IDE (e.g. Truffle or Remix): Remix
  • EVM execution environment / backend / blockchain client:
  • Operating system: Windows

Out of Gas Error.

I do not know why the reset() function in the code below returns an OOG (Out Of Gas) error when being called after the start() function is called.

The value of the structs's val variable cannot be changed to 0, but is 0 on initialization.

Can this be fixed?

// SPDX-License-Identifier: MIT
pragma solidity >0.6.0;


contract A
{
    struct f
    {
        string name;
        uint val;
    }

    mapping(uint => f) private j;

    function start() public
    {
        j[1].val = 8;
    }

    function see() public view returns(uint)
    {
        return j[1].val;
    }

    function reset() public 
    {
        j[1].val = 0;         // OOG Error here.
    }
}
@0xfps 0xfps changed the title Error assigning 0 to map value in Remix IDE Error assigning 0 to map value in Remix IDE. Apr 18, 2022
@Aniket-Engg
Copy link
Collaborator

Hello @fps8k , Can you check it now? It should be fixed

@0xfps
Copy link
Author

0xfps commented Apr 19, 2022 via email

@0xfps 0xfps closed this as completed Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants