git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2560 from purescript/phil/2136
f2656f6Phil Freeman
examples/passing/2136.pursnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff.Console (log)
5+
6+main =
7+ if (negate (bottom :: Int) > top)
8+ then log "Fail"
9+ else log "Done"
src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+3−2
@@ -86,6 +86,8 @@ inlineCommonValues = everywhereOnJS convert
86 | isDict' [semiringNumber, semiringInt] dict && isFn fnOne fn = JSNumericLiteral ss (Left 1)
86 | isDict' [semiringNumber, semiringInt] dict && isFn fnOne fn = JSNumericLiteral ss (Left 1)
87 | isDict boundedBoolean dict && isFn fnBottom fn = JSBooleanLiteral ss False
87 | isDict boundedBoolean dict && isFn fnBottom fn = JSBooleanLiteral ss False
88 | isDict boundedBoolean dict && isFn fnTop fn = JSBooleanLiteral ss True
88 | isDict boundedBoolean dict && isFn fnTop fn = JSBooleanLiteral ss True
89+ convert (JSApp ss (JSApp _ fn [dict]) [x])
90+ | isDict ringInt dict && isFn fnNegate fn = JSBinary ss BitwiseOr (JSUnary ss Negate x) (JSNumericLiteral ss (Left 0))
89 convert (JSApp ss (JSApp _ (JSApp _ fn [dict]) [x]) [y])
91 convert (JSApp ss (JSApp _ (JSApp _ fn [dict]) [x]) [y])
90 | isDict semiringInt dict && isFn fnAdd fn = intOp ss Add x y
92 | isDict semiringInt dict && isFn fnAdd fn = intOp ss Add x y
91 | isDict semiringInt dict && isFn fnMultiply fn = intOp ss Multiply x y
93 | isDict semiringInt dict && isFn fnMultiply fn = intOp ss Multiply x y
@@ -100,6 +102,7 @@ inlineCommonValues = everywhereOnJS convert
100 fnDivide = (C.dataEuclideanRing, C.div)
102 fnDivide = (C.dataEuclideanRing, C.div)
101 fnMultiply = (C.dataSemiring, C.mul)
103 fnMultiply = (C.dataSemiring, C.mul)
102 fnSubtract = (C.dataRing, C.sub)
104 fnSubtract = (C.dataRing, C.sub)
105+ fnNegate = (C.dataRing, C.negate)
103 intOp ss op x y = JSBinary ss BitwiseOr (JSBinary ss op x y) (JSNumericLiteral ss (Left 0))
106 intOp ss op x y = JSBinary ss BitwiseOr (JSBinary ss op x y) (JSNumericLiteral ss (Left 0))
104
107
105inlineCommonOperators :: JS -> JS
108inlineCommonOperators :: JS -> JS
@@ -109,8 +112,6 @@ inlineCommonOperators = applyAll $
109
112
110 , binary ringNumber opSub Subtract
113 , binary ringNumber opSub Subtract
111 , unary ringNumber opNegate Negate
114 , unary ringNumber opNegate Negate
112− , binary ringInt opSub Subtract
113− , unary ringInt opNegate Negate
114
115
115 , binary euclideanRingNumber opDiv Divide
116 , binary euclideanRingNumber opDiv Divide
116 , binary euclideanRingInt opMod Modulus
117 , binary euclideanRingInt opMod Modulus