Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r98280:56cb51f3c081
Date: 2019-12-12 17:44 +0100
http://bitbucket.org/pypy/pypy/changeset/56cb51f3c081/

Log:    Prevent lltype.typeOf(2<<32) from returning SignedLongLong on 32-bit
        just because 2<<32 doesn't fit into a regular Signed. If you want to
        get a SignedLongLong, better be explicit (e.g. with r_int64())

diff --git a/rpython/jit/backend/x86/test/test_runner.py 
b/rpython/jit/backend/x86/test/test_runner.py
--- a/rpython/jit/backend/x86/test/test_runner.py
+++ b/rpython/jit/backend/x86/test/test_runner.py
@@ -285,12 +285,15 @@
         cases = [8, 16, 24]
         if WORD == 8:
             cases.append(32)
+            bigvalue = 0xAAAAAAAAAAAA
+        else:
+            bigvalue = 0xAAAAAAA
         for i in cases:
-            box = InputArgInt(0xAAAAAAAAAAAA)
+            box = InputArgInt(bigvalue)
             res = self.execute_operation(rop.INT_AND,
                                          [box, ConstInt(2 ** i - 1)],
                                          'int')
-            assert res == 0xAAAAAAAAAAAA & (2 ** i - 1)
+            assert res == bigvalue & (2 ** i - 1)
 
     def test_nullity_with_guard(self):
         allops = [rop.INT_IS_TRUE]
diff --git a/rpython/rtyper/lltypesystem/lltype.py 
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -815,7 +815,11 @@
             if -maxint-1 <= val <= maxint:
                 return Signed
             elif longlongmask(val) == val:
-                return SignedLongLong
+                raise OverflowError("integer %r is out of bounds for Signed "
+                                    "(it would fit SignedLongLong, but we "
+                                    "won't implicitly return SignedLongLong "
+                                    "for typeOf(%r) where type(%r) is long)"
+                                    % (val, val, val))
             else:
                 raise OverflowError("integer %r is out of bounds" % (val,))
         if tp is bool:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to