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

Replace invalid opcode by Panic() #9995

Closed
chriseth opened this issue Oct 8, 2020 · 3 comments
Closed

Replace invalid opcode by Panic() #9995

chriseth opened this issue Oct 8, 2020 · 3 comments
Labels
language design :rage4: Any changes to the language, e.g. new features

Comments

@chriseth
Copy link
Contributor

chriseth commented Oct 8, 2020

The following situations currently create an invalid opcode or a Panic in the future:

  • failing assert()
  • arithmetic overflow in addition, multiplication, exponentation, negation, ...
  • arithmetic underflow in addition, multiplication, exponentation, negation, ...
  • division / modulo by zero
  • array too large (either storage or memory)
  • memory allocation error (too much memory required for something)
  • empty array pop
  • array out of bounds access
  • enum conversion error
  • calling invalid internal function

Note that the old code-generator still contains code that uses "invalid opcode".

Suggestions for how to assign error codes:

  • 0: generic / unspecified error. Used by assert().
  • 0x11: arithmetic underflow or overflow
  • 0x12: division or modulo by zero
  • 0x21: enum conversion error
  • 0x31: empty array pop
  • 0x32: array out of bounds access
  • 0x41: resource error (too large allocation or too large array)
  • 0x51: calling invalid internal function
@cameel cameel added feature language design :rage4: Any changes to the language, e.g. new features labels Oct 8, 2020
@chriseth
Copy link
Contributor Author

chriseth commented Oct 8, 2020

Replaced by a comment in the other issue: #9824 (comment)

@chriseth chriseth closed this as completed Oct 8, 2020
@ekpyron
Copy link
Member

ekpyron commented Oct 8, 2020

I wonder whether we should be more generous and at least use 16 bits for it and reserve 256 slots in each category or even more... it's not like we don't have enough space in the uint256...

@ekpyron
Copy link
Member

ekpyron commented Oct 8, 2020

Ah, damn, now you moved the discussion :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language design :rage4: Any changes to the language, e.g. new features
Projects
None yet
Development

No branches or pull requests

3 participants