ref: c860f5307ff18dff3c63d6a80691c4a865101491
parent: 728fe3286bec3f5e6b6df584d88c6b39e54237cb
author: Ori Bernstein <[email protected]>
date: Tue May 27 20:01:49 EDT 2014
Use a signed int when we check for <0 If we use negative value to signal errors, we had better make sure that we can hold negative values.
--- a/libstd/intparse.myr
+++ b/libstd/intparse.myr
@@ -45,7 +45,8 @@
generic doparse = {s, isneg, base
var c
- var v, cv
+ var v
+ var cv : int32
v = 0
while s.len != 0
@@ -56,7 +57,7 @@
cv = charval(c, base)
if cv >= 0
v *= (base castto(@a::(integral,numeric)))
- v += cv
+ v += cv castto(@a::(integral,numeric))
else
-> `None
;;