on master help sign in
Expand `else` to `True` instead of `otherwise`.

Makes `if` syntax independent of the value of `otherwise`. Includes test case.

commit254d71f4e59a37a96c281dd6128a1287562243e2 authorMax New <maxsnew@gmail.com> dateMon 23 Dec 2013, 18:29 (13 years ago) parente119d8e
2 files changed+6−1
compiler/Parse/Expression.hs+1−1 tests/good/Otherwise.elm+5
compiler/Parse/Expression.hs+1−1
@@ -157,7 +157,7 @@ ifExpr = reserved "if" >> whitespace >> (normal <|> multiIf)
157157 whitespace <?> "an 'else' branch" ; reserved "else" <?> "an 'else' branch" ; whitespace
158158 elseBranch <- expr
159159 return $ MultiIf [(bool, thenBranch),
160− (Location.sameAs elseBranch (Var "otherwise"), elseBranch)]
160+ (Location.sameAs elseBranch (Literal . Literal.Boolean $ True), elseBranch)]
161161 multiIf = MultiIf <$> spaceSep1 iff
162162 where iff = do string "|" ; whitespace
163163 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"