summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-08-11 14:44:48 +1000
committerDamien George <damien@micropython.org>2025-08-15 11:38:20 +1000
commit3efbd726eb89a1514c01a51857100b2718f12a50 (patch)
tree2435c9c0a9e8076289162a8ca200968a11c6cf04
parent141f7d0c35516403c39ce6266be7c6fb4551ef6f (diff)
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 69ead7d98ef30df3b6bd4485633490e80fca1718 Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--py/parse.c16
1 files changed, 0 insertions, 16 deletions
diff --git a/py/parse.c b/py/parse.c
index 6260987b2..1a50b13b5 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -771,12 +771,6 @@ static bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
if (!mp_parse_node_get_number_maybe(pn, &arg1)) {
return false;
}
- #if !MICROPY_COMP_CONST_FLOAT
- if (op == MP_BINARY_OP_POWER && mp_obj_int_sign(arg1) < 0) {
- // ** can't have negative rhs
- return false;
- }
- #endif
if (!binary_op_maybe(op, arg0, arg1, &arg0)) {
return false;
}
@@ -796,16 +790,6 @@ static bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
return false;
}
mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(peek_result(parser, i));
- if (tok == MP_TOKEN_OP_AT) {
- // Can't fold @
- return false;
- }
- #if !MICROPY_COMP_CONST_FLOAT
- if (tok == MP_TOKEN_OP_SLASH) {
- // Can't fold /
- return false;
- }
- #endif
mp_binary_op_t op = MP_BINARY_OP_LSHIFT + (tok - MP_TOKEN_OP_DBL_LESS);
if (!binary_op_maybe(op, arg0, arg1, &arg0)) {
return false;