diff --git a/ASTree.cpp b/ASTree.cpp index a0c35939..a04852c9 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -620,6 +620,16 @@ PycRef BuildFromCode(PycRef code, PycModule* mod) stack.push(new ASTCompare(left, right, operand)); } break; + case Pyc::CONTAINS_OP_A: + { + PycRef right = stack.top(); + stack.pop(); + PycRef left = stack.top(); + stack.pop(); + // The operand will be 0 for 'in' and 1 for 'not in'. + stack.push(new ASTCompare(left, right, operand ? ASTCompare::CMP_NOT_IN : ASTCompare::CMP_IN)); + } + break; case Pyc::DELETE_ATTR_A: { PycRef name = stack.top(); diff --git a/tests/compiled/contains_op.3.9.pyc b/tests/compiled/contains_op.3.9.pyc new file mode 100644 index 00000000..78b9c181 Binary files /dev/null and b/tests/compiled/contains_op.3.9.pyc differ diff --git a/tests/input/contains_op.py b/tests/input/contains_op.py new file mode 100644 index 00000000..c4b207ab --- /dev/null +++ b/tests/input/contains_op.py @@ -0,0 +1,8 @@ +a = 10 +b = [10, 20, 30] + +if a in b: + pass + +if a not in b: + pass diff --git a/tests/tokenized/contains_op.txt b/tests/tokenized/contains_op.txt new file mode 100644 index 00000000..f33e0931 --- /dev/null +++ b/tests/tokenized/contains_op.txt @@ -0,0 +1,9 @@ +a = 10 +b = [ 10 , 20 , 30 ] +if a in b : + +pass + +if a not in b : + +pass