lib/fixed_ints: fix crash on `"-".is_int`
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 1 May 2016 21:33:53 +0000 (17:33 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 5 May 2016 17:25:41 +0000 (13:25 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/core/fixed_ints.nit

index c643eee..f2f3890 100644 (file)
@@ -900,11 +900,13 @@ redef class Text
        #     assert not "0xGE".is_int
        #     assert not "".is_int
        #     assert not "Not an Int".is_int
+       #     assert not "-".is_int
        fun is_int: Bool do
                if bytelen == 0 then return false
                var s = remove_all('_')
                var pos = 0
-               while s[pos] == '-' do
+               var len = s.length
+               while pos < len and s[pos] == '-' do
                        pos += 1
                end
                s = s.substring_from(pos)