Commit 47a94155 authored by Stefan Behnel's avatar Stefan Behnel

implement None check removal for binary operations on builtin types

parent ec9e1b3c
......@@ -6741,6 +6741,16 @@ class NumBinopNode(BinopNode):
else:
return None
def may_be_none(self):
type1 = self.operand1.type
type2 = self.operand2.type
if type1 and type1.is_builtin_type and type2 and type2.is_builtin_type:
# XXX: I can't think of any case where a binary operation
# on builtin types evaluates to None - add a special case
# here if there is one.
return False
return super(NumBinopNode, self).may_be_none()
def get_constant_c_result_code(self):
value1 = self.operand1.get_constant_c_result_code()
value2 = self.operand2.get_constant_c_result_code()
......
......@@ -114,7 +114,7 @@ def self_dependency_none(int x):
a,b = b,a
return b.get(2)
#@cython.test_fail_if_path_exists('//NoneCheckNode')
@cython.test_fail_if_path_exists('//NoneCheckNode')
def in_place_op():
vals = [0]
vals += [1]
......
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