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

Remove redundant check from drop_operand #429

Merged
merged 1 commit into from
Jul 22, 2020
Merged

Remove redundant check from drop_operand #429

merged 1 commit into from
Jul 22, 2020

Conversation

gumb0
Copy link
Collaborator

@gumb0 gumb0 commented Jul 20, 2020

No description provided.

@@ -119,7 +119,7 @@ inline void drop_operand(
static_cast<int>(operand_stack.size()) < frame.parent_stack_height + 1)
throw validation_error{"stack underflow"};

if (frame.unreachable && static_cast<int>(operand_stack.size()) == frame.parent_stack_height)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was redundant, becase the case of reachable frame + stack equal to parent stack is eliminated by the stack underflow condition above.

In other words, by this point not having a value on stack is possible only if it's unreachable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not leave an assertion here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered assertion, but it just seems too obvious, because the previous check implies it's true.

"(frame unreachable OR no stack underflow) AND stack underflow" implies "frame unreachable".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if you read it carefully, but I think an assertion is much more explicit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will add an assertion.

@codecov
Copy link

codecov bot commented Jul 20, 2020

Codecov Report

Merging #429 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #429   +/-   ##
=======================================
  Coverage   99.32%   99.32%           
=======================================
  Files          50       50           
  Lines       13989    13992    +3     
=======================================
+ Hits        13894    13897    +3     
  Misses         95       95           

@gumb0 gumb0 requested review from chfast and axic July 21, 2020 08:43
@gumb0 gumb0 force-pushed the drop-operand-fix branch 3 times, most recently from c4de939 to 10b32f9 Compare July 22, 2020 13:42
@gumb0 gumb0 merged commit cb62d80 into master Jul 22, 2020
@gumb0 gumb0 deleted the drop-operand-fix branch July 22, 2020 14:03
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

Successfully merging this pull request may close these issues.

2 participants