shafu0x / evm-from-scratch-book

The EVM from scratch book
https://evm-from-scratch.xyz
70 stars 14 forks source link

Issue with stack chapter #7

Closed Rozengarden closed 6 months ago

Rozengarden commented 6 months ago

I've encountered two issues while trying to code along the Stack() chapter:

1) Two methods are called the same (pop), from my understanding python just replace the old method with the new one in this case and it seems to be what it is happening raising this error on Stack.pop() execution:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 print(stack.pop())

TypeError: pop() missing 1 required positional argument: 'n'

2) We push 3 value to the stack and then pop one, yet it is stated that we have 3 value on the stack instead of two

shafu0x commented 6 months ago

good point! should be fixed

Rozengarden commented 6 months ago

to reproduce pop behaviour n should be set to -1 by default, n=0 will remove the item at the bottom of the stack not the one on top

also it's still written:

Now only 3 values are left on the stack

print(stack)
1
4

while there is only two left

shafu0x commented 6 months ago

I should stop merging things without having a coffee first 😅

the explanation should be a bit clearer now.