0

I'm trying to figure out why the following line is giving the error at https://vyper.online/: invalid syntax (, line 168).

Line 168 is self.collator_pool.empty_slots_stack_top] = index).

@internal
def stack_push(index: int128):
    (self.collator_pool.empty_slots_stack[
        self.collator_pool.empty_slots_stack_top] = index)
    self.collator_pool.empty_slots_stack_top += 1

There's also this which is the other relevant part of the file:

collator_pool: public({
    # array of active collator addresses
    collator_pool_arr: address[int128],
    # size of the collator pool
    collator_pool_len: int128,
    # Stack of empty collator slot indices caused by the function
    # degister_collator().
    empty_slots_stack: int128[int128],
    # The top index of the stack in empty_slots_stack.
    empty_slots_stack_top: int128,
})

I don't think you'll need it but the whole file is available at https://github.com/Drops-of-Diamond/sharding/blob/develop/smc/sharding_manager_contract.v.py.

  • I think it might be due to the way you have broken up the statement in the parentheses. If Vyper is anything like Python that has caused me some issues every so often. – hextet Mar 29 '18 at 2:26
  • No, it's not that, I tried putting it all on one line, but I still got the same error. The use of parentheses allows line continuation. (self.collator_pool.empty_slots_stack[self.collator_pool.empty_slots_stack_top] = index) – James Ray Mar 29 '18 at 2:45
  • Ah okay. I haven't used Vyper so I'm just spit balling, but I took a look at some of your other internal function definitions, and noticed that they had a return statement at the end of them. Why not try having stack_push return an empty boolean and them compiling it again? See if that fixes the error. – hextet Mar 29 '18 at 4:45
  • I did think of that but I'm skeptical as it didn't mention this in vyper.readthedocs.io/en/latest, and in Python you don't need a return statement, if there isn't one the function will return None. The compiler is breaking at line 8, it hasn't got to stack_push yet. Nevertheless I did add return None, but it is still breaking the same way. – James Ray Mar 29 '18 at 5:26
  • @hextet, FYI, adding return None caused an error: line 170: Not expecting to return a value return None ----^. – James Ray Mar 29 '18 at 5:50
1

The parentheses are causing the error. Putting the statement on one line without the parentheses causes it to compile. To still comply with PEP008, since implicit line continuation is not an option with Vyper here (although it should be, and I will report this issue to the Vyper team), explicit line continuation will still work, in this case:

@private
def stack_push(index: int128):
    self.collator_pool.empty_slots_stack[self.collator_pool \
        .empty_slots_stack_top] = index

I reported this at https://github.com/ethereum/vyper/issues/724.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.