Author: Armin Rigo <[email protected]>
Branch:
Changeset: r79696:071d445c8497
Date: 2015-09-18 19:33 +0200
http://bitbucket.org/pypy/pypy/changeset/071d445c8497/
Log: Fix for a corner case: functions returning a constant 'nan'
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -13,7 +13,7 @@
import os
-import py
+import py, math
from rpython.annotator import model as annmodel, unaryop, binaryop
from rpython.rtyper.llannotation import SomePtr, lltype_to_annotation
@@ -446,7 +446,11 @@
if isinstance(resultvar, Constant) and \
isinstance(hop.r_result.lowleveltype, Primitive) and \
hop.r_result.lowleveltype is not Void:
- assert resultvar.value == hop.s_result.const
+ # assert that they are equal, or both are 'nan'
+ assert resultvar.value == hop.s_result.const or (
+ math.isnan(resultvar.value) and
+ math.isnan(hop.s_result.const))
+
resulttype = resultvar.concretetype
op.result.concretetype = hop.r_result.lowleveltype
if op.result.concretetype != resulttype:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit