Skip to content

Commit 3efbd72

Browse files
committed
py/parse: Remove explicit checks for invalid folding operations.
They are instead checked by `binary_op_maybe()`, which catches exceptions for invalid int/float operations. This is a follow-up to 69ead7d Signed-off-by: Damien George <damien@micropython.org>
1 parent 141f7d0 commit 3efbd72

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

py/parse.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,6 @@ static bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
771771
if (!mp_parse_node_get_number_maybe(pn, &arg1)) {
772772
return false;
773773
}
774-
#if !MICROPY_COMP_CONST_FLOAT
775-
if (op == MP_BINARY_OP_POWER && mp_obj_int_sign(arg1) < 0) {
776-
// ** can't have negative rhs
777-
return false;
778-
}
779-
#endif
780774
if (!binary_op_maybe(op, arg0, arg1, &arg0)) {
781775
return false;
782776
}
@@ -796,16 +790,6 @@ static bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
796790
return false;
797791
}
798792
mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(peek_result(parser, i));
799-
if (tok == MP_TOKEN_OP_AT) {
800-
// Can't fold @
801-
return false;
802-
}
803-
#if !MICROPY_COMP_CONST_FLOAT
804-
if (tok == MP_TOKEN_OP_SLASH) {
805-
// Can't fold /
806-
return false;
807-
}
808-
#endif
809793
mp_binary_op_t op = MP_BINARY_OP_LSHIFT + (tok - MP_TOKEN_OP_DBL_LESS);
810794
if (!binary_op_maybe(op, arg0, arg1, &arg0)) {
811795
return false;

0 commit comments

Comments
 (0)