on master help sign in
Expand `else` to `True` instead of `otherwise`.
254d71fMax New
compiler/Parse/Expression.hs+1−1
@@ -157,7 +157,7 @@ ifExpr = reserved "if" >> whitespace >> (normal <|> multiIf)
157 whitespace <?> "an 'else' branch" ; reserved "else" <?> "an 'else' branch" ; whitespace
157 whitespace <?> "an 'else' branch" ; reserved "else" <?> "an 'else' branch" ; whitespace
158 elseBranch <- expr
158 elseBranch <- expr
159 return $ MultiIf [(bool, thenBranch),
159 return $ MultiIf [(bool, thenBranch),
160− (Location.sameAs elseBranch (Var "otherwise"), elseBranch)]
160+ (Location.sameAs elseBranch (Literal . Literal.Boolean $ True), elseBranch)]
161 multiIf = MultiIf <$> spaceSep1 iff
161 multiIf = MultiIf <$> spaceSep1 iff
162 where iff = do string "|" ; whitespace
162 where iff = do string "|" ; whitespace
163 b <- expr ; padded arrow
163 b <- expr ; padded arrow
tests/good/Otherwise.elmnew file+5
@@ -0,0 +1,5 @@
1+module Otherwise where
2+
3+otherwise = 3
4+
5+main = asText <| if False then "Yay" else "Boo"