Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

"Invalid list operation" error with if conditions #29

Closed
brianlenz opened this issue Jan 17, 2018 · 1 comment
Closed

"Invalid list operation" error with if conditions #29

brianlenz opened this issue Jan 17, 2018 · 1 comment

Comments

@brianlenz
Copy link

As discussed with @localhuman in #python Discord.

The following snippet of code (taken from our modified version of the nex-ico-template project) is failing on the if condition:

is_kyc_approved = self.get_kyc_status(attachments.sender_addr, storage)
print(is_key_approved)
if not is_kyc_approved:
    print("not KYC approved")
    return 0

Here is the output:

[I 180116 18:34:22 EventHub:102] [test_mode][SmartContract.Runtime.Log] [465172675f3249377aff2dde78093cf75b8429ac] b'\x01'
[E 180116 18:34:22 ExecutionEngine:831] COULD NOT EXECUTE OP: Invalid list operation b'c' JMPIF
[E 180116 18:34:22 ExecutionEngine:832] Invalid list operation
    Traceback (most recent call last):
      File "/Users/brian/Projects/Narrative/neo-python/neo/VM/ExecutionEngine.py", line 829, in StepInto
        self.ExecuteOp(op, self.CurrentContext)
      File "/Users/brian/Projects/Narrative/neo-python/neo/VM/ExecutionEngine.py", line 172, in ExecuteOp
        fValue = estack.Pop().GetBoolean()
      File "/Users/brian/Projects/Narrative/neo-python/neo/VM/RandomAccessStack.py", line 45, in Pop
        return self.Remove(0)
      File "/Users/brian/Projects/Narrative/neo-python/neo/VM/RandomAccessStack.py", line 57, in Remove
        raise Exception("Invalid list operation")
    Exception: Invalid list operation
[I 180116 18:34:22 EventHub:102] [test_mode][SmartContract.Runtime.Log] [465172675f3249377aff2dde78093cf75b8429ac] b'not KYC approved'

is_kyc_approved is true, but the if condition fails due to the "Invalid list operation" error.

I've tested on the latest neo-boa development branch, and it has the same issue.

We can work around the issue by putting a print statement right after the if or by adding an else condition.

@localhuman
Copy link
Collaborator

This should be resolved in the new version of the compiler ( v0.3.3 ).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants