Commit 68e229b4 authored by Stefan Behnel's avatar Stefan Behnel

fix type inference for C true division

parent 6344f0b0
......@@ -9780,11 +9780,20 @@ class DivNode(NumBinopNode):
except Exception, e:
self.compile_time_value_error(e)
def analyse_operation(self, env):
def _check_truedivision(self, env):
if self.cdivision or env.directives['cdivision']:
self.ctruedivision = False
else:
self.ctruedivision = self.truedivision
def infer_type(self, env):
self._check_truedivision(env)
return self.result_type(
self.operand1.infer_type(env),
self.operand2.infer_type(env))
def analyse_operation(self, env):
self._check_truedivision(env)
NumBinopNode.analyse_operation(self, env)
if self.is_cpp_operation():
self.cdivision = True
......
from __future__ import division
cimport cython
def doit(x,y):
"""
>>> doit(1,2)
......@@ -81,3 +83,15 @@ def float_mix_rev(float a):
(0.25, 0.0, 1.25, 1.0, 1.25, 1.0)
"""
return 1/a, 1//a, 5.0/a, 5.0//a, 5/a, 5//a
def infer_division_type():
"""
>>> v = infer_division_type()
double
>>> v
8333333.25
"""
v = (10000**2 - 1) / 12
print(cython.typeof(v))
return v
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment