[MLton-commit] r5168

Matthew Fluet fluet at mlton.org
Sun Feb 11 13:17:02 PST 2007


WordXVector.equals (and, consequently, Const.equals) was judging empty
vectors of different element sizes as being equal.  This would allow
constantPropagation (and probably commonSubexp) to equate empty
strings of different sizes, yielding a type-incorrect program.

The solution is simply: WordXVector.equals now judges vectors as equal
if they have the same elementSize and equal elements.


----------------------------------------------------------------------

U   mlton/trunk/mlton/atoms/word-x-vector.fun

----------------------------------------------------------------------

Modified: mlton/trunk/mlton/atoms/word-x-vector.fun
===================================================================
--- mlton/trunk/mlton/atoms/word-x-vector.fun	2007-02-11 20:34:10 UTC (rev 5167)
+++ mlton/trunk/mlton/atoms/word-x-vector.fun	2007-02-11 21:17:01 UTC (rev 5168)
@@ -45,7 +45,9 @@
 
 val layout = Layout.str o toString
 
-fun equals (v, v') = Vector.equals (elements v, elements v', WordX.equals)
+fun equals (v, v') = 
+    WordSize.equals (elementSize v, elementSize v')
+    andalso Vector.equals (elements v, elements v', WordX.equals)
 
 fun forall (v, f) = Vector.forall (elements v, f)
 




More information about the MLton-commit mailing list