Files
RustPython/compiler
ichyo 74c02d416e Fix wrong const optimization for "1.0 / 0.0" case
In cpython, "1.0 / 0.0" raises ZeroDivisionError
```
>>> 1.0 / 0.0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: float division by zer
```

but RustPython doesn't
```
>>>>> 1.0 / 0.0
inf
```

This is because they emits different byte codes.

```
$ echo "1.0 / 0.0" > zero-div.py

$ python -m dis zero-div.py
  1           0 LOAD_CONST               0 (1.0)
              2 LOAD_CONST               1 (0.0)
              4 BINARY_TRUE_DIVIDE
              6 POP_TOP
              8 LOAD_CONST               2 (None)
             10 RETURN_VALUE

$ cargo run --example dis zero-div.py
zero-div.py:
                 0 LoadConst            (inf)
                 1 Pop
                 2 LoadConst            (None)
                 3 ReturnValue
```

This commit stops optimization for zero division case
to generate same byte codes.
2019-10-24 00:26:02 +09:00
..
2019-10-10 21:07:26 +01:00