diff --git a/py/compile.c b/py/compile.c index c953711081..bb7c1117fa 100644 --- a/py/compile.c +++ b/py/compile.c @@ -423,21 +423,6 @@ STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int la } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_not_test_2) { c_if_cond(comp, pns->nodes[0], !jump_if, label); return; - } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_atom_paren) { - // cond is something in parenthesis - if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { - // empty tuple, acts as false for the condition - if (jump_if == false) { - EMIT_ARG(jump, label); - } - } else { - assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); - // non-empty tuple, acts as true for the condition - if (jump_if == true) { - EMIT_ARG(jump, label); - } - } - return; } } diff --git a/tests/basics/ifcond.py b/tests/basics/ifcond.py index 9264aa74dd..5eba143420 100644 --- a/tests/basics/ifcond.py +++ b/tests/basics/ifcond.py @@ -57,6 +57,20 @@ if not (1,): else: print('b') +# test evaluation of the if-condition with tuples as arguments +# non-constant tuples should be evaluated even though they will evaluate to true + +def f(x): + print("f", x) + +if (f(1),): + print(18) + +if (f(2), f(3)): + print(19) + +# test if-conditions within a function + f2 = 0 def f(t1, t2, f1):