Make the strictNEq optimization more conservative
The previous version had (0 /= x) and (x /= 0) result in truthy values,
rather than the direct true or false value. The truthy values were
observable via Debug.toString, so this will fix #1810. It seems there
are other case where it can be observed, though I have not seen any
reports of those cases.
commit7e1116c48618da1853c1a645ec07079a47946d7f
authorEvan Czaplicki <evancz@users.noreply.github.com>
dateWed 7 Nov 2018, 20:51 (8 years ago)
parent35ac8af
compiler/src/Generate/JavaScript/Expression.hs+2−2
@@ -668,7 +668,7 @@ strictNEq :: JS.Expr -> JS.Expr -> JS.Expr
668668strictNEq left right =
669669 case left of
670670 JS.Int 0 ->
671− right
671+ JS.Prefix JS.PrefixLNot (JS.Prefix JS.PrefixLNot right)
672672
673673 JS.Bool bool ->
674674 if bool then JS.Prefix JS.PrefixLNot right else right
@@ -676,7 +676,7 @@ strictNEq left right =
676676 _ ->
677677 case right of
678678 JS.Int 0 ->
679− left
679+ JS.Prefix JS.PrefixLNot (JS.Prefix JS.PrefixLNot left)
680680
681681 JS.Bool bool ->
682682 if bool then JS.Prefix JS.PrefixLNot left else left