Skip to content
Snippets Groups Projects
Commit 96eec4f8 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

compile: Don't try to constant-fold division by zero.

The way it is, just crashes app. And optimizing to
"raise ZeroDivisionError" is probably too much.
parent 864038da
Branches
No related tags found
No related merge requests found
......@@ -145,7 +145,9 @@ mp_parse_node_t fold_constants(mp_parse_node_t pn) {
} else if (MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_PERCENT)) {
pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, python_modulo(arg0, arg1));
} else if (MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_DBL_SLASH)) {
if (arg1 != 0) {
pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, python_floor_divide(arg0, arg1));
}
} else {
// shouldn't happen
assert(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment