diff --git a/builtins/Float.roc b/builtins/Float.roc index 1761ecb347..10309e6a08 100644 --- a/builtins/Float.roc +++ b/builtins/Float.roc @@ -69,7 +69,7 @@ interface Float #round : Float -> Int round = \num -> - case num is + when num is 0.0 -> 0 _ -> 1 @@ -110,7 +110,7 @@ round = \num -> ## >>> |> Float.div 2.0 #div : Float, Float -> Result Float DivByZero div = \numerator, denominator -> - case numerator is + when numerator is 0.0 -> 0.0 # TODO return Result! _ -> denominator diff --git a/src/fmt/expr.rs b/src/fmt/expr.rs index 526f35c3b3..27b492f72d 100644 --- a/src/fmt/expr.rs +++ b/src/fmt/expr.rs @@ -134,7 +134,7 @@ pub fn fmt_expr<'a>( } Case(loc_condition, branches) => { buf.push_str("\ - case "); + when "); fmt_expr(buf, &loc_condition.value, indent, false, true); buf.push_str(" is\n"); diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 21aef45c2b..65fa21bff6 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -1139,7 +1139,7 @@ pub fn colon_with_indent<'a>() -> impl Parser<'a, u16> { pub fn case_with_indent<'a>() -> impl Parser<'a, u16> { move |arena, state: State<'a>| { - string(keyword::CASE) + string(keyword::WHEN) .parse(arena, state) .map(|((), state)| (state.indent_col, state)) } diff --git a/tests/test_canonicalize.rs b/tests/test_canonicalize.rs index 0e60687216..fea07b2f85 100644 --- a/tests/test_canonicalize.rs +++ b/tests/test_canonicalize.rs @@ -249,17 +249,17 @@ mod test_canonicalize { let src = indoc!( r#" g = \x -> - case x is + when x is 0 -> 0 _ -> g (x - 1) h = \x -> - case x is + when x is 0 -> 0 _ -> g (x - 1) p = \x -> - case x is + when x is 0 -> 0 1 -> g (x - 1) _ -> p (x - 1) @@ -288,7 +288,7 @@ mod test_canonicalize { let src = indoc!( r#" g = \x -> - case x is + when x is 0 -> 0 _ -> g (x + 1) @@ -327,7 +327,7 @@ mod test_canonicalize { let src = indoc!( r#" q = \x -> - case q x is + when q x is _ -> 0 0 @@ -348,12 +348,12 @@ mod test_canonicalize { let src = indoc!( r#" q = \x -> - case x is + when x is 0 -> 0 _ -> p (x - 1) p = \x -> - case x is + when x is 0 -> 0 _ -> q (x - 1) diff --git a/tests/test_eval.rs b/tests/test_eval.rs index 752d9e791c..d72a372364 100644 --- a/tests/test_eval.rs +++ b/tests/test_eval.rs @@ -87,7 +87,7 @@ mod test_gen { assert_evals_to!( indoc!( r#" - case 1 is + when 1 is 1 -> 12 _ -> 34 "# @@ -102,7 +102,7 @@ mod test_gen { assert_evals_to!( indoc!( r#" - case 2 is + when 2 is 1 -> 63 _ -> 48 "# diff --git a/tests/test_format.rs b/tests/test_format.rs index 29a89cd7ca..1f44ae5184 100644 --- a/tests/test_format.rs +++ b/tests/test_format.rs @@ -695,7 +695,7 @@ mod test_format { fn integer_case() { expr_formats_same(indoc!( r#" - case b is + when b is 1 -> 1 @@ -710,7 +710,7 @@ mod test_format { expr_formats_to( indoc!( r#" - case year is + when year is 1999 -> @@ -725,7 +725,7 @@ mod test_format { ), indoc!( r#" - case year is + when year is 1999 -> 1 @@ -740,10 +740,10 @@ mod test_format { fn case_with_comments() { expr_formats_same(indoc!( r#" - case b is + when b is # look at cases 1 -> - # case 1 + # when 1 1 # important @@ -761,9 +761,9 @@ mod test_format { fn nested_case() { expr_formats_same(indoc!( r#" - case b is + when b is _ -> - case c is + when c is _ -> 1 "# @@ -775,9 +775,9 @@ mod test_format { expr_formats_to( indoc!( r#" - case b is + when b is 1 -> - 1 # case 1 + 1 # when 1 # fall through _ -> @@ -786,11 +786,11 @@ mod test_format { ), indoc!( r#" - case b is + when b is 1 -> 1 - # case 1 + # when 1 # fall through _ -> 2 diff --git a/tests/test_infer.rs b/tests/test_infer.rs index 43220c57e9..31a2c21bdd 100644 --- a/tests/test_infer.rs +++ b/tests/test_infer.rs @@ -833,7 +833,7 @@ mod test_infer { infer_eq( indoc!( r#" - case 1 is + when 1 is 1 -> 2 3 -> 4 "# diff --git a/tests/test_parse.rs b/tests/test_parse.rs index 4e67a7e037..d95df07c23 100644 --- a/tests/test_parse.rs +++ b/tests/test_parse.rs @@ -1322,7 +1322,7 @@ mod test_parse { &arena, indoc!( r#" - case x is + when x is "blah" -> 1 "mise" -> 2 "# @@ -1356,7 +1356,7 @@ mod test_parse { &arena, indoc!( r#" - case x is + when x is 1 -> 2 3 -> 4 "# @@ -1396,7 +1396,7 @@ mod test_parse { &arena, indoc!( r#" - case x is + when x is { y } -> 2 { z, w } -> 4 "# diff --git a/tests/test_uniqueness_infer.rs b/tests/test_uniqueness_infer.rs index 826c4b3f33..25a50cfa73 100644 --- a/tests/test_uniqueness_infer.rs +++ b/tests/test_uniqueness_infer.rs @@ -863,7 +863,7 @@ mod test_infer_uniq { infer_eq( indoc!( r#" - case 1 is + when 1 is 1 -> 2 3 -> 4 "#