Skip to content

Commit

Permalink
Go around DeferredCoercionNode problem. See XXX note.
Browse files Browse the repository at this point in the history
  • Loading branch information
sklam committed Oct 24, 2012
1 parent 588e167 commit 613748f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion numba/ast_type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,10 +1167,15 @@ def visit_Return(self, node):
elif self.return_variable.type is None:
self.return_variable.type = type
node.value = value
else:
elif self.return_variable.type != type:
# todo: in case of unpromotable types, return object?
self.return_variable.type = self.promote_types_numeric(
self.return_variable.type, type)

# XXX: DeferredCoercionNode __init__ is not compatible
# with CoercionNode __new__.
# We go around the problem for test_if.test_if_fn_5
# by not visiting this block if return_variable.type == type.
node.value = nodes.DeferredCoercionNode(
value, self.return_variable.type)

Expand Down
12 changes: 6 additions & 6 deletions numba/tests/test_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def test_if_fn_4(self):
for j in range(-3, 3):
self.assertEqual(if_fn_4c(i, j), oracle(i, j))

# def test_if_fn_5(self):
# if_fn_5c = jit(restype=int4, argtypes=[i4, i4], backend='ast')(if_fn_5)
# oracle = if_fn_5
# for i in range(-3, 3):
# for j in range(-3, 3):
# self.assertEqual(if_fn_5c(i, j), oracle(i, j))
def test_if_fn_5(self):
if_fn_5c = jit(restype=i4, argtypes=[i4, i4], backend='ast')(if_fn_5)
oracle = if_fn_5
for i in range(-3, 3):
for j in range(-3, 3):
self.assertEqual(if_fn_5c(i, j), oracle(i, j))

def test_if_fn_6(self):
if_fn_6c = jit(restype=void, argtypes=[i4, i4], backend='ast')(if_fn_6)
Expand Down

0 comments on commit 613748f

Please sign in to comment.