diff --git a/crates/compiler/builtins/roc/Bool.roc b/crates/compiler/builtins/roc/Bool.roc index f264f19345..e7dfc2ff71 100644 --- a/crates/compiler/builtins/roc/Bool.roc +++ b/crates/compiler/builtins/roc/Bool.roc @@ -1,20 +1,28 @@ interface Bool - exposes [Bool, and, or, not, isEq, isNotEq] + exposes [Bool, true, false, and, or, not, isEq, isNotEq] imports [] -Bool : [True, False] +Bool := [True, False] -## Returns `True` when given `True` and `True`, and `False` when either argument is `False`. +## The boolean true value. +true : Bool +true = @Bool True + +## The boolean false value. +false : Bool +false = @Bool False + +## Returns `Bool.true` when given `Bool.true` and `Bool.true`, and `Bool.false` when either argument is `Bool.false`. ## ## `a && b` is shorthand for `Bool.and a b` ## -## >>> True && True +## >>> Bool.true && Bool.true ## -## >>> True && False +## >>> Bool.true && Bool.false ## -## >>> False && True +## >>> Bool.false && Bool.true ## -## >>> False && False +## >>> Bool.false && Bool.false ## ## ## Performance Notes ## @@ -26,7 +34,7 @@ Bool : [True, False] ## if enablePets then ## likesDogs user ## else -## False +## Bool.false ## ## In Roc, however, `&&` and `||` are not special. They work the same way as ## other functions. Conditionals like `if` and `when` have a performance cost, @@ -37,17 +45,17 @@ Bool : [True, False] ## one explicitly!) and : Bool, Bool -> Bool -## Returns `True` when given `True` for either argument, and `False` only when given `False` and `False`. +## Returns `Bool.true` when given `Bool.true` for either argument, and `Bool.false` only when given `Bool.false` and `Bool.false`. ## ## `a || b` is shorthand for `Bool.or a b`. ## -## >>> True || True +## >>> Bool.true || Bool.true ## -## >>> True || False +## >>> Bool.true || Bool.false ## -## >>> False || True +## >>> Bool.false || Bool.true ## -## >>> False || False +## >>> Bool.false || Bool.false ## ## ## Performance Notes ## @@ -56,10 +64,10 @@ and : Bool, Bool -> Bool ## In Roc, this is not the case. See the performance notes for [Bool.and] for details. or : Bool, Bool -> Bool # xor : Bool, Bool -> Bool # currently unimplemented -## Returns `False` when given `True`, and vice versa. +## Returns `Bool.false` when given `Bool.true`, and vice versa. not : Bool -> Bool -## Returns `True` if the two values are *structurally equal*, and `False` otherwise. +## Returns `Bool.true` if the two values are *structurally equal*, and `Bool.false` otherwise. ## ## `a == b` is shorthand for `Bool.isEq a b` ## @@ -68,7 +76,7 @@ not : Bool -> Bool ## 1. Tags are equal if they have the same tag name, and also their contents (if any) are equal. ## 2. Records are equal if all their fields are equal. ## 3. Collections ([Str], [List], [Dict], and [Set]) are equal if they are the same length, and also all their corresponding elements are equal. -## 4. [Num](Num#Num) values are equal if their numbers are equal, with one exception: if both arguments to `isEq` are *NaN*, then `isEq` returns `False`. See `Num.isNaN` for more about *NaN*. +## 4. [Num](Num#Num) values are equal if their numbers are equal, with one exception: if both arguments to `isEq` are *NaN*, then `isEq` returns `Bool.false`. See `Num.isNaN` for more about *NaN*. ## ## Note that `isEq` takes `'val` instead of `val`, which means `isEq` does not ## accept arguments whose types contain functions. diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 8650747613..ef012f7f21 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -69,7 +69,7 @@ interface Dict ## ## When comparing two dictionaries for equality, they are `==` only if their both their contents and their ## orderings match. This preserves the property that if `dict1 == dict2`, you should be able to rely on -## `fn dict1 == fn dict2` also being `True`, even if `fn` relies on the dictionary's ordering. +## `fn dict1 == fn dict2` also being `Bool.true`, even if `fn` relies on the dictionary's ordering. Dict k v := List [Pair k v] ## An empty dictionary. @@ -130,8 +130,8 @@ contains = \@Dict list, needle -> Continue {} when List.iterate list {} step is - Continue _ -> False - Break _ -> True + Continue _ -> Bool.false + Break _ -> Bool.true single : k, v -> Dict k v single = \key, value -> diff --git a/crates/compiler/builtins/roc/Json.roc b/crates/compiler/builtins/roc/Json.roc index 914c126c86..3dca470cf5 100644 --- a/crates/compiler/builtins/roc/Json.roc +++ b/crates/compiler/builtins/roc/Json.roc @@ -307,14 +307,14 @@ decodeBool = Decode.custom \bytes, @Json {} -> if maybeFalse == [asciiByte 'f', asciiByte 'a', asciiByte 'l', asciiByte 's', asciiByte 'e'] then - { result: Ok False, rest: afterFalse } + { result: Ok Bool.false, rest: afterFalse } else { before: maybeTrue, others: afterTrue } = List.split bytes 4 if maybeTrue == [asciiByte 't', asciiByte 'r', asciiByte 'u', asciiByte 'e'] then - { result: Ok True, rest: afterTrue } + { result: Ok Bool.true, rest: afterTrue } else { result: Err TooShort, rest: bytes } diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 44c8638ea3..f5b5734767 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -441,7 +441,7 @@ product : List (Num a) -> Num a product = \list -> List.walk list 1 Num.mul -## Run the given predicate on each element of the list, returning `True` if +## Run the given predicate on each element of the list, returning `Bool.true` if ## any of the elements satisfy it. any : List a, (a -> Bool) -> Bool any = \list, predicate -> @@ -452,10 +452,10 @@ any = \list, predicate -> Continue {} when List.iterate list {} looper is - Continue {} -> False - Break {} -> True + Continue {} -> Bool.false + Break {} -> Bool.true -## Run the given predicate on each element of the list, returning `True` if +## Run the given predicate on each element of the list, returning `Bool.true` if ## all of the elements satisfy it. all : List a, (a -> Bool) -> Bool all = \list, predicate -> @@ -466,11 +466,11 @@ all = \list, predicate -> Break {} when List.iterate list {} looper is - Continue {} -> True - Break {} -> False + Continue {} -> Bool.true + Break {} -> Bool.false ## Run the given function on each element of a list, and return all the -## elements for which the function returned `True`. +## elements for which the function returned `Bool.true`. ## ## >>> List.keepIf [1, 2, 3, 4] (\num -> num > 2) ## @@ -507,7 +507,7 @@ keepIfHelp = \list, predicate, kept, index, length -> List.takeFirst list kept ## Run the given function on each element of a list, and return all the -## elements for which the function returned `False`. +## elements for which the function returned `Bool.false`. ## ## >>> List.dropIf [1, 2, 3, 4] (\num -> num > 2) ## @@ -875,24 +875,24 @@ intersperse = \list, sep -> List.dropLast newList -## Returns `True` if the first list starts with the second list. +## Returns `Bool.true` if the first list starts with the second list. ## -## If the second list is empty, this always returns `True`; every list +## If the second list is empty, this always returns `Bool.true`; every list ## is considered to "start with" an empty list. ## -## If the first list is empty, this only returns `True` if the second list is empty. +## If the first list is empty, this only returns `Bool.true` if the second list is empty. startsWith : List elem, List elem -> Bool startsWith = \list, prefix -> # TODO once we have seamless slices, verify that this wouldn't # have better performance with a function like List.compareSublists prefix == List.sublist list { start: 0, len: List.len prefix } -## Returns `True` if the first list ends with the second list. +## Returns `Bool.true` if the first list ends with the second list. ## -## If the second list is empty, this always returns `True`; every list +## If the second list is empty, this always returns `Bool.true`; every list ## is considered to "end with" an empty list. ## -## If the first list is empty, this only returns `True` if the second list is empty. +## If the first list is empty, this only returns `Bool.true` if the second list is empty. endsWith : List elem, List elem -> Bool endsWith = \list, suffix -> # TODO once we have seamless slices, verify that this wouldn't diff --git a/crates/compiler/builtins/roc/Num.roc b/crates/compiler/builtins/roc/Num.roc index 32d560c9b9..9a712367da 100644 --- a/crates/compiler/builtins/roc/Num.roc +++ b/crates/compiler/builtins/roc/Num.roc @@ -346,14 +346,14 @@ Int range : Num (Integer range) ## ## wasItPrecise = 0.1 + 0.2 == 0.3 ## -## The value of `wasItPrecise` here will be `True`, because Roc uses [Dec] +## The value of `wasItPrecise` here will be `Bool.true`, because Roc uses [Dec] ## by default when there are no types specified. ## ## In contrast, suppose we use `f32` or `f64` for one of these numbers: ## ## wasItPrecise = 0.1f64 + 0.2 == 0.3 ## -## Here, `wasItPrecise` will be `False` because the entire calculation will have +## Here, `wasItPrecise` will be `Bool.false` because the entire calculation will have ## been done in a base-2 floating point calculation, which causes noticeable ## precision loss in this case. ## @@ -534,45 +534,45 @@ bytesToU32 = \bytes, index -> compare : Num a, Num a -> [LT, EQ, GT] -## Returns `True` if the first number is less than the second. +## Returns `Bool.true` if the first number is less than the second. ## ## `a < b` is shorthand for `Num.isLt a b`. ## -## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN* +## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN* ## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).) ## ## >>> 5 ## >>> |> Num.isLt 6 isLt : Num a, Num a -> Bool -## Returns `True` if the first number is greater than the second. +## Returns `Bool.true` if the first number is greater than the second. ## ## `a > b` is shorthand for `Num.isGt a b`. ## -## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN* +## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN* ## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).) ## ## >>> 6 ## >>> |> Num.isGt 5 isGt : Num a, Num a -> Bool -## Returns `True` if the first number is less than or equal to the second. +## Returns `Bool.true` if the first number is less than or equal to the second. ## ## `a <= b` is shorthand for `Num.isLte a b`. ## -## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN* +## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN* ## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).) isLte : Num a, Num a -> Bool -## Returns `True` if the first number is greater than or equal to the second. +## Returns `Bool.true` if the first number is greater than or equal to the second. ## ## `a >= b` is shorthand for `Num.isGte a b`. ## -## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN* +## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN* ## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).) isGte : Num a, Num a -> Bool -## Returns `True` if the number is `0`, and `False` otherwise. +## Returns `Bool.true` if the number is `0`, and `Bool.false` otherwise. isZero : Num a -> Bool isZero = \x -> x == 0 @@ -1265,34 +1265,34 @@ toF32Checked : Num * -> Result F32 [OutOfBounds]* toF64Checked : Num * -> Result F64 [OutOfBounds]* # Special Floating-Point operations -## When given a [F64] or [F32] value, returns `False` if that value is -## [*NaN*](Num.isNaN), ∞ or -∞, and `True` otherwise. +## When given a [F64] or [F32] value, returns `Bool.false` if that value is +## [*NaN*](Num.isNaN), ∞ or -∞, and `Bool.true` otherwise. ## -## Always returns `True` when given a [Dec]. +## Always returns `Bool.true` when given a [Dec]. ## ## This is the opposite of #isInfinite, except when given [*NaN*](Num.isNaN). Both -## #isFinite and #isInfinite return `False` for [*NaN*](Num.isNaN). +## #isFinite and #isInfinite return `Bool.false` for [*NaN*](Num.isNaN). # isFinite : Frac * -> Bool -## When given a [F64] or [F32] value, returns `True` if that value is either -## ∞ or -∞, and `False` otherwise. +## When given a [F64] or [F32] value, returns `Bool.true` if that value is either +## ∞ or -∞, and `Bool.false` otherwise. ## -## Always returns `False` when given a [Dec]. +## Always returns `Bool.false` when given a [Dec]. ## ## This is the opposite of #isFinite, except when given [*NaN*](Num.isNaN). Both -## #isFinite and #isInfinite return `False` for [*NaN*](Num.isNaN). +## #isFinite and #isInfinite return `Bool.false` for [*NaN*](Num.isNaN). # isInfinite : Frac * -> Bool -## When given a [F64] or [F32] value, returns `True` if that value is -## *NaN* ([not a number](https://en.wikipedia.org/wiki/NaN)), and `False` otherwise. +## When given a [F64] or [F32] value, returns `Bool.true` if that value is +## *NaN* ([not a number](https://en.wikipedia.org/wiki/NaN)), and `Bool.false` otherwise. ## -## Always returns `False` when given a [Dec]. +## Always returns `Bool.false` when given a [Dec]. ## ## >>> Num.isNaN 12.3 ## ## >>> Num.isNaN (Num.pow -1 0.5) ## ## *NaN* is unusual from other numberic values in that: -## * *NaN* is not equal to any other number, even itself. [Bool.isEq] always returns `False` if either argument is *NaN*. -## * *NaN* has no ordering, so [isLt], [isLte], [isGt], and [isGte] always return `False` if either argument is *NaN*. +## * *NaN* is not equal to any other number, even itself. [Bool.isEq] always returns `Bool.false` if either argument is *NaN*. +## * *NaN* has no ordering, so [isLt], [isLte], [isGt], and [isGte] always return `Bool.false` if either argument is *NaN*. ## ## These rules come from the [IEEE-754](https://en.wikipedia.org/wiki/IEEE_754) ## floating point standard. Because almost all modern processors are built to @@ -1306,12 +1306,12 @@ toF64Checked : Num * -> Result F64 [OutOfBounds]* # isNaN : Frac * -> Bool ## Returns the higher of two numbers. ## -## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN* +## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN* ## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).) # max : Num a, Num a -> Num a ## Returns the lower of two numbers. ## -## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN* +## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN* ## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).) # min : Num a, Num a -> Num a # Branchless implementation that works for all numeric types: diff --git a/crates/compiler/builtins/roc/Result.roc b/crates/compiler/builtins/roc/Result.roc index e1a9ad1926..967c901567 100644 --- a/crates/compiler/builtins/roc/Result.roc +++ b/crates/compiler/builtins/roc/Result.roc @@ -6,23 +6,23 @@ interface Result ## okay, or else there was an error of some sort. Result ok err : [Ok ok, Err err] -## Return True if the result indicates a success, else return False +## Return `Bool.true` if the result indicates a success, else return `Bool.false` ## ## >>> Result.isOk (Ok 5) isOk : Result ok err -> Bool isOk = \result -> when result is - Ok _ -> True - Err _ -> False + Ok _ -> Bool.true + Err _ -> Bool.false -## Return True if the result indicates a failure, else return False +## Return `Bool.true` if the result indicates a failure, else return `Bool.false` ## ## >>> Result.isErr (Err "uh oh") isErr : Result ok err -> Bool isErr = \result -> when result is - Ok _ -> False - Err _ -> True + Ok _ -> Bool.false + Err _ -> Bool.true ## If the result is `Ok`, return the value it holds. Otherwise, return ## the given default value. diff --git a/crates/compiler/builtins/roc/Str.roc b/crates/compiler/builtins/roc/Str.roc index f595d56250..5331fb9c88 100644 --- a/crates/compiler/builtins/roc/Str.roc +++ b/crates/compiler/builtins/roc/Str.roc @@ -131,7 +131,7 @@ Utf8ByteProblem : [ Utf8Problem : { byteIndex : Nat, problem : Utf8ByteProblem } -## Returns `True` if the string is empty, and `False` otherwise. +## Returns `Bool.true` if the string is empty, and `Bool.false` otherwise. ## ## >>> Str.isEmpty "hi!" ## @@ -167,10 +167,10 @@ repeat : Str, Nat -> Str countGraphemes : Str -> Nat ## If the string begins with a [Unicode code point](http://www.unicode.org/glossary/#code_point) -## equal to the given [U32], return `True`. Otherwise return `False`. +## equal to the given [U32], return `Bool.true`. Otherwise return `Bool.false`. ## ## If the given [Str] is empty, or if the given [U32] is not a valid -## code point, this will return `False`. +## code point, this will return `Bool.false`. ## ## **Performance Note:** This runs slightly faster than [Str.startsWith], so ## if you want to check whether a string begins with something that's representable @@ -452,9 +452,9 @@ matchesAtHelp = \haystack, haystackIndex, needle, needleIndex, endIndex -> if Str.getUnsafe haystack haystackIndex == Str.getUnsafe needle needleIndex then matchesAtHelp haystack (haystackIndex + 1) needle (needleIndex + 1) endIndex else - False + Bool.false else - True + Bool.true ## Walks over the string's UTF-8 bytes, calling a function which updates a state using each ## UTF-8 `U8` byte as well as the index of that byte within the string. diff --git a/crates/compiler/can/src/scope.rs b/crates/compiler/can/src/scope.rs index 54fda6ae11..3022c9f3b3 100644 --- a/crates/compiler/can/src/scope.rs +++ b/crates/compiler/can/src/scope.rs @@ -690,8 +690,6 @@ mod test { assert_eq!( &idents, &[ - Ident::from("False"), - Ident::from("True"), Ident::from("Str"), Ident::from("List"), Ident::from("Ok"), @@ -715,8 +713,6 @@ mod test { assert_eq!( &idents, &[ - Ident::from("False"), - Ident::from("True"), Ident::from("Str"), Ident::from("List"), Ident::from("Ok"), diff --git a/crates/compiler/gen_dev/src/lib.rs b/crates/compiler/gen_dev/src/lib.rs index ea36f1f9b3..bcdcf51862 100644 --- a/crates/compiler/gen_dev/src/lib.rs +++ b/crates/compiler/gen_dev/src/lib.rs @@ -728,6 +728,16 @@ trait Backend<'a> { self.load_literal_symbols(args); self.build_fn_call(sym, fn_name, args, arg_layouts, ret_layout) } + Symbol::BOOL_TRUE => { + let bool_layout = Layout::Builtin(Builtin::Bool); + self.load_literal(&Symbol::DEV_TMP, &bool_layout, &Literal::Bool(true)); + self.return_symbol(&Symbol::DEV_TMP, &bool_layout); + } + Symbol::BOOL_FALSE => { + let bool_layout = Layout::Builtin(Builtin::Bool); + self.load_literal(&Symbol::DEV_TMP, &bool_layout, &Literal::Bool(false)); + self.return_symbol(&Symbol::DEV_TMP, &bool_layout); + } _ => todo!("the function, {:?}", func_sym), } } diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index f6d5560f24..0935e0509b 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -1181,10 +1181,8 @@ define_builtins! { } 4 BOOL: "Bool" => { 0 BOOL_BOOL: "Bool" // the Bool.Bool type alias - 1 BOOL_FALSE: "False" imported // Bool.Bool = [False, True] - // NB: not strictly needed; used for finding tag names in error suggestions - 2 BOOL_TRUE: "True" imported // Bool.Bool = [False, True] - // NB: not strictly needed; used for finding tag names in error suggestions + 1 BOOL_FALSE: "false" + 2 BOOL_TRUE: "true" 3 BOOL_AND: "and" 4 BOOL_OR: "or" 5 BOOL_NOT: "not" diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 2ae51ddeaf..b68f39dee6 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -3919,11 +3919,13 @@ fn specialize_naked_symbol<'a>( std::vec::Vec::new(), layout_cache, assigned, - env.arena.alloc(match hole { - Stmt::Jump(id, _) => Stmt::Jump(*id, env.arena.alloc([assigned])), - Stmt::Ret(_) => Stmt::Ret(assigned), - _ => unreachable!(), - }), + match hole { + Stmt::Jump(id, _) => env + .arena + .alloc(Stmt::Jump(*id, env.arena.alloc([assigned]))), + Stmt::Ret(_) => env.arena.alloc(Stmt::Ret(assigned)), + hole => hole, + }, ); return result; @@ -7597,7 +7599,31 @@ where // if this is an imported symbol, then we must make sure it is // specialized, and wrap the original in a function pointer. let mut result = result; - for (_, (variable, left)) in needed_specializations_of_left { + + let no_specializations_needed = needed_specializations_of_left.len() == 0; + let needed_specializations_of_left = needed_specializations_of_left + .map(|(_, spec)| Some(spec)) + // HACK: sometimes specializations can be lost, for example for `x` in + // x = Bool.true + // p = \_ -> x == 1 + // that's because when specializing `p`, we collect specializations for `x`, but then + // drop all of them when leaving the body of `p`, because `x` is an argument of `p` in + // such a case. + // So, if we have no recorded specializations, suppose we are in a case like this, and + // generate the default implementation. + // + // TODO: we should fix this properly. I think the way to do it is to only have proc + // specialization only drop specializations of non-captured symbols. That's because + // captured symbols can only ever be specialized outside the closure. + // After that is done, remove this hack. + .chain(if no_specializations_needed { + [Some((variable, left))] + } else { + [None] + }) + .flatten(); + + for (variable, left) in needed_specializations_of_left { add_needed_external(procs, env, variable, LambdaName::no_niche(right)); let res_layout = layout_cache.from_var(env.arena, variable, env.subs); diff --git a/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.result-ast b/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.result-ast index 9395ab1ab7..541cc4e111 100644 --- a/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.result-ast +++ b/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.result-ast @@ -53,7 +53,7 @@ When( ], ), ], - value: @52-73 Apply( + value: @52-78 Apply( @52-56 Tag( "Node", ), @@ -64,10 +64,11 @@ When( @63-64 Num( "0", ), - @65-70 Tag( - "False", - ), - @71-73 Var { + @65-75 Var { + module_name: "Bool", + ident: "false", + }, + @76-78 Var { module_name: "", ident: "ry", }, diff --git a/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.roc b/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.roc index c397c8ce35..3bcd97676f 100644 --- a/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.roc +++ b/crates/compiler/parse/tests/snapshots/pass/pattern_with_space_in_parens.expr.roc @@ -1,2 +1,2 @@ when Delmin (Del rx) 0 is - Delmin (Del ry ) _ -> Node Black 0 False ry + Delmin (Del ry ) _ -> Node Black 0 Bool.false ry diff --git a/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.result-ast b/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.result-ast index e8a3539470..3375d05218 100644 --- a/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.result-ast +++ b/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.result-ast @@ -7,18 +7,19 @@ BinOps( @2-3 Star, ), ], - @4-25 If( + @4-30 If( [ ( - @7-11 Tag( - "True", - ), - @17-18 Num( + @7-16 Var { + module_name: "Bool", + ident: "true", + }, + @22-23 Num( "1", ), ), ], - @24-25 Num( + @29-30 Num( "1", ), ), diff --git a/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.roc b/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.roc index 50a84b0a4d..1ca4ae5946 100644 --- a/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.roc +++ b/crates/compiler/parse/tests/snapshots/pass/plus_if.expr.roc @@ -1 +1 @@ -1 * if True then 1 else 1 +1 * if Bool.true then 1 else 1 diff --git a/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.result-ast b/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.result-ast index 5301d17702..43a85f4464 100644 --- a/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.result-ast +++ b/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.result-ast @@ -1,28 +1,29 @@ Record( [ - @1-26 RequiredValue( + @1-31 RequiredValue( @1-2 "x", [], - @5-26 If( + @5-31 If( [ ( - @8-12 Tag( - "True", - ), - @18-19 Num( + @8-17 Var { + module_name: "Bool", + ident: "true", + }, + @23-24 Num( "1", ), ), ], - @25-26 Num( + @30-31 Num( "2", ), ), ), - @28-32 RequiredValue( - @28-29 "y", + @33-37 RequiredValue( + @33-34 "y", [], - @31-32 Num( + @36-37 Num( "3", ), ), diff --git a/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.roc b/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.roc index 7c186e5d31..ccec321db1 100644 --- a/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.roc +++ b/crates/compiler/parse/tests/snapshots/pass/record_with_if.expr.roc @@ -1 +1 @@ -{x : if True then 1 else 2, y: 3 } \ No newline at end of file +{x : if Bool.true then 1 else 2, y: 3 } \ No newline at end of file diff --git a/crates/compiler/solve/tests/solve_expr.rs b/crates/compiler/solve/tests/solve_expr.rs index ae6dc7dbcb..ca4ee09671 100644 --- a/crates/compiler/solve/tests/solve_expr.rs +++ b/crates/compiler/solve/tests/solve_expr.rs @@ -1385,7 +1385,7 @@ mod solve_expr { infer_eq( indoc!( r#" - if True then + if Bool.true then 42 else 24 @@ -3812,7 +3812,7 @@ mod solve_expr { when x is 2 | 3 -> 0 a if a < 20 -> 1 - 3 | 4 if False -> 2 + 3 | 4 if Bool.false -> 2 _ -> 3 "# ), @@ -4054,7 +4054,7 @@ mod solve_expr { r#" \rec -> { x, y } : { x : I64, y ? Bool }* - { x, y ? False } = rec + { x, y ? Bool.false } = rec { x, y } "# @@ -5015,7 +5015,7 @@ mod solve_expr { infer_eq_without_problem( indoc!( r#" - badComics: Bool -> [CowTools _, Thagomizer _] + badComics: [True, False] -> [CowTools _, Thagomizer _] badComics = \c -> when c is True -> CowTools "The Far Side" @@ -5023,7 +5023,7 @@ mod solve_expr { badComics "# ), - "Bool -> [CowTools Str, Thagomizer Str]", + "[False, True] -> [CowTools Str, Thagomizer Str]", ) } @@ -5929,7 +5929,7 @@ mod solve_expr { infer_eq_without_problem( indoc!( r#" - if True then List.first [] else Str.toI64 "" + if Bool.true then List.first [] else Str.toI64 "" "# ), "Result I64 [InvalidNumStr, ListWasEmpty]*", @@ -6220,7 +6220,7 @@ mod solve_expr { r#" app "test" provides [foo] to "./platform" - foo : Bool -> Str + foo : [True, False] -> Str foo = \ob -> # ^^ when ob is @@ -6232,8 +6232,8 @@ mod solve_expr { "# ), @r###" - ob : Bool - ob : Bool + ob : [False, True] + ob : [False, True] True : [False, True] False : [False, True] "### @@ -6912,7 +6912,7 @@ mod solve_expr { indoc!( r#" f : _ -> _ - f = \_ -> if False then "" else f "" + f = \_ -> if Bool.false then "" else f "" f "# @@ -6928,7 +6928,7 @@ mod solve_expr { r#" f : _ -> Str f = \s -> g s - g = \s -> if True then s else f s + g = \s -> if Bool.true then s else f s g "# @@ -7430,7 +7430,7 @@ mod solve_expr { # ^^ (f A (@C {}) (@D {})) # ^ - if True + if Bool.true then it (@E {}) # ^^ else it (@F {}) @@ -7741,8 +7741,8 @@ mod solve_expr { infer_queries!( indoc!( r#" - x = True - y = False + x = Bool.true + y = Bool.false a = "foo" b = "bar" @@ -7756,8 +7756,8 @@ mod solve_expr { "# ), @r###" - foo : {} -[[foo(5) [True]* [False]* Str Str]]-> Str - bar : {} -[[bar(6) [True]* [False]* Str Str]]-> Str + foo : {} -[[foo(5) Bool Bool Str Str]]-> Str + bar : {} -[[bar(6) Bool Bool Str Str]]-> Str "### ); } diff --git a/crates/compiler/test_gen/src/gen_compare.rs b/crates/compiler/test_gen/src/gen_compare.rs index 31db80dddd..da9e2a2437 100644 --- a/crates/compiler/test_gen/src/gen_compare.rs +++ b/crates/compiler/test_gen/src/gen_compare.rs @@ -118,9 +118,9 @@ fn eq_bool_tag() { indoc!( r#" true : Bool - true = True + true = Bool.true - true == True + true == Bool.true "# ), true, @@ -135,9 +135,9 @@ fn neq_bool_tag() { indoc!( r#" true : Bool - true = True + true = Bool.true - true == False + true == Bool.false "# ), false, diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index 27d6dfe495..753feddfcc 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -54,15 +54,10 @@ fn int_list_literal() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn bool_list_literal() { - // NOTE: make sure to explicitly declare the elements to be of type bool, or - // use both True and False; only using one of them causes the list to in practice be - // of type `List [True]` or `List [False]`, those are tag unions with one constructor - // and not fields, and don't have a runtime representation. assert_evals_to!( indoc!( r#" - false : Bool - false = False + false = Bool.false [false] "# @@ -72,7 +67,7 @@ fn bool_list_literal() { ); assert_evals_to!( - "[True, False, True]", + "[Bool.true, Bool.false, Bool.true]", RocList::from_slice(&[true, false, true]), RocList ); @@ -81,7 +76,7 @@ fn bool_list_literal() { indoc!( r#" false : Bool - false = False + false = Bool.false [false] "# @@ -94,7 +89,7 @@ fn bool_list_literal() { indoc!( r#" true : Bool - true = True + true = Bool.true List.repeat true 23 "# @@ -107,7 +102,7 @@ fn bool_list_literal() { indoc!( r#" true : Bool - true = True + true = Bool.true List.repeat { x: true, y: true } 23 "# @@ -120,7 +115,7 @@ fn bool_list_literal() { indoc!( r#" true : Bool - true = True + true = Bool.true List.repeat { x: true, y: true, a: true, b: true, c: true, d : true, e: true, f: true } 23 "# @@ -503,7 +498,7 @@ fn list_drop_at_shared() { indoc!( r#" list : List I64 - list = [if True then 4 else 4, 5, 6] + list = [if Bool.true then 4 else 4, 5, 6] { newList: List.dropAt list 0, original: list } "# @@ -527,7 +522,7 @@ fn list_drop_if_empty_list_of_int() { empty : List I64 empty = [] - List.dropIf empty \_ -> True + List.dropIf empty \_ -> Bool.true "# ), RocList::::from_slice(&[]), @@ -542,7 +537,7 @@ fn list_drop_if_empty_list() { indoc!( r#" alwaysTrue : I64 -> Bool - alwaysTrue = \_ -> True + alwaysTrue = \_ -> Bool.true List.dropIf [] alwaysTrue "# @@ -558,7 +553,7 @@ fn list_drop_if_always_false_for_non_empty_list() { assert_evals_to!( indoc!( r#" - List.dropIf [1,2,3,4,5,6,7,8] (\_ -> False) + List.dropIf [1,2,3,4,5,6,7,8] (\_ -> Bool.false) "# ), RocList::from_slice(&[1, 2, 3, 4, 5, 6, 7, 8]), @@ -572,7 +567,7 @@ fn list_drop_if_always_true_for_non_empty_list() { assert_evals_to!( indoc!( r#" - List.dropIf [1,2,3,4,5,6,7,8] (\_ -> True) + List.dropIf [1,2,3,4,5,6,7,8] (\_ -> Bool.true) "# ), RocList::::from_slice(&[]), @@ -635,7 +630,7 @@ fn list_drop_last_mutable() { indoc!( r#" list : List I64 - list = [if True then 4 else 4, 5, 6] + list = [if Bool.true then 4 else 4, 5, 6] { newList: List.dropLast list, original: list } "# @@ -734,7 +729,7 @@ fn list_append_to_empty_list_of_int() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn list_append_bools() { assert_evals_to!( - "List.append [True, False] True", + "List.append [Bool.true, Bool.false] Bool.true", RocList::from_slice(&[true, false, true]), RocList ); @@ -793,7 +788,7 @@ fn list_prepend() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn list_prepend_bools() { assert_evals_to!( - "List.prepend [True, False] True", + "List.prepend [Bool.true, Bool.false] Bool.true", RocList::from_slice(&[true, true, false]), RocList ); @@ -971,7 +966,7 @@ fn list_keep_if_empty_list_of_int() { empty = [] - List.keepIf empty \_ -> True + List.keepIf empty \_ -> Bool.true "# ), RocList::::from_slice(&[]), @@ -987,7 +982,7 @@ fn list_keep_if_empty_list() { r#" alwaysTrue : I64 -> Bool alwaysTrue = \_ -> - True + Bool.true List.keepIf [] alwaysTrue @@ -1006,7 +1001,7 @@ fn list_keep_if_always_true_for_non_empty_list() { r#" alwaysTrue : I64 -> Bool alwaysTrue = \_ -> - True + Bool.true oneThroughEight : List I64 oneThroughEight = @@ -1028,7 +1023,7 @@ fn list_keep_if_always_false_for_non_empty_list() { r#" alwaysFalse : I64 -> Bool alwaysFalse = \_ -> - False + Bool.false List.keepIf [1,2,3,4,5,6,7,8] alwaysFalse "# @@ -2308,7 +2303,7 @@ fn quicksort() { partitionHelp : Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))] partitionHelp = \i, j, list, high, pivot -> # if j < high then - if False then + if Bool.false then when List.get list j is Ok value -> if value <= pivot then @@ -2791,7 +2786,7 @@ fn list_any() { #[test] #[cfg(any(feature = "gen-llvm"))] fn list_any_empty_with_unknown_element_type() { - assert_evals_to!("List.any [] (\\_ -> True)", false, bool); + assert_evals_to!("List.any [] (\\_ -> Bool.true)", false, bool); } #[test] @@ -2806,7 +2801,7 @@ fn list_all() { #[test] #[cfg(any(feature = "gen-llvm"))] fn list_all_empty_with_unknown_element_type() { - assert_evals_to!("List.all [] (\\_ -> True)", true, bool); + assert_evals_to!("List.all [] (\\_ -> Bool.true)", true, bool); } #[test] @@ -2825,7 +2820,7 @@ fn lists_with_incompatible_type_param_in_if() { list2 = [""] - x = if True then list1 else list2 + x = if Bool.true then list1 else list2 "" "# @@ -2864,7 +2859,7 @@ fn empty_list_of_function_type() { myClosure = \_ -> "bar" choose = - if False then + if Bool.false then myList else [myClosure] @@ -3003,7 +2998,7 @@ fn list_find_empty_layout() { assert_evals_to!( indoc!( r#" - List.findFirst [] \_ -> True + List.findFirst [] \_ -> Bool.true "# ), // [Ok [], Err [NotFound]] gets unwrapped all the way to just [NotFound], @@ -3015,7 +3010,7 @@ fn list_find_empty_layout() { assert_evals_to!( indoc!( r#" - List.findLast [] \_ -> True + List.findLast [] \_ -> Bool.true "# ), // [Ok [], Err [NotFound]] gets unwrapped all the way to just [NotFound], diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index d6d32c986a..045ae3dd5d 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -3800,7 +3800,7 @@ fn condition_polymorphic_num_becomes_float() { assert_evals_to!( indoc!( r#" - x = if True then 2 else 3 + x = if Bool.true then 2 else 3 x * 5f32 "# ), diff --git a/crates/compiler/test_gen/src/gen_primitives.rs b/crates/compiler/test_gen/src/gen_primitives.rs index 50031f4a6e..01179bf886 100644 --- a/crates/compiler/test_gen/src/gen_primitives.rs +++ b/crates/compiler/test_gen/src/gen_primitives.rs @@ -983,7 +983,7 @@ fn undefined_variable() { assert_evals_to!( indoc!( r#" - if True then + if Bool.true then x + z else y + z @@ -1262,10 +1262,10 @@ fn linked_list_is_singleton() { isSingleton = \list -> when list is Cons _ Nil -> - True + Bool.true _ -> - False + Bool.false main : Bool main = @@ -1297,10 +1297,10 @@ fn linked_list_is_empty_1() { isEmpty = \list -> when list is Cons _ _ -> - False + Bool.false Nil -> - True + Bool.true main : Bool main = @@ -1329,10 +1329,10 @@ fn linked_list_is_empty_2() { isEmpty = \list -> when list is Cons _ _ -> - False + Bool.false Nil -> - True + Bool.true main : Bool main = @@ -2006,9 +2006,9 @@ fn hof_conditional() { assert_evals_to!( indoc!( r#" - passTrue = \f -> f True + passTrue = \f -> f Bool.true - passTrue (\trueVal -> if trueVal then False else True) + passTrue (\trueVal -> if trueVal then Bool.false else Bool.true) "# ), 0, @@ -2087,8 +2087,8 @@ fn fingertree_basic() { main : Bool main = when cons 0x1 Nil is - Unit 1 -> True - _ -> False + Unit 1 -> Bool.true + _ -> Bool.false "# ), true, @@ -2136,8 +2136,8 @@ fn rosetree_basic() { x : Tree F64 x = singleton 3 when x is - Tree 3.0 _ -> True - _ -> False + Tree 3.0 _ -> Bool.true + _ -> Bool.false "# ), true, @@ -2338,7 +2338,7 @@ fn multiple_increment() { leaf = Leaf m : Map - m = Node Black (Node Black leaf 10 False leaf) 11 False (Node Black leaf 12 False (Node Red leaf 13 False leaf)) + m = Node Black (Node Black leaf 10 Bool.false leaf) 11 Bool.false (Node Black leaf 12 Bool.false (Node Red leaf 13 Bool.false leaf)) when m is Leaf -> 0 @@ -2550,7 +2550,7 @@ fn increment_or_double_closure() { two = 2 b : Bool - b = True + b = Bool.true increment : I64 -> I64 increment = \x -> x + one @@ -2558,7 +2558,7 @@ fn increment_or_double_closure() { double : I64 -> I64 double = \x -> if b then x * two else x - f = (if True then increment else double) + f = (if Bool.true then increment else double) apply f 42 "# @@ -2879,7 +2879,7 @@ fn unresolved_tvar_when_capture_is_unused() { main : I64 main = r : Bool - r = False + r = Bool.false p1 = (\_ -> r == (1 == 1)) oneOfResult = List.map [p1] (\p -> p Green) @@ -3399,7 +3399,7 @@ fn polymorphic_lambda_set_usage() { r#" id1 = \x -> x id2 = \y -> y - id = if True then id1 else id2 + id = if Bool.true then id1 else id2 id 9u8 "# @@ -3417,7 +3417,7 @@ fn polymorphic_lambda_set_multiple_specializations() { r#" id1 = \x -> x id2 = \y -> y - id = if True then id1 else id2 + id = if Bool.true then id1 else id2 (id 9u8) + Num.toU8 (id 16u16) "# @@ -3449,7 +3449,7 @@ fn list_map2_conslist() { } #[test] -#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn mutual_recursion_top_level_defs() { assert_evals_to!( indoc!( @@ -3458,14 +3458,14 @@ fn mutual_recursion_top_level_defs() { isEven = \n -> when n is - 0 -> True - 1 -> False + 0 -> Bool.true + 1 -> Bool.false _ -> isOdd (n - 1) isOdd = \n -> when n is - 0 -> False - 1 -> True + 0 -> Bool.false + 1 -> Bool.true _ -> isEven (n - 1) main = isOdd 11 @@ -3486,7 +3486,7 @@ fn polymorphic_lambda_captures_polymorphic_value() { f1 = \_ -> x - f = if True then f1 else f1 + f = if Bool.true then f1 else f1 f {} "# ), @@ -3506,13 +3506,14 @@ fn lambda_capture_niche_u64_vs_u8_capture() { \{} -> Num.toStr val - x : [True, False] - x = True + x : Bool + x = Bool.true fun = - when x is - True -> capture 123u64 - False -> capture 18u8 + if x then + capture 123u64 + else + capture 18u8 fun {} "# @@ -3608,12 +3609,13 @@ fn lambda_capture_niches_have_captured_function_in_closure() { fun = \x -> h = - when x is - True -> after (\{} -> "") f - False -> after (\{} -> {s1: "s1"}) g + if x then + after (\{} -> "") f + else + after (\{} -> {s1: "s1"}) g h {} - {a: fun False, b: fun True} + {a: fun Bool.false, b: fun Bool.true} "# ), (RocStr::from("s1"), RocStr::from("fun f")), @@ -4007,10 +4009,10 @@ fn mutually_recursive_captures() { indoc!( r#" x : Bool - x = True + x = Bool.true y : Bool - y = False + y = Bool.false a = "foo" b = "bar" @@ -4035,9 +4037,9 @@ fn monomorphization_sees_polymorphic_recursion() { foo : a, Bool -> Str foo = \in, b -> if b then "done" else bar in - bar = \_ -> foo {} True + bar = \_ -> foo {} Bool.true - foo "" False + foo "" Bool.false "# ), RocStr::from("done"), diff --git a/crates/compiler/test_gen/src/gen_records.rs b/crates/compiler/test_gen/src/gen_records.rs index d339ba24a7..823b260955 100644 --- a/crates/compiler/test_gen/src/gen_records.rs +++ b/crates/compiler/test_gen/src/gen_records.rs @@ -309,7 +309,7 @@ fn f64_record2_literal() { // indoc!( // r#" // record : { a : Bool, b : Bool, c : Bool, d : Bool } -// record = { a: True, b: True, c : True, d : Bool } +// record = { a: Bool.true, b: Bool.true, c : Bool.true, d : Bool } // record // "# @@ -366,7 +366,7 @@ fn bool_literal() { indoc!( r#" x : Bool - x = True + x = Bool.true x "# @@ -894,7 +894,9 @@ fn booleans_in_record() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn alignment_in_record() { assert_evals_to!( - indoc!("{ c: 32, b: if True then Red else if True then Green else Blue, a: 1 == 1 }"), + indoc!( + "{ c: 32, b: if Bool.true then Red else if Bool.true then Green else Blue, a: 1 == 1 }" + ), (32i64, true, 2u8), (i64, bool, u8) ); diff --git a/crates/compiler/test_gen/src/gen_refcount.rs b/crates/compiler/test_gen/src/gen_refcount.rs index 905b4b4267..dad781e82a 100644 --- a/crates/compiler/test_gen/src/gen_refcount.rs +++ b/crates/compiler/test_gen/src/gen_refcount.rs @@ -483,7 +483,7 @@ fn boxed_str_dec() { s = Str.concat "A long enough string " "to be heap-allocated" b = Box.box s - if False then + if Bool.false then ReturnTheBox b else DeallocateEverything diff --git a/crates/compiler/test_gen/src/gen_result.rs b/crates/compiler/test_gen/src/gen_result.rs index a8dba91329..53cc8aaf76 100644 --- a/crates/compiler/test_gen/src/gen_result.rs +++ b/crates/compiler/test_gen/src/gen_result.rs @@ -264,7 +264,7 @@ fn roc_result_err() { fn issue_2583_specialize_errors_behind_unified_branches() { assert_evals_to!( r#" - if True then List.first [15] else Str.toI64 "" + if Bool.true then List.first [15] else Str.toI64 "" "#, RocResult::ok(15i64), RocResult diff --git a/crates/compiler/test_gen/src/gen_tags.rs b/crates/compiler/test_gen/src/gen_tags.rs index eda3643fdf..7070031e3b 100644 --- a/crates/compiler/test_gen/src/gen_tags.rs +++ b/crates/compiler/test_gen/src/gen_tags.rs @@ -115,8 +115,8 @@ fn true_is_true() { assert_evals_to!( indoc!( r#" - bool : [True, False] - bool = True + bool : Bool + bool = Bool.true bool "# @@ -132,8 +132,8 @@ fn false_is_false() { assert_evals_to!( indoc!( r#" - bool : [True, False] - bool = False + bool : Bool + bool = Bool.false bool "# @@ -214,8 +214,8 @@ fn basic_enum() { // isEmpty : LinkedList a -> Bool // isEmpty = \list -> // when list is -// Nil -> True -// Cons _ _ -> False +// Nil -> Bool.true +// Cons _ _ -> Bool.false // // isEmpty (Cons 4 Nil) // "# @@ -232,14 +232,14 @@ fn even_odd() { r#" even = \n -> when n is - 0 -> True - 1 -> False + 0 -> Bool.true + 1 -> Bool.false _ -> odd (n - 1) odd = \n -> when n is - 0 -> False - 1 -> True + 0 -> Bool.false + 1 -> Bool.true _ -> even (n - 1) odd 5 && even 42 @@ -256,7 +256,7 @@ fn gen_literal_true() { assert_evals_to!( indoc!( r#" - if True then -1 else 1 + if Bool.true then -1 else 1 "# ), -1, @@ -270,7 +270,7 @@ fn gen_if_float() { assert_evals_to!( indoc!( r#" - if True then -1.0 else 1.0 + if Bool.true then -1.0 else 1.0 "# ), -1.0, @@ -424,8 +424,8 @@ fn maybe_is_just_not_nested() { isJust : Maybe a -> Bool isJust = \list -> when list is - Nothing -> False - Just _ -> True + Nothing -> Bool.false + Just _ -> Bool.true main = isJust (Just 42) @@ -447,8 +447,8 @@ fn maybe_is_just_nested() { isJust : Maybe a -> Bool isJust = \list -> when list is - Nothing -> False - Just _ -> True + Nothing -> Bool.false + Just _ -> Bool.true isJust (Just 42) "# @@ -601,7 +601,7 @@ fn if_guard_pattern_false() { r#" wrapper = \{} -> when 2 is - 2 if False -> 0 + 2 if Bool.false -> 0 _ -> 42 wrapper {} @@ -620,7 +620,7 @@ fn if_guard_switch() { r#" wrapper = \{} -> when 2 is - 2 | 3 if False -> 0 + 2 | 3 if Bool.false -> 0 _ -> 42 wrapper {} @@ -639,7 +639,7 @@ fn if_guard_pattern_true() { r#" wrapper = \{} -> when 2 is - 2 if True -> 42 + 2 if Bool.true -> 42 _ -> 0 wrapper {} @@ -658,7 +658,7 @@ fn if_guard_exhaustiveness() { r#" wrapper = \{} -> when 2 is - _ if False -> 0 + _ if Bool.false -> 0 _ -> 42 wrapper {} @@ -814,7 +814,7 @@ fn join_point_if() { indoc!( r#" x = - if True then 1 else 2 + if Bool.true then 1 else 2 x "# @@ -895,7 +895,7 @@ fn alignment_in_single_tag_construction() { assert_evals_to!(indoc!("Three (1 == 1) 32"), (32i64, true), (i64, bool)); assert_evals_to!( - indoc!("Three (1 == 1) (if True then Red else if True then Green else Blue) 32"), + indoc!("Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32"), (32i64, true, 2u8), (i64, bool, u8) ); @@ -921,7 +921,7 @@ fn alignment_in_single_tag_pattern_match() { assert_evals_to!( indoc!( r"# - x = Three (1 == 1) (if True then Red else if True then Green else Blue) 32 + x = Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32 when x is Three bool color int -> @@ -958,7 +958,7 @@ fn alignment_in_multi_tag_construction_three() { indoc!( r"# x : [Three Bool [Red, Green, Blue] I64, Empty] - x = Three (1 == 1) (if True then Red else if True then Green else Blue) 32 + x = Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32 x #" @@ -982,7 +982,7 @@ fn alignment_in_multi_tag_pattern_match() { { bool, int } Empty -> - { bool: False, int: 0 } + { bool: Bool.false, int: 0 } #" ), (32i64, true), @@ -993,13 +993,13 @@ fn alignment_in_multi_tag_pattern_match() { indoc!( r"# x : [Three Bool [Red, Green, Blue] I64, Empty] - x = Three (1 == 1) (if True then Red else if True then Green else Blue) 32 + x = Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32 when x is Three bool color int -> { bool, color, int } Empty -> - { bool: False, color: Red, int: 0 } + { bool: Bool.false, color: Red, int: 0 } #" ), (32i64, true, 2u8), @@ -1237,8 +1237,8 @@ fn monomorphized_tag() { assert_evals_to!( indoc!( r#" - b = False - f : Bool, [True, False, Idk] -> U8 + b = Bar + f : [Foo, Bar], [Bar, Baz] -> U8 f = \_, _ -> 18 f b b "# @@ -1853,10 +1853,10 @@ fn error_type_in_tag_union_payload() { r#" f : ([] -> Bool) -> Bool f = \fun -> - if True then + if Bool.true then fun 42 else - False + Bool.false f (\x -> x) "# diff --git a/crates/compiler/test_gen/src/wasm_str.rs b/crates/compiler/test_gen/src/wasm_str.rs index 02e5645cc2..d236479ef3 100644 --- a/crates/compiler/test_gen/src/wasm_str.rs +++ b/crates/compiler/test_gen/src/wasm_str.rs @@ -299,14 +299,14 @@ fn small_str_zeroed_literal() { reusedSpace = createStr isForRealThisTime # Unoptimised 'if' ensures that we don't just allocate in the caller's frame - if True then + if Bool.true then reusedSpace else reusedSpace main = - garbage = functionWithReusedSpace False - functionWithReusedSpace True + garbage = functionWithReusedSpace Bool.false + functionWithReusedSpace Bool.true "# ), [ diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt index ac96381481..81cc10159e 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.385 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.381 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.385; + ret List.381; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt index 8c4c9cb47d..5c345ed6cd 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.385 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.381 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.385; + ret List.381; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/closure_in_list.txt b/crates/compiler/test_mono/generated/closure_in_list.txt index 26e9a06eae..edb31caf09 100644 --- a/crates/compiler/test_mono/generated/closure_in_list.txt +++ b/crates/compiler/test_mono/generated/closure_in_list.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure Test.1 (Test.5): let Test.2 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/dict.txt b/crates/compiler/test_mono/generated/dict.txt index 703c5f429d..1052346f47 100644 --- a/crates/compiler/test_mono/generated/dict.txt +++ b/crates/compiler/test_mono/generated/dict.txt @@ -1,14 +1,14 @@ procedure Dict.1 (): - let Dict.102 : List {[], []} = Array []; - ret Dict.102; + let Dict.100 : List {[], []} = Array []; + ret Dict.100; -procedure Dict.7 (Dict.96): - let Dict.101 : U64 = CallByName List.6 Dict.96; - ret Dict.101; +procedure Dict.7 (Dict.94): + let Dict.99 : U64 = CallByName List.6 Dict.94; + ret Dict.99; procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure Test.0 (): let Test.2 : List {[], []} = CallByName Dict.1; diff --git a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt index 70263729b3..5886c61084 100644 --- a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt +++ b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt @@ -1,55 +1,59 @@ +procedure Bool.1 (): + let Bool.11 : Int1 = false; + ret Bool.11; + procedure List.2 (List.90, List.91): - let List.390 : U64 = CallByName List.6 List.90; - let List.387 : Int1 = CallByName Num.22 List.91 List.390; - if List.387 then - let List.389 : {} = CallByName List.66 List.90 List.91; - let List.388 : [C {}, C {}] = TagId(1) List.389; - ret List.388; + let List.387 : U64 = CallByName List.6 List.90; + let List.383 : Int1 = CallByName Num.22 List.91 List.387; + if List.383 then + let List.385 : {} = CallByName List.66 List.90 List.91; + let List.384 : [C {}, C {}] = TagId(1) List.385; + ret List.384; else - let List.386 : {} = Struct {}; - let List.385 : [C {}, C {}] = TagId(0) List.386; - ret List.385; + let List.382 : {} = Struct {}; + let List.381 : [C {}, C {}] = TagId(0) List.382; + ret List.381; procedure List.6 (#Attr.2): - let List.392 : U64 = lowlevel ListLen #Attr.2; - ret List.392; + let List.388 : U64 = lowlevel ListLen #Attr.2; + ret List.388; procedure List.66 (#Attr.2, #Attr.3): - let List.391 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.391; + let List.386 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.386; procedure Num.22 (#Attr.2, #Attr.3): let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.257; -procedure Test.2 (Test.6): - let Test.18 : Str = "bar"; - ret Test.18; +procedure Test.2 (Test.5): + let Test.17 : Str = "bar"; + ret Test.17; procedure Test.0 (): let Test.1 : List {} = Array []; - joinpoint Test.16 Test.3: - let Test.14 : U64 = 0i64; - let Test.7 : [C {}, C {}] = CallByName List.2 Test.3 Test.14; + joinpoint Test.15 Test.3: + let Test.13 : U64 = 0i64; + let Test.6 : [C {}, C {}] = CallByName List.2 Test.3 Test.13; dec Test.3; - let Test.11 : U8 = 1i64; - let Test.12 : U8 = GetTagId Test.7; - let Test.13 : Int1 = lowlevel Eq Test.11 Test.12; - if Test.13 then - let Test.5 : {} = UnionAtIndex (Id 1) (Index 0) Test.7; - let Test.9 : Str = "foo"; - let Test.8 : Str = CallByName Test.2 Test.9; - dec Test.9; - ret Test.8; + let Test.10 : U8 = 1i64; + let Test.11 : U8 = GetTagId Test.6; + let Test.12 : Int1 = lowlevel Eq Test.10 Test.11; + if Test.12 then + let Test.4 : {} = UnionAtIndex (Id 1) (Index 0) Test.6; + let Test.8 : Str = "foo"; + let Test.7 : Str = CallByName Test.2 Test.8; + dec Test.8; + ret Test.7; else - let Test.10 : Str = "bad!"; - ret Test.10; + let Test.9 : Str = "bad!"; + ret Test.9; in - let Test.19 : Int1 = false; - if Test.19 then - jump Test.16 Test.1; + let Test.18 : Int1 = CallByName Bool.1; + if Test.18 then + jump Test.15 Test.1; else dec Test.1; - let Test.17 : {} = Struct {}; - let Test.15 : List {} = Array [Test.17]; - jump Test.16 Test.15; + let Test.16 : {} = Struct {}; + let Test.14 : List {} = Array [Test.16]; + jump Test.15 Test.14; diff --git a/crates/compiler/test_mono/generated/encode.txt b/crates/compiler/test_mono/generated/encode.txt index 03cb371d02..0d4eb1a362 100644 --- a/crates/compiler/test_mono/generated/encode.txt +++ b/crates/compiler/test_mono/generated/encode.txt @@ -1,16 +1,16 @@ procedure List.4 (List.101, List.102): - let List.387 : U64 = 1i64; - let List.386 : List U8 = CallByName List.70 List.101 List.387; - let List.385 : List U8 = CallByName List.71 List.386 List.102; - ret List.385; + let List.384 : U64 = 1i64; + let List.382 : List U8 = CallByName List.70 List.101 List.384; + let List.381 : List U8 = CallByName List.71 List.382 List.102; + ret List.381; procedure List.70 (#Attr.2, #Attr.3): - let List.389 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.389; + let List.385 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.385; procedure List.71 (#Attr.2, #Attr.3): - let List.388 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.388; + let List.383 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.383; procedure Test.23 (Test.24, Test.35, Test.22): let Test.37 : List U8 = CallByName List.4 Test.24 Test.22; diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index 2e9010b165..1ae82bd7c2 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -44,7 +44,7 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.103 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): @@ -52,11 +52,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.115; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.125 : List U8 = CallByName Json.103 Encode.94 Encode.96 Encode.102; + let Encode.125 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; ret Encode.125; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.128 : List U8 = CallByName Json.87 Encode.94 Encode.96 Encode.102; + let Encode.128 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; ret Encode.128; procedure Encode.25 (Encode.100, Encode.101): @@ -66,293 +66,293 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.318 : {} = Struct {}; - ret Json.318; + let Json.396 : {} = Struct {}; + ret Json.396; -procedure Json.103 (Json.104, Json.321, Json.102): - let Json.354 : I32 = 123i64; - let Json.353 : U8 = CallByName Num.123 Json.354; - let Json.106 : List U8 = CallByName List.4 Json.104 Json.353; - let Json.352 : U64 = CallByName List.6 Json.102; - let Json.329 : {List U8, U64} = Struct {Json.106, Json.352}; - let Json.330 : {} = Struct {}; - let Json.328 : {List U8, U64} = CallByName List.18 Json.102 Json.329 Json.330; - dec Json.102; - let Json.108 : List U8 = StructAtIndex 0 Json.328; - inc Json.108; - dec Json.328; - let Json.327 : I32 = 125i64; - let Json.326 : U8 = CallByName Num.123 Json.327; - let Json.325 : List U8 = CallByName List.4 Json.108 Json.326; - ret Json.325; +procedure Json.113 (Json.114, Json.399, Json.112): + let Json.432 : I32 = 123i64; + let Json.431 : U8 = CallByName Num.123 Json.432; + let Json.116 : List U8 = CallByName List.4 Json.114 Json.431; + let Json.430 : U64 = CallByName List.6 Json.112; + let Json.407 : {List U8, U64} = Struct {Json.116, Json.430}; + let Json.408 : {} = Struct {}; + let Json.406 : {List U8, U64} = CallByName List.18 Json.112 Json.407 Json.408; + dec Json.112; + let Json.118 : List U8 = StructAtIndex 0 Json.406; + inc Json.118; + dec Json.406; + let Json.405 : I32 = 125i64; + let Json.404 : U8 = CallByName Num.123 Json.405; + let Json.403 : List U8 = CallByName List.4 Json.118 Json.404; + ret Json.403; -procedure Json.103 (Json.104, Json.321, Json.102): - let Json.397 : I32 = 123i64; - let Json.396 : U8 = CallByName Num.123 Json.397; - let Json.106 : List U8 = CallByName List.4 Json.104 Json.396; - let Json.395 : U64 = CallByName List.6 Json.102; - let Json.372 : {List U8, U64} = Struct {Json.106, Json.395}; - let Json.373 : {} = Struct {}; - let Json.371 : {List U8, U64} = CallByName List.18 Json.102 Json.372 Json.373; - dec Json.102; - let Json.108 : List U8 = StructAtIndex 0 Json.371; - inc Json.108; - dec Json.371; - let Json.370 : I32 = 125i64; - let Json.369 : U8 = CallByName Num.123 Json.370; - let Json.368 : List U8 = CallByName List.4 Json.108 Json.369; - ret Json.368; +procedure Json.113 (Json.114, Json.399, Json.112): + let Json.472 : I32 = 123i64; + let Json.471 : U8 = CallByName Num.123 Json.472; + let Json.116 : List U8 = CallByName List.4 Json.114 Json.471; + let Json.470 : U64 = CallByName List.6 Json.112; + let Json.447 : {List U8, U64} = Struct {Json.116, Json.470}; + let Json.448 : {} = Struct {}; + let Json.446 : {List U8, U64} = CallByName List.18 Json.112 Json.447 Json.448; + dec Json.112; + let Json.118 : List U8 = StructAtIndex 0 Json.446; + inc Json.118; + dec Json.446; + let Json.445 : I32 = 125i64; + let Json.444 : U8 = CallByName Num.123 Json.445; + let Json.443 : List U8 = CallByName List.4 Json.118 Json.444; + ret Json.443; -procedure Json.105 (Json.323, Json.324): - let Json.111 : Str = StructAtIndex 0 Json.324; - inc Json.111; - let Json.112 : Str = StructAtIndex 1 Json.324; - inc Json.112; - dec Json.324; - let Json.109 : List U8 = StructAtIndex 0 Json.323; - inc Json.109; - let Json.110 : U64 = StructAtIndex 1 Json.323; - dec Json.323; - let Json.351 : I32 = 34i64; - let Json.350 : U8 = CallByName Num.123 Json.351; - let Json.348 : List U8 = CallByName List.4 Json.109 Json.350; - let Json.349 : List U8 = CallByName Str.12 Json.111; - let Json.345 : List U8 = CallByName List.8 Json.348 Json.349; - let Json.347 : I32 = 34i64; - let Json.346 : U8 = CallByName Num.123 Json.347; - let Json.342 : List U8 = CallByName List.4 Json.345 Json.346; - let Json.344 : I32 = 58i64; - let Json.343 : U8 = CallByName Num.123 Json.344; - let Json.340 : List U8 = CallByName List.4 Json.342 Json.343; - let Json.341 : {} = Struct {}; - let Json.113 : List U8 = CallByName Encode.23 Json.340 Json.112 Json.341; - joinpoint Json.335 Json.114: - let Json.333 : U64 = 1i64; - let Json.332 : U64 = CallByName Num.20 Json.110 Json.333; - let Json.331 : {List U8, U64} = Struct {Json.114, Json.332}; - ret Json.331; +procedure Json.115 (Json.401, Json.402): + let Json.121 : Str = StructAtIndex 0 Json.402; + inc Json.121; + let Json.122 : Str = StructAtIndex 1 Json.402; + inc Json.122; + dec Json.402; + let Json.119 : List U8 = StructAtIndex 0 Json.401; + inc Json.119; + let Json.120 : U64 = StructAtIndex 1 Json.401; + dec Json.401; + let Json.429 : I32 = 34i64; + let Json.428 : U8 = CallByName Num.123 Json.429; + let Json.426 : List U8 = CallByName List.4 Json.119 Json.428; + let Json.427 : List U8 = CallByName Str.12 Json.121; + let Json.423 : List U8 = CallByName List.8 Json.426 Json.427; + let Json.425 : I32 = 34i64; + let Json.424 : U8 = CallByName Num.123 Json.425; + let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; + let Json.422 : I32 = 58i64; + let Json.421 : U8 = CallByName Num.123 Json.422; + let Json.418 : List U8 = CallByName List.4 Json.420 Json.421; + let Json.419 : {} = Struct {}; + let Json.123 : List U8 = CallByName Encode.23 Json.418 Json.122 Json.419; + joinpoint Json.413 Json.124: + let Json.411 : U64 = 1i64; + let Json.410 : U64 = CallByName Num.20 Json.120 Json.411; + let Json.409 : {List U8, U64} = Struct {Json.124, Json.410}; + ret Json.409; in - let Json.339 : U64 = 1i64; - let Json.336 : Int1 = CallByName Num.24 Json.110 Json.339; - if Json.336 then - let Json.338 : I32 = 44i64; - let Json.337 : U8 = CallByName Num.123 Json.338; - let Json.334 : List U8 = CallByName List.4 Json.113 Json.337; - jump Json.335 Json.334; + let Json.417 : U64 = 1i64; + let Json.414 : Int1 = CallByName Num.24 Json.120 Json.417; + if Json.414 then + let Json.416 : I32 = 44i64; + let Json.415 : U8 = CallByName Num.123 Json.416; + let Json.412 : List U8 = CallByName List.4 Json.123 Json.415; + jump Json.413 Json.412; else - jump Json.335 Json.113; + jump Json.413 Json.123; -procedure Json.105 (Json.323, Json.324): - let Json.111 : Str = StructAtIndex 0 Json.324; - inc Json.111; - let Json.112 : Str = StructAtIndex 1 Json.324; - inc Json.112; - dec Json.324; - let Json.109 : List U8 = StructAtIndex 0 Json.323; - inc Json.109; - let Json.110 : U64 = StructAtIndex 1 Json.323; - dec Json.323; - let Json.394 : I32 = 34i64; - let Json.393 : U8 = CallByName Num.123 Json.394; - let Json.391 : List U8 = CallByName List.4 Json.109 Json.393; - let Json.392 : List U8 = CallByName Str.12 Json.111; - let Json.388 : List U8 = CallByName List.8 Json.391 Json.392; - let Json.390 : I32 = 34i64; - let Json.389 : U8 = CallByName Num.123 Json.390; - let Json.385 : List U8 = CallByName List.4 Json.388 Json.389; - let Json.387 : I32 = 58i64; - let Json.386 : U8 = CallByName Num.123 Json.387; - let Json.383 : List U8 = CallByName List.4 Json.385 Json.386; - let Json.384 : {} = Struct {}; - let Json.113 : List U8 = CallByName Encode.23 Json.383 Json.112 Json.384; - joinpoint Json.378 Json.114: - let Json.376 : U64 = 1i64; - let Json.375 : U64 = CallByName Num.20 Json.110 Json.376; - let Json.374 : {List U8, U64} = Struct {Json.114, Json.375}; - ret Json.374; +procedure Json.115 (Json.401, Json.402): + let Json.121 : Str = StructAtIndex 0 Json.402; + inc Json.121; + let Json.122 : Str = StructAtIndex 1 Json.402; + inc Json.122; + dec Json.402; + let Json.119 : List U8 = StructAtIndex 0 Json.401; + inc Json.119; + let Json.120 : U64 = StructAtIndex 1 Json.401; + dec Json.401; + let Json.469 : I32 = 34i64; + let Json.468 : U8 = CallByName Num.123 Json.469; + let Json.466 : List U8 = CallByName List.4 Json.119 Json.468; + let Json.467 : List U8 = CallByName Str.12 Json.121; + let Json.463 : List U8 = CallByName List.8 Json.466 Json.467; + let Json.465 : I32 = 34i64; + let Json.464 : U8 = CallByName Num.123 Json.465; + let Json.460 : List U8 = CallByName List.4 Json.463 Json.464; + let Json.462 : I32 = 58i64; + let Json.461 : U8 = CallByName Num.123 Json.462; + let Json.458 : List U8 = CallByName List.4 Json.460 Json.461; + let Json.459 : {} = Struct {}; + let Json.123 : List U8 = CallByName Encode.23 Json.458 Json.122 Json.459; + joinpoint Json.453 Json.124: + let Json.451 : U64 = 1i64; + let Json.450 : U64 = CallByName Num.20 Json.120 Json.451; + let Json.449 : {List U8, U64} = Struct {Json.124, Json.450}; + ret Json.449; in - let Json.382 : U64 = 1i64; - let Json.379 : Int1 = CallByName Num.24 Json.110 Json.382; - if Json.379 then - let Json.381 : I32 = 44i64; - let Json.380 : U8 = CallByName Num.123 Json.381; - let Json.377 : List U8 = CallByName List.4 Json.113 Json.380; - jump Json.378 Json.377; + let Json.457 : U64 = 1i64; + let Json.454 : Int1 = CallByName Num.24 Json.120 Json.457; + if Json.454 then + let Json.456 : I32 = 44i64; + let Json.455 : U8 = CallByName Num.123 Json.456; + let Json.452 : List U8 = CallByName List.4 Json.123 Json.455; + jump Json.453 Json.452; else - jump Json.378 Json.113; + jump Json.453 Json.123; -procedure Json.18 (Json.86): - let Json.364 : Str = CallByName Encode.22 Json.86; - ret Json.364; +procedure Json.18 (Json.96): + let Json.473 : Str = CallByName Encode.22 Json.96; + ret Json.473; -procedure Json.20 (Json.102): - let Json.319 : List {Str, Str} = CallByName Encode.22 Json.102; - ret Json.319; +procedure Json.20 (Json.112): + let Json.397 : List {Str, Str} = CallByName Encode.22 Json.112; + ret Json.397; -procedure Json.20 (Json.102): - let Json.361 : List {Str, Str} = CallByName Encode.22 Json.102; - ret Json.361; +procedure Json.20 (Json.112): + let Json.439 : List {Str, Str} = CallByName Encode.22 Json.112; + ret Json.439; -procedure Json.87 (Json.88, Json.366, Json.86): - let Json.406 : I32 = 34i64; - let Json.405 : U8 = CallByName Num.123 Json.406; - let Json.403 : List U8 = CallByName List.4 Json.88 Json.405; - let Json.404 : List U8 = CallByName Str.12 Json.86; - let Json.400 : List U8 = CallByName List.8 Json.403 Json.404; - let Json.402 : I32 = 34i64; - let Json.401 : U8 = CallByName Num.123 Json.402; - let Json.399 : List U8 = CallByName List.4 Json.400 Json.401; - ret Json.399; +procedure Json.97 (Json.98, Json.475, Json.96): + let Json.484 : I32 = 34i64; + let Json.483 : U8 = CallByName Num.123 Json.484; + let Json.481 : List U8 = CallByName List.4 Json.98 Json.483; + let Json.482 : List U8 = CallByName Str.12 Json.96; + let Json.478 : List U8 = CallByName List.8 Json.481 Json.482; + let Json.480 : I32 = 34i64; + let Json.479 : U8 = CallByName Num.123 Json.480; + let Json.477 : List U8 = CallByName List.4 Json.478 Json.479; + ret Json.477; procedure List.133 (List.134, List.135, List.132): - let List.434 : {List U8, U64} = CallByName Json.105 List.134 List.135; - let List.433 : [C [], C {List U8, U64}] = TagId(1) List.434; - ret List.433; + let List.429 : {List U8, U64} = CallByName Json.115 List.134 List.135; + let List.428 : [C [], C {List U8, U64}] = TagId(1) List.429; + ret List.428; procedure List.133 (List.134, List.135, List.132): - let List.515 : {List U8, U64} = CallByName Json.105 List.134 List.135; - let List.514 : [C [], C {List U8, U64}] = TagId(1) List.515; - ret List.514; + let List.510 : {List U8, U64} = CallByName Json.115 List.134 List.135; + let List.509 : [C [], C {List U8, U64}] = TagId(1) List.510; + ret List.509; procedure List.18 (List.130, List.131, List.132): - let List.405 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; - let List.408 : U8 = 1i64; - let List.409 : U8 = GetTagId List.405; - let List.410 : Int1 = lowlevel Eq List.408 List.409; - if List.410 then - let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.405; + let List.403 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; + let List.407 : U8 = 1i64; + let List.408 : U8 = GetTagId List.403; + let List.409 : Int1 = lowlevel Eq List.407 List.408; + if List.409 then + let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.403; inc List.137; - dec List.405; + dec List.403; ret List.137; else - let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.405; - dec List.405; - let List.407 : {List U8, U64} = CallByName List.69 List.138; - ret List.407; + let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.403; + dec List.403; + let List.405 : {List U8, U64} = CallByName List.69 List.138; + ret List.405; procedure List.18 (List.130, List.131, List.132): - let List.485 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; + let List.484 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; let List.488 : U8 = 1i64; - let List.489 : U8 = GetTagId List.485; + let List.489 : U8 = GetTagId List.484; let List.490 : Int1 = lowlevel Eq List.488 List.489; if List.490 then - let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.485; + let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.484; inc List.137; - dec List.485; + dec List.484; ret List.137; else - let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.485; - dec List.485; - let List.487 : {List U8, U64} = CallByName List.69 List.138; - ret List.487; + let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.484; + dec List.484; + let List.486 : {List U8, U64} = CallByName List.69 List.138; + ret List.486; procedure List.4 (List.101, List.102): - let List.484 : U64 = 1i64; - let List.483 : List U8 = CallByName List.70 List.101 List.484; - let List.482 : List U8 = CallByName List.71 List.483 List.102; - ret List.482; + let List.483 : U64 = 1i64; + let List.482 : List U8 = CallByName List.70 List.101 List.483; + let List.481 : List U8 = CallByName List.71 List.482 List.102; + ret List.481; procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure List.6 (#Attr.2): - let List.413 : U64 = lowlevel ListLen #Attr.2; - ret List.413; + let List.431 : U64 = lowlevel ListLen #Attr.2; + ret List.431; procedure List.6 (#Attr.2): - let List.494 : U64 = lowlevel ListLen #Attr.2; - ret List.494; - -procedure List.66 (#Attr.2, #Attr.3): - let List.432 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.432; - -procedure List.66 (#Attr.2, #Attr.3): - let List.513 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + let List.513 : U64 = lowlevel ListLen #Attr.2; ret List.513; +procedure List.66 (#Attr.2, #Attr.3): + let List.426 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.426; + +procedure List.66 (#Attr.2, #Attr.3): + let List.507 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.507; + procedure List.69 (#Attr.2): - let List.497 : {List U8, U64} = lowlevel Unreachable #Attr.2; - ret List.497; + let List.487 : {List U8, U64} = lowlevel Unreachable #Attr.2; + ret List.487; procedure List.70 (#Attr.2, #Attr.3): - let List.496 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.496; + let List.462 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.462; procedure List.71 (#Attr.2, #Attr.3): - let List.495 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.495; + let List.460 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.460; -procedure List.75 (List.361, List.362, List.363): - let List.418 : U64 = 0i64; - let List.419 : U64 = CallByName List.6 List.361; - let List.417 : [C [], C {List U8, U64}] = CallByName List.86 List.361 List.362 List.363 List.418 List.419; - ret List.417; +procedure List.75 (List.357, List.358, List.359): + let List.412 : U64 = 0i64; + let List.413 : U64 = CallByName List.6 List.357; + let List.411 : [C [], C {List U8, U64}] = CallByName List.86 List.357 List.358 List.359 List.412 List.413; + ret List.411; -procedure List.75 (List.361, List.362, List.363): - let List.499 : U64 = 0i64; - let List.500 : U64 = CallByName List.6 List.361; - let List.498 : [C [], C {List U8, U64}] = CallByName List.86 List.361 List.362 List.363 List.499 List.500; - ret List.498; +procedure List.75 (List.357, List.358, List.359): + let List.493 : U64 = 0i64; + let List.494 : U64 = CallByName List.6 List.357; + let List.492 : [C [], C {List U8, U64}] = CallByName List.86 List.357 List.358 List.359 List.493 List.494; + ret List.492; procedure List.8 (#Attr.2, #Attr.3): - let List.493 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.493; + let List.512 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.512; -procedure List.86 (List.448, List.449, List.450, List.451, List.452): - joinpoint List.420 List.364 List.365 List.366 List.367 List.368: - let List.422 : Int1 = CallByName Num.22 List.367 List.368; - if List.422 then - let List.431 : {Str, Str} = CallByName List.66 List.364 List.367; - let List.423 : [C [], C {List U8, U64}] = CallByName List.133 List.365 List.431 List.366; - let List.428 : U8 = 1i64; - let List.429 : U8 = GetTagId List.423; - let List.430 : Int1 = lowlevel Eq List.428 List.429; - if List.430 then - let List.369 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.423; - inc List.369; - dec List.423; - let List.426 : U64 = 1i64; - let List.425 : U64 = CallByName Num.19 List.367 List.426; - jump List.420 List.364 List.369 List.366 List.425 List.368; +procedure List.86 (List.442, List.443, List.444, List.445, List.446): + joinpoint List.414 List.360 List.361 List.362 List.363 List.364: + let List.416 : Int1 = CallByName Num.22 List.363 List.364; + if List.416 then + let List.425 : {Str, Str} = CallByName List.66 List.360 List.363; + let List.417 : [C [], C {List U8, U64}] = CallByName List.133 List.361 List.425 List.362; + let List.422 : U8 = 1i64; + let List.423 : U8 = GetTagId List.417; + let List.424 : Int1 = lowlevel Eq List.422 List.423; + if List.424 then + let List.365 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.417; + inc List.365; + dec List.417; + let List.420 : U64 = 1i64; + let List.419 : U64 = CallByName Num.19 List.363 List.420; + jump List.414 List.360 List.365 List.362 List.419 List.364; else - let List.370 : [] = UnionAtIndex (Id 0) (Index 0) List.423; - dec List.423; - let List.427 : [C [], C {List U8, U64}] = TagId(0) List.370; - ret List.427; + let List.366 : [] = UnionAtIndex (Id 0) (Index 0) List.417; + dec List.417; + let List.421 : [C [], C {List U8, U64}] = TagId(0) List.366; + ret List.421; else - let List.421 : [C [], C {List U8, U64}] = TagId(1) List.365; - ret List.421; + let List.415 : [C [], C {List U8, U64}] = TagId(1) List.361; + ret List.415; in - jump List.420 List.448 List.449 List.450 List.451 List.452; + jump List.414 List.442 List.443 List.444 List.445 List.446; -procedure List.86 (List.529, List.530, List.531, List.532, List.533): - joinpoint List.501 List.364 List.365 List.366 List.367 List.368: - let List.503 : Int1 = CallByName Num.22 List.367 List.368; - if List.503 then - let List.512 : {Str, Str} = CallByName List.66 List.364 List.367; - let List.504 : [C [], C {List U8, U64}] = CallByName List.133 List.365 List.512 List.366; - let List.509 : U8 = 1i64; - let List.510 : U8 = GetTagId List.504; - let List.511 : Int1 = lowlevel Eq List.509 List.510; - if List.511 then - let List.369 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.504; - inc List.369; - dec List.504; - let List.507 : U64 = 1i64; - let List.506 : U64 = CallByName Num.19 List.367 List.507; - jump List.501 List.364 List.369 List.366 List.506 List.368; +procedure List.86 (List.524, List.525, List.526, List.527, List.528): + joinpoint List.495 List.360 List.361 List.362 List.363 List.364: + let List.497 : Int1 = CallByName Num.22 List.363 List.364; + if List.497 then + let List.506 : {Str, Str} = CallByName List.66 List.360 List.363; + let List.498 : [C [], C {List U8, U64}] = CallByName List.133 List.361 List.506 List.362; + let List.503 : U8 = 1i64; + let List.504 : U8 = GetTagId List.498; + let List.505 : Int1 = lowlevel Eq List.503 List.504; + if List.505 then + let List.365 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.498; + inc List.365; + dec List.498; + let List.501 : U64 = 1i64; + let List.500 : U64 = CallByName Num.19 List.363 List.501; + jump List.495 List.360 List.365 List.362 List.500 List.364; else - let List.370 : [] = UnionAtIndex (Id 0) (Index 0) List.504; - dec List.504; - let List.508 : [C [], C {List U8, U64}] = TagId(0) List.370; - ret List.508; + let List.366 : [] = UnionAtIndex (Id 0) (Index 0) List.498; + dec List.498; + let List.502 : [C [], C {List U8, U64}] = TagId(0) List.366; + ret List.502; else - let List.502 : [C [], C {List U8, U64}] = TagId(1) List.365; - ret List.502; + let List.496 : [C [], C {List U8, U64}] = TagId(1) List.361; + ret List.496; in - jump List.501 List.529 List.530 List.531 List.532 List.533; + jump List.495 List.524 List.525 List.526 List.527 List.528; procedure Num.123 (#Attr.2): let Num.283 : U8 = lowlevel NumIntCast #Attr.2; @@ -375,31 +375,31 @@ procedure Num.24 (#Attr.2, #Attr.3): ret Num.285; procedure Str.12 (#Attr.2): - let Str.219 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.219; + let Str.268 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.268; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.211 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.211; + let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.260; -procedure Str.9 (Str.69): - let Str.209 : U64 = 0i64; - let Str.210 : U64 = CallByName List.6 Str.69; - let Str.70 : {U64, Str, Int1, U8} = CallByName Str.48 Str.69 Str.209 Str.210; - let Str.206 : Int1 = StructAtIndex 2 Str.70; - if Str.206 then - let Str.208 : Str = StructAtIndex 1 Str.70; - inc Str.208; - dec Str.70; - let Str.207 : [C {U64, U8}, C Str] = TagId(1) Str.208; - ret Str.207; +procedure Str.9 (Str.73): + let Str.258 : U64 = 0i64; + let Str.259 : U64 = CallByName List.6 Str.73; + let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; + let Str.255 : Int1 = StructAtIndex 2 Str.74; + if Str.255 then + let Str.257 : Str = StructAtIndex 1 Str.74; + inc Str.257; + dec Str.74; + let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; + ret Str.256; else - let Str.204 : U8 = StructAtIndex 3 Str.70; - let Str.205 : U64 = StructAtIndex 0 Str.70; - dec Str.70; - let Str.203 : {U64, U8} = Struct {Str.205, Str.204}; - let Str.202 : [C {U64, U8}, C Str] = TagId(0) Str.203; - ret Str.202; + let Str.253 : U8 = StructAtIndex 3 Str.74; + let Str.254 : U64 = StructAtIndex 0 Str.74; + dec Str.74; + let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; + let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; + ret Str.251; procedure Test.0 (): let Test.12 : Str = "bar"; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt index 3398a4c5e9..48849a17f2 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -25,11 +25,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.103 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.116 : List U8 = CallByName Json.87 Encode.94 Encode.96 Encode.102; + let Encode.116 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; ret Encode.116; procedure Encode.25 (Encode.100, Encode.101): @@ -39,171 +39,171 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.318 : {} = Struct {}; - ret Json.318; + let Json.396 : {} = Struct {}; + ret Json.396; -procedure Json.103 (Json.104, Json.321, Json.102): - let Json.357 : I32 = 123i64; - let Json.356 : U8 = CallByName Num.123 Json.357; - let Json.106 : List U8 = CallByName List.4 Json.104 Json.356; - let Json.355 : U64 = CallByName List.6 Json.102; - let Json.332 : {List U8, U64} = Struct {Json.106, Json.355}; - let Json.333 : {} = Struct {}; - let Json.331 : {List U8, U64} = CallByName List.18 Json.102 Json.332 Json.333; - dec Json.102; - let Json.108 : List U8 = StructAtIndex 0 Json.331; - inc Json.108; - dec Json.331; - let Json.330 : I32 = 125i64; - let Json.329 : U8 = CallByName Num.123 Json.330; - let Json.328 : List U8 = CallByName List.4 Json.108 Json.329; - ret Json.328; +procedure Json.113 (Json.114, Json.399, Json.112): + let Json.432 : I32 = 123i64; + let Json.431 : U8 = CallByName Num.123 Json.432; + let Json.116 : List U8 = CallByName List.4 Json.114 Json.431; + let Json.430 : U64 = CallByName List.6 Json.112; + let Json.407 : {List U8, U64} = Struct {Json.116, Json.430}; + let Json.408 : {} = Struct {}; + let Json.406 : {List U8, U64} = CallByName List.18 Json.112 Json.407 Json.408; + dec Json.112; + let Json.118 : List U8 = StructAtIndex 0 Json.406; + inc Json.118; + dec Json.406; + let Json.405 : I32 = 125i64; + let Json.404 : U8 = CallByName Num.123 Json.405; + let Json.403 : List U8 = CallByName List.4 Json.118 Json.404; + ret Json.403; -procedure Json.105 (Json.326, Json.327): - let Json.111 : Str = StructAtIndex 0 Json.327; - inc Json.111; - let Json.112 : Str = StructAtIndex 1 Json.327; - inc Json.112; - dec Json.327; - let Json.109 : List U8 = StructAtIndex 0 Json.326; - inc Json.109; - let Json.110 : U64 = StructAtIndex 1 Json.326; - dec Json.326; - let Json.354 : I32 = 34i64; - let Json.353 : U8 = CallByName Num.123 Json.354; - let Json.351 : List U8 = CallByName List.4 Json.109 Json.353; - let Json.352 : List U8 = CallByName Str.12 Json.111; - let Json.348 : List U8 = CallByName List.8 Json.351 Json.352; - let Json.350 : I32 = 34i64; - let Json.349 : U8 = CallByName Num.123 Json.350; - let Json.345 : List U8 = CallByName List.4 Json.348 Json.349; - let Json.347 : I32 = 58i64; - let Json.346 : U8 = CallByName Num.123 Json.347; - let Json.343 : List U8 = CallByName List.4 Json.345 Json.346; - let Json.344 : {} = Struct {}; - let Json.113 : List U8 = CallByName Encode.23 Json.343 Json.112 Json.344; - joinpoint Json.338 Json.114: - let Json.336 : U64 = 1i64; - let Json.335 : U64 = CallByName Num.20 Json.110 Json.336; - let Json.334 : {List U8, U64} = Struct {Json.114, Json.335}; - ret Json.334; +procedure Json.115 (Json.401, Json.402): + let Json.121 : Str = StructAtIndex 0 Json.402; + inc Json.121; + let Json.122 : Str = StructAtIndex 1 Json.402; + inc Json.122; + dec Json.402; + let Json.119 : List U8 = StructAtIndex 0 Json.401; + inc Json.119; + let Json.120 : U64 = StructAtIndex 1 Json.401; + dec Json.401; + let Json.429 : I32 = 34i64; + let Json.428 : U8 = CallByName Num.123 Json.429; + let Json.426 : List U8 = CallByName List.4 Json.119 Json.428; + let Json.427 : List U8 = CallByName Str.12 Json.121; + let Json.423 : List U8 = CallByName List.8 Json.426 Json.427; + let Json.425 : I32 = 34i64; + let Json.424 : U8 = CallByName Num.123 Json.425; + let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; + let Json.422 : I32 = 58i64; + let Json.421 : U8 = CallByName Num.123 Json.422; + let Json.418 : List U8 = CallByName List.4 Json.420 Json.421; + let Json.419 : {} = Struct {}; + let Json.123 : List U8 = CallByName Encode.23 Json.418 Json.122 Json.419; + joinpoint Json.413 Json.124: + let Json.411 : U64 = 1i64; + let Json.410 : U64 = CallByName Num.20 Json.120 Json.411; + let Json.409 : {List U8, U64} = Struct {Json.124, Json.410}; + ret Json.409; in - let Json.342 : U64 = 1i64; - let Json.339 : Int1 = CallByName Num.24 Json.110 Json.342; - if Json.339 then - let Json.341 : I32 = 44i64; - let Json.340 : U8 = CallByName Num.123 Json.341; - let Json.337 : List U8 = CallByName List.4 Json.113 Json.340; - jump Json.338 Json.337; + let Json.417 : U64 = 1i64; + let Json.414 : Int1 = CallByName Num.24 Json.120 Json.417; + if Json.414 then + let Json.416 : I32 = 44i64; + let Json.415 : U8 = CallByName Num.123 Json.416; + let Json.412 : List U8 = CallByName List.4 Json.123 Json.415; + jump Json.413 Json.412; else - jump Json.338 Json.113; + jump Json.413 Json.123; -procedure Json.18 (Json.86): - let Json.322 : Str = CallByName Encode.22 Json.86; - ret Json.322; +procedure Json.18 (Json.96): + let Json.433 : Str = CallByName Encode.22 Json.96; + ret Json.433; -procedure Json.20 (Json.102): - let Json.319 : List {Str, Str} = CallByName Encode.22 Json.102; - ret Json.319; +procedure Json.20 (Json.112): + let Json.397 : List {Str, Str} = CallByName Encode.22 Json.112; + ret Json.397; -procedure Json.87 (Json.88, Json.324, Json.86): - let Json.366 : I32 = 34i64; - let Json.365 : U8 = CallByName Num.123 Json.366; - let Json.363 : List U8 = CallByName List.4 Json.88 Json.365; - let Json.364 : List U8 = CallByName Str.12 Json.86; - let Json.360 : List U8 = CallByName List.8 Json.363 Json.364; - let Json.362 : I32 = 34i64; - let Json.361 : U8 = CallByName Num.123 Json.362; - let Json.359 : List U8 = CallByName List.4 Json.360 Json.361; - ret Json.359; +procedure Json.97 (Json.98, Json.435, Json.96): + let Json.444 : I32 = 34i64; + let Json.443 : U8 = CallByName Num.123 Json.444; + let Json.441 : List U8 = CallByName List.4 Json.98 Json.443; + let Json.442 : List U8 = CallByName Str.12 Json.96; + let Json.438 : List U8 = CallByName List.8 Json.441 Json.442; + let Json.440 : I32 = 34i64; + let Json.439 : U8 = CallByName Num.123 Json.440; + let Json.437 : List U8 = CallByName List.4 Json.438 Json.439; + ret Json.437; procedure List.133 (List.134, List.135, List.132): - let List.441 : {List U8, U64} = CallByName Json.105 List.134 List.135; - let List.440 : [C [], C {List U8, U64}] = TagId(1) List.441; - ret List.440; + let List.435 : {List U8, U64} = CallByName Json.115 List.134 List.135; + let List.434 : [C [], C {List U8, U64}] = TagId(1) List.435; + ret List.434; procedure List.18 (List.130, List.131, List.132): - let List.411 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; - let List.414 : U8 = 1i64; - let List.415 : U8 = GetTagId List.411; - let List.416 : Int1 = lowlevel Eq List.414 List.415; - if List.416 then - let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.411; + let List.409 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; + let List.413 : U8 = 1i64; + let List.414 : U8 = GetTagId List.409; + let List.415 : Int1 = lowlevel Eq List.413 List.414; + if List.415 then + let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.409; inc List.137; - dec List.411; + dec List.409; ret List.137; else - let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.411; - dec List.411; - let List.413 : {List U8, U64} = CallByName List.69 List.138; - ret List.413; + let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.409; + dec List.409; + let List.411 : {List U8, U64} = CallByName List.69 List.138; + ret List.411; procedure List.4 (List.101, List.102): - let List.410 : U64 = 1i64; - let List.409 : List U8 = CallByName List.70 List.101 List.410; - let List.408 : List U8 = CallByName List.71 List.409 List.102; - ret List.408; + let List.408 : U64 = 1i64; + let List.407 : List U8 = CallByName List.70 List.101 List.408; + let List.406 : List U8 = CallByName List.71 List.407 List.102; + ret List.406; procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure List.6 (#Attr.2): - let List.420 : U64 = lowlevel ListLen #Attr.2; - ret List.420; + let List.438 : U64 = lowlevel ListLen #Attr.2; + ret List.438; procedure List.66 (#Attr.2, #Attr.3): - let List.439 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.439; + let List.432 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.432; procedure List.69 (#Attr.2): - let List.423 : {List U8, U64} = lowlevel Unreachable #Attr.2; - ret List.423; + let List.412 : {List U8, U64} = lowlevel Unreachable #Attr.2; + ret List.412; procedure List.70 (#Attr.2, #Attr.3): - let List.422 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.422; + let List.387 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.387; procedure List.71 (#Attr.2, #Attr.3): - let List.421 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.421; + let List.385 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.385; -procedure List.75 (List.361, List.362, List.363): - let List.425 : U64 = 0i64; - let List.426 : U64 = CallByName List.6 List.361; - let List.424 : [C [], C {List U8, U64}] = CallByName List.86 List.361 List.362 List.363 List.425 List.426; - ret List.424; +procedure List.75 (List.357, List.358, List.359): + let List.418 : U64 = 0i64; + let List.419 : U64 = CallByName List.6 List.357; + let List.417 : [C [], C {List U8, U64}] = CallByName List.86 List.357 List.358 List.359 List.418 List.419; + ret List.417; procedure List.8 (#Attr.2, #Attr.3): - let List.419 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.419; + let List.437 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.437; -procedure List.86 (List.455, List.456, List.457, List.458, List.459): - joinpoint List.427 List.364 List.365 List.366 List.367 List.368: - let List.429 : Int1 = CallByName Num.22 List.367 List.368; - if List.429 then - let List.438 : {Str, Str} = CallByName List.66 List.364 List.367; - let List.430 : [C [], C {List U8, U64}] = CallByName List.133 List.365 List.438 List.366; - let List.435 : U8 = 1i64; - let List.436 : U8 = GetTagId List.430; - let List.437 : Int1 = lowlevel Eq List.435 List.436; - if List.437 then - let List.369 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.430; - inc List.369; - dec List.430; - let List.433 : U64 = 1i64; - let List.432 : U64 = CallByName Num.19 List.367 List.433; - jump List.427 List.364 List.369 List.366 List.432 List.368; +procedure List.86 (List.449, List.450, List.451, List.452, List.453): + joinpoint List.420 List.360 List.361 List.362 List.363 List.364: + let List.422 : Int1 = CallByName Num.22 List.363 List.364; + if List.422 then + let List.431 : {Str, Str} = CallByName List.66 List.360 List.363; + let List.423 : [C [], C {List U8, U64}] = CallByName List.133 List.361 List.431 List.362; + let List.428 : U8 = 1i64; + let List.429 : U8 = GetTagId List.423; + let List.430 : Int1 = lowlevel Eq List.428 List.429; + if List.430 then + let List.365 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.423; + inc List.365; + dec List.423; + let List.426 : U64 = 1i64; + let List.425 : U64 = CallByName Num.19 List.363 List.426; + jump List.420 List.360 List.365 List.362 List.425 List.364; else - let List.370 : [] = UnionAtIndex (Id 0) (Index 0) List.430; - dec List.430; - let List.434 : [C [], C {List U8, U64}] = TagId(0) List.370; - ret List.434; + let List.366 : [] = UnionAtIndex (Id 0) (Index 0) List.423; + dec List.423; + let List.427 : [C [], C {List U8, U64}] = TagId(0) List.366; + ret List.427; else - let List.428 : [C [], C {List U8, U64}] = TagId(1) List.365; - ret List.428; + let List.421 : [C [], C {List U8, U64}] = TagId(1) List.361; + ret List.421; in - jump List.427 List.455 List.456 List.457 List.458 List.459; + jump List.420 List.449 List.450 List.451 List.452 List.453; procedure Num.123 (#Attr.2): let Num.264 : U8 = lowlevel NumIntCast #Attr.2; @@ -226,31 +226,31 @@ procedure Num.24 (#Attr.2, #Attr.3): ret Num.266; procedure Str.12 (#Attr.2): - let Str.217 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.217; + let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.266; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.211 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.211; + let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.260; -procedure Str.9 (Str.69): - let Str.209 : U64 = 0i64; - let Str.210 : U64 = CallByName List.6 Str.69; - let Str.70 : {U64, Str, Int1, U8} = CallByName Str.48 Str.69 Str.209 Str.210; - let Str.206 : Int1 = StructAtIndex 2 Str.70; - if Str.206 then - let Str.208 : Str = StructAtIndex 1 Str.70; - inc Str.208; - dec Str.70; - let Str.207 : [C {U64, U8}, C Str] = TagId(1) Str.208; - ret Str.207; +procedure Str.9 (Str.73): + let Str.258 : U64 = 0i64; + let Str.259 : U64 = CallByName List.6 Str.73; + let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; + let Str.255 : Int1 = StructAtIndex 2 Str.74; + if Str.255 then + let Str.257 : Str = StructAtIndex 1 Str.74; + inc Str.257; + dec Str.74; + let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; + ret Str.256; else - let Str.204 : U8 = StructAtIndex 3 Str.70; - let Str.205 : U64 = StructAtIndex 0 Str.70; - dec Str.70; - let Str.203 : {U64, U8} = Struct {Str.205, Str.204}; - let Str.202 : [C {U64, U8}, C Str] = TagId(0) Str.203; - ret Str.202; + let Str.253 : U8 = StructAtIndex 3 Str.74; + let Str.254 : U64 = StructAtIndex 0 Str.74; + dec Str.74; + let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; + let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; + ret Str.251; procedure Test.0 (): let Test.11 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt index 0aff7f2c04..a4715fb73c 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -33,11 +33,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.103 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.117 : List U8 = CallByName Json.87 Encode.94 Encode.96 Encode.102; + let Encode.117 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; ret Encode.117; procedure Encode.25 (Encode.100, Encode.101): @@ -47,171 +47,171 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.318 : {} = Struct {}; - ret Json.318; + let Json.396 : {} = Struct {}; + ret Json.396; -procedure Json.103 (Json.104, Json.321, Json.102): - let Json.360 : I32 = 123i64; - let Json.359 : U8 = CallByName Num.123 Json.360; - let Json.106 : List U8 = CallByName List.4 Json.104 Json.359; - let Json.358 : U64 = CallByName List.6 Json.102; - let Json.335 : {List U8, U64} = Struct {Json.106, Json.358}; - let Json.336 : {} = Struct {}; - let Json.334 : {List U8, U64} = CallByName List.18 Json.102 Json.335 Json.336; - dec Json.102; - let Json.108 : List U8 = StructAtIndex 0 Json.334; - inc Json.108; - dec Json.334; - let Json.333 : I32 = 125i64; - let Json.332 : U8 = CallByName Num.123 Json.333; - let Json.331 : List U8 = CallByName List.4 Json.108 Json.332; - ret Json.331; +procedure Json.113 (Json.114, Json.399, Json.112): + let Json.432 : I32 = 123i64; + let Json.431 : U8 = CallByName Num.123 Json.432; + let Json.116 : List U8 = CallByName List.4 Json.114 Json.431; + let Json.430 : U64 = CallByName List.6 Json.112; + let Json.407 : {List U8, U64} = Struct {Json.116, Json.430}; + let Json.408 : {} = Struct {}; + let Json.406 : {List U8, U64} = CallByName List.18 Json.112 Json.407 Json.408; + dec Json.112; + let Json.118 : List U8 = StructAtIndex 0 Json.406; + inc Json.118; + dec Json.406; + let Json.405 : I32 = 125i64; + let Json.404 : U8 = CallByName Num.123 Json.405; + let Json.403 : List U8 = CallByName List.4 Json.118 Json.404; + ret Json.403; -procedure Json.105 (Json.329, Json.330): - let Json.111 : Str = StructAtIndex 0 Json.330; - inc Json.111; - let Json.112 : Str = StructAtIndex 1 Json.330; - inc Json.112; - dec Json.330; - let Json.109 : List U8 = StructAtIndex 0 Json.329; - inc Json.109; - let Json.110 : U64 = StructAtIndex 1 Json.329; - dec Json.329; - let Json.357 : I32 = 34i64; - let Json.356 : U8 = CallByName Num.123 Json.357; - let Json.354 : List U8 = CallByName List.4 Json.109 Json.356; - let Json.355 : List U8 = CallByName Str.12 Json.111; - let Json.351 : List U8 = CallByName List.8 Json.354 Json.355; - let Json.353 : I32 = 34i64; - let Json.352 : U8 = CallByName Num.123 Json.353; - let Json.348 : List U8 = CallByName List.4 Json.351 Json.352; - let Json.350 : I32 = 58i64; - let Json.349 : U8 = CallByName Num.123 Json.350; - let Json.346 : List U8 = CallByName List.4 Json.348 Json.349; - let Json.347 : {} = Struct {}; - let Json.113 : List U8 = CallByName Encode.23 Json.346 Json.112 Json.347; - joinpoint Json.341 Json.114: - let Json.339 : U64 = 1i64; - let Json.338 : U64 = CallByName Num.20 Json.110 Json.339; - let Json.337 : {List U8, U64} = Struct {Json.114, Json.338}; - ret Json.337; +procedure Json.115 (Json.401, Json.402): + let Json.121 : Str = StructAtIndex 0 Json.402; + inc Json.121; + let Json.122 : Str = StructAtIndex 1 Json.402; + inc Json.122; + dec Json.402; + let Json.119 : List U8 = StructAtIndex 0 Json.401; + inc Json.119; + let Json.120 : U64 = StructAtIndex 1 Json.401; + dec Json.401; + let Json.429 : I32 = 34i64; + let Json.428 : U8 = CallByName Num.123 Json.429; + let Json.426 : List U8 = CallByName List.4 Json.119 Json.428; + let Json.427 : List U8 = CallByName Str.12 Json.121; + let Json.423 : List U8 = CallByName List.8 Json.426 Json.427; + let Json.425 : I32 = 34i64; + let Json.424 : U8 = CallByName Num.123 Json.425; + let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; + let Json.422 : I32 = 58i64; + let Json.421 : U8 = CallByName Num.123 Json.422; + let Json.418 : List U8 = CallByName List.4 Json.420 Json.421; + let Json.419 : {} = Struct {}; + let Json.123 : List U8 = CallByName Encode.23 Json.418 Json.122 Json.419; + joinpoint Json.413 Json.124: + let Json.411 : U64 = 1i64; + let Json.410 : U64 = CallByName Num.20 Json.120 Json.411; + let Json.409 : {List U8, U64} = Struct {Json.124, Json.410}; + ret Json.409; in - let Json.345 : U64 = 1i64; - let Json.342 : Int1 = CallByName Num.24 Json.110 Json.345; - if Json.342 then - let Json.344 : I32 = 44i64; - let Json.343 : U8 = CallByName Num.123 Json.344; - let Json.340 : List U8 = CallByName List.4 Json.113 Json.343; - jump Json.341 Json.340; + let Json.417 : U64 = 1i64; + let Json.414 : Int1 = CallByName Num.24 Json.120 Json.417; + if Json.414 then + let Json.416 : I32 = 44i64; + let Json.415 : U8 = CallByName Num.123 Json.416; + let Json.412 : List U8 = CallByName List.4 Json.123 Json.415; + jump Json.413 Json.412; else - jump Json.341 Json.113; + jump Json.413 Json.123; -procedure Json.18 (Json.86): - let Json.325 : Str = CallByName Encode.22 Json.86; - ret Json.325; +procedure Json.18 (Json.96): + let Json.445 : Str = CallByName Encode.22 Json.96; + ret Json.445; -procedure Json.20 (Json.102): - let Json.319 : List {Str, Str} = CallByName Encode.22 Json.102; - ret Json.319; +procedure Json.20 (Json.112): + let Json.397 : List {Str, Str} = CallByName Encode.22 Json.112; + ret Json.397; -procedure Json.87 (Json.88, Json.324, Json.86): - let Json.369 : I32 = 34i64; - let Json.368 : U8 = CallByName Num.123 Json.369; - let Json.366 : List U8 = CallByName List.4 Json.88 Json.368; - let Json.367 : List U8 = CallByName Str.12 Json.86; - let Json.363 : List U8 = CallByName List.8 Json.366 Json.367; - let Json.365 : I32 = 34i64; - let Json.364 : U8 = CallByName Num.123 Json.365; - let Json.362 : List U8 = CallByName List.4 Json.363 Json.364; - ret Json.362; +procedure Json.97 (Json.98, Json.435, Json.96): + let Json.444 : I32 = 34i64; + let Json.443 : U8 = CallByName Num.123 Json.444; + let Json.441 : List U8 = CallByName List.4 Json.98 Json.443; + let Json.442 : List U8 = CallByName Str.12 Json.96; + let Json.438 : List U8 = CallByName List.8 Json.441 Json.442; + let Json.440 : I32 = 34i64; + let Json.439 : U8 = CallByName Num.123 Json.440; + let Json.437 : List U8 = CallByName List.4 Json.438 Json.439; + ret Json.437; procedure List.133 (List.134, List.135, List.132): - let List.441 : {List U8, U64} = CallByName Json.105 List.134 List.135; - let List.440 : [C [], C {List U8, U64}] = TagId(1) List.441; - ret List.440; + let List.435 : {List U8, U64} = CallByName Json.115 List.134 List.135; + let List.434 : [C [], C {List U8, U64}] = TagId(1) List.435; + ret List.434; procedure List.18 (List.130, List.131, List.132): - let List.411 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; - let List.414 : U8 = 1i64; - let List.415 : U8 = GetTagId List.411; - let List.416 : Int1 = lowlevel Eq List.414 List.415; - if List.416 then - let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.411; + let List.409 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; + let List.413 : U8 = 1i64; + let List.414 : U8 = GetTagId List.409; + let List.415 : Int1 = lowlevel Eq List.413 List.414; + if List.415 then + let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.409; inc List.137; - dec List.411; + dec List.409; ret List.137; else - let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.411; - dec List.411; - let List.413 : {List U8, U64} = CallByName List.69 List.138; - ret List.413; + let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.409; + dec List.409; + let List.411 : {List U8, U64} = CallByName List.69 List.138; + ret List.411; procedure List.4 (List.101, List.102): - let List.410 : U64 = 1i64; - let List.409 : List U8 = CallByName List.70 List.101 List.410; - let List.408 : List U8 = CallByName List.71 List.409 List.102; - ret List.408; + let List.408 : U64 = 1i64; + let List.407 : List U8 = CallByName List.70 List.101 List.408; + let List.406 : List U8 = CallByName List.71 List.407 List.102; + ret List.406; procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure List.6 (#Attr.2): - let List.420 : U64 = lowlevel ListLen #Attr.2; - ret List.420; + let List.438 : U64 = lowlevel ListLen #Attr.2; + ret List.438; procedure List.66 (#Attr.2, #Attr.3): - let List.439 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.439; + let List.432 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.432; procedure List.69 (#Attr.2): - let List.423 : {List U8, U64} = lowlevel Unreachable #Attr.2; - ret List.423; + let List.412 : {List U8, U64} = lowlevel Unreachable #Attr.2; + ret List.412; procedure List.70 (#Attr.2, #Attr.3): - let List.422 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.422; + let List.387 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.387; procedure List.71 (#Attr.2, #Attr.3): - let List.421 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.421; + let List.385 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.385; -procedure List.75 (List.361, List.362, List.363): - let List.425 : U64 = 0i64; - let List.426 : U64 = CallByName List.6 List.361; - let List.424 : [C [], C {List U8, U64}] = CallByName List.86 List.361 List.362 List.363 List.425 List.426; - ret List.424; +procedure List.75 (List.357, List.358, List.359): + let List.418 : U64 = 0i64; + let List.419 : U64 = CallByName List.6 List.357; + let List.417 : [C [], C {List U8, U64}] = CallByName List.86 List.357 List.358 List.359 List.418 List.419; + ret List.417; procedure List.8 (#Attr.2, #Attr.3): - let List.419 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.419; + let List.437 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.437; -procedure List.86 (List.455, List.456, List.457, List.458, List.459): - joinpoint List.427 List.364 List.365 List.366 List.367 List.368: - let List.429 : Int1 = CallByName Num.22 List.367 List.368; - if List.429 then - let List.438 : {Str, Str} = CallByName List.66 List.364 List.367; - let List.430 : [C [], C {List U8, U64}] = CallByName List.133 List.365 List.438 List.366; - let List.435 : U8 = 1i64; - let List.436 : U8 = GetTagId List.430; - let List.437 : Int1 = lowlevel Eq List.435 List.436; - if List.437 then - let List.369 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.430; - inc List.369; - dec List.430; - let List.433 : U64 = 1i64; - let List.432 : U64 = CallByName Num.19 List.367 List.433; - jump List.427 List.364 List.369 List.366 List.432 List.368; +procedure List.86 (List.449, List.450, List.451, List.452, List.453): + joinpoint List.420 List.360 List.361 List.362 List.363 List.364: + let List.422 : Int1 = CallByName Num.22 List.363 List.364; + if List.422 then + let List.431 : {Str, Str} = CallByName List.66 List.360 List.363; + let List.423 : [C [], C {List U8, U64}] = CallByName List.133 List.361 List.431 List.362; + let List.428 : U8 = 1i64; + let List.429 : U8 = GetTagId List.423; + let List.430 : Int1 = lowlevel Eq List.428 List.429; + if List.430 then + let List.365 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.423; + inc List.365; + dec List.423; + let List.426 : U64 = 1i64; + let List.425 : U64 = CallByName Num.19 List.363 List.426; + jump List.420 List.360 List.365 List.362 List.425 List.364; else - let List.370 : [] = UnionAtIndex (Id 0) (Index 0) List.430; - dec List.430; - let List.434 : [C [], C {List U8, U64}] = TagId(0) List.370; - ret List.434; + let List.366 : [] = UnionAtIndex (Id 0) (Index 0) List.423; + dec List.423; + let List.427 : [C [], C {List U8, U64}] = TagId(0) List.366; + ret List.427; else - let List.428 : [C [], C {List U8, U64}] = TagId(1) List.365; - ret List.428; + let List.421 : [C [], C {List U8, U64}] = TagId(1) List.361; + ret List.421; in - jump List.427 List.455 List.456 List.457 List.458 List.459; + jump List.420 List.449 List.450 List.451 List.452 List.453; procedure Num.123 (#Attr.2): let Num.264 : U8 = lowlevel NumIntCast #Attr.2; @@ -234,31 +234,31 @@ procedure Num.24 (#Attr.2, #Attr.3): ret Num.266; procedure Str.12 (#Attr.2): - let Str.217 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.217; + let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.266; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.211 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.211; + let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.260; -procedure Str.9 (Str.69): - let Str.209 : U64 = 0i64; - let Str.210 : U64 = CallByName List.6 Str.69; - let Str.70 : {U64, Str, Int1, U8} = CallByName Str.48 Str.69 Str.209 Str.210; - let Str.206 : Int1 = StructAtIndex 2 Str.70; - if Str.206 then - let Str.208 : Str = StructAtIndex 1 Str.70; - inc Str.208; - dec Str.70; - let Str.207 : [C {U64, U8}, C Str] = TagId(1) Str.208; - ret Str.207; +procedure Str.9 (Str.73): + let Str.258 : U64 = 0i64; + let Str.259 : U64 = CallByName List.6 Str.73; + let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; + let Str.255 : Int1 = StructAtIndex 2 Str.74; + if Str.255 then + let Str.257 : Str = StructAtIndex 1 Str.74; + inc Str.257; + dec Str.74; + let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; + ret Str.256; else - let Str.204 : U8 = StructAtIndex 3 Str.70; - let Str.205 : U64 = StructAtIndex 0 Str.70; - dec Str.70; - let Str.203 : {U64, U8} = Struct {Str.205, Str.204}; - let Str.202 : [C {U64, U8}, C Str] = TagId(0) Str.203; - ret Str.202; + let Str.253 : U8 = StructAtIndex 3 Str.74; + let Str.254 : U64 = StructAtIndex 0 Str.74; + dec Str.74; + let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; + let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; + ret Str.251; procedure Test.0 (): let Test.11 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index 5fd131fd3f..8be74f6f88 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -2,7 +2,7 @@ procedure Encode.22 (Encode.93): ret Encode.93; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.106 : List U8 = CallByName Json.87 Encode.94 Encode.96 Encode.102; + let Encode.106 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; ret Encode.106; procedure Encode.25 (Encode.100, Encode.101): @@ -12,76 +12,76 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.318 : {} = Struct {}; - ret Json.318; + let Json.396 : {} = Struct {}; + ret Json.396; -procedure Json.18 (Json.86): - let Json.319 : Str = CallByName Encode.22 Json.86; - ret Json.319; +procedure Json.18 (Json.96): + let Json.397 : Str = CallByName Encode.22 Json.96; + ret Json.397; -procedure Json.87 (Json.88, Json.321, Json.86): - let Json.330 : I32 = 34i64; - let Json.329 : U8 = CallByName Num.123 Json.330; - let Json.327 : List U8 = CallByName List.4 Json.88 Json.329; - let Json.328 : List U8 = CallByName Str.12 Json.86; - let Json.324 : List U8 = CallByName List.8 Json.327 Json.328; - let Json.326 : I32 = 34i64; - let Json.325 : U8 = CallByName Num.123 Json.326; - let Json.323 : List U8 = CallByName List.4 Json.324 Json.325; - ret Json.323; +procedure Json.97 (Json.98, Json.399, Json.96): + let Json.408 : I32 = 34i64; + let Json.407 : U8 = CallByName Num.123 Json.408; + let Json.405 : List U8 = CallByName List.4 Json.98 Json.407; + let Json.406 : List U8 = CallByName Str.12 Json.96; + let Json.402 : List U8 = CallByName List.8 Json.405 Json.406; + let Json.404 : I32 = 34i64; + let Json.403 : U8 = CallByName Num.123 Json.404; + let Json.401 : List U8 = CallByName List.4 Json.402 Json.403; + ret Json.401; procedure List.4 (List.101, List.102): - let List.392 : U64 = 1i64; - let List.391 : List U8 = CallByName List.70 List.101 List.392; - let List.390 : List U8 = CallByName List.71 List.391 List.102; - ret List.390; + let List.390 : U64 = 1i64; + let List.389 : List U8 = CallByName List.70 List.101 List.390; + let List.388 : List U8 = CallByName List.71 List.389 List.102; + ret List.388; procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure List.70 (#Attr.2, #Attr.3): - let List.395 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.395; + let List.387 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.387; procedure List.71 (#Attr.2, #Attr.3): - let List.394 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.394; + let List.385 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.385; procedure List.8 (#Attr.2, #Attr.3): - let List.393 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.393; + let List.391 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.391; procedure Num.123 (#Attr.2): let Num.258 : U8 = lowlevel NumIntCast #Attr.2; ret Num.258; procedure Str.12 (#Attr.2): - let Str.216 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.216; + let Str.265 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.265; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.211 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.211; + let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.260; -procedure Str.9 (Str.69): - let Str.209 : U64 = 0i64; - let Str.210 : U64 = CallByName List.6 Str.69; - let Str.70 : {U64, Str, Int1, U8} = CallByName Str.48 Str.69 Str.209 Str.210; - let Str.206 : Int1 = StructAtIndex 2 Str.70; - if Str.206 then - let Str.208 : Str = StructAtIndex 1 Str.70; - inc Str.208; - dec Str.70; - let Str.207 : [C {U64, U8}, C Str] = TagId(1) Str.208; - ret Str.207; +procedure Str.9 (Str.73): + let Str.258 : U64 = 0i64; + let Str.259 : U64 = CallByName List.6 Str.73; + let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; + let Str.255 : Int1 = StructAtIndex 2 Str.74; + if Str.255 then + let Str.257 : Str = StructAtIndex 1 Str.74; + inc Str.257; + dec Str.74; + let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; + ret Str.256; else - let Str.204 : U8 = StructAtIndex 3 Str.70; - let Str.205 : U64 = StructAtIndex 0 Str.70; - dec Str.70; - let Str.203 : {U64, U8} = Struct {Str.205, Str.204}; - let Str.202 : [C {U64, U8}, C Str] = TagId(0) Str.203; - ret Str.202; + let Str.253 : U8 = StructAtIndex 3 Str.74; + let Str.254 : U64 = StructAtIndex 0 Str.74; + dec Str.74; + let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; + let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; + ret Str.251; procedure Test.0 (): let Test.9 : Str = "abc"; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt index 1dab5efd61..fd02b620e6 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -27,11 +27,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.117 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.127 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.116 : List U8 = CallByName Json.87 Encode.94 Encode.96 Encode.102; + let Encode.116 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; ret Encode.116; procedure Encode.25 (Encode.100, Encode.101): @@ -41,178 +41,178 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.318 : {} = Struct {}; - ret Json.318; + let Json.396 : {} = Struct {}; + ret Json.396; -procedure Json.117 (Json.118, Json.321, #Attr.12): - let Json.116 : List Str = StructAtIndex 1 #Attr.12; - inc Json.116; - let Json.115 : Str = StructAtIndex 0 #Attr.12; - inc Json.115; +procedure Json.127 (Json.128, Json.399, #Attr.12): + let Json.126 : List Str = StructAtIndex 1 #Attr.12; + inc Json.126; + let Json.125 : Str = StructAtIndex 0 #Attr.12; + inc Json.125; dec #Attr.12; - let Json.362 : I32 = 123i64; - let Json.361 : U8 = CallByName Num.123 Json.362; - let Json.358 : List U8 = CallByName List.4 Json.118 Json.361; - let Json.360 : I32 = 34i64; - let Json.359 : U8 = CallByName Num.123 Json.360; - let Json.356 : List U8 = CallByName List.4 Json.358 Json.359; - let Json.357 : List U8 = CallByName Str.12 Json.115; - let Json.353 : List U8 = CallByName List.8 Json.356 Json.357; - let Json.355 : I32 = 34i64; - let Json.354 : U8 = CallByName Num.123 Json.355; - let Json.350 : List U8 = CallByName List.4 Json.353 Json.354; - let Json.352 : I32 = 58i64; - let Json.351 : U8 = CallByName Num.123 Json.352; - let Json.347 : List U8 = CallByName List.4 Json.350 Json.351; - let Json.349 : I32 = 91i64; - let Json.348 : U8 = CallByName Num.123 Json.349; - let Json.120 : List U8 = CallByName List.4 Json.347 Json.348; - let Json.346 : U64 = CallByName List.6 Json.116; - let Json.334 : {List U8, U64} = Struct {Json.120, Json.346}; - let Json.335 : {} = Struct {}; - let Json.333 : {List U8, U64} = CallByName List.18 Json.116 Json.334 Json.335; - dec Json.116; - let Json.122 : List U8 = StructAtIndex 0 Json.333; - inc Json.122; - dec Json.333; - let Json.332 : I32 = 93i64; - let Json.331 : U8 = CallByName Num.123 Json.332; - let Json.328 : List U8 = CallByName List.4 Json.122 Json.331; - let Json.330 : I32 = 125i64; - let Json.329 : U8 = CallByName Num.123 Json.330; - let Json.327 : List U8 = CallByName List.4 Json.328 Json.329; - ret Json.327; + let Json.437 : I32 = 123i64; + let Json.436 : U8 = CallByName Num.123 Json.437; + let Json.433 : List U8 = CallByName List.4 Json.128 Json.436; + let Json.435 : I32 = 34i64; + let Json.434 : U8 = CallByName Num.123 Json.435; + let Json.431 : List U8 = CallByName List.4 Json.433 Json.434; + let Json.432 : List U8 = CallByName Str.12 Json.125; + let Json.428 : List U8 = CallByName List.8 Json.431 Json.432; + let Json.430 : I32 = 34i64; + let Json.429 : U8 = CallByName Num.123 Json.430; + let Json.425 : List U8 = CallByName List.4 Json.428 Json.429; + let Json.427 : I32 = 58i64; + let Json.426 : U8 = CallByName Num.123 Json.427; + let Json.422 : List U8 = CallByName List.4 Json.425 Json.426; + let Json.424 : I32 = 91i64; + let Json.423 : U8 = CallByName Num.123 Json.424; + let Json.130 : List U8 = CallByName List.4 Json.422 Json.423; + let Json.421 : U64 = CallByName List.6 Json.126; + let Json.409 : {List U8, U64} = Struct {Json.130, Json.421}; + let Json.410 : {} = Struct {}; + let Json.408 : {List U8, U64} = CallByName List.18 Json.126 Json.409 Json.410; + dec Json.126; + let Json.132 : List U8 = StructAtIndex 0 Json.408; + inc Json.132; + dec Json.408; + let Json.407 : I32 = 93i64; + let Json.406 : U8 = CallByName Num.123 Json.407; + let Json.403 : List U8 = CallByName List.4 Json.132 Json.406; + let Json.405 : I32 = 125i64; + let Json.404 : U8 = CallByName Num.123 Json.405; + let Json.402 : List U8 = CallByName List.4 Json.403 Json.404; + ret Json.402; -procedure Json.119 (Json.326, Json.125): - let Json.123 : List U8 = StructAtIndex 0 Json.326; - inc Json.123; - let Json.124 : U64 = StructAtIndex 1 Json.326; - dec Json.326; - let Json.345 : {} = Struct {}; - let Json.126 : List U8 = CallByName Encode.23 Json.123 Json.125 Json.345; - joinpoint Json.340 Json.127: - let Json.338 : U64 = 1i64; - let Json.337 : U64 = CallByName Num.20 Json.124 Json.338; - let Json.336 : {List U8, U64} = Struct {Json.127, Json.337}; - ret Json.336; +procedure Json.129 (Json.401, Json.135): + let Json.133 : List U8 = StructAtIndex 0 Json.401; + inc Json.133; + let Json.134 : U64 = StructAtIndex 1 Json.401; + dec Json.401; + let Json.420 : {} = Struct {}; + let Json.136 : List U8 = CallByName Encode.23 Json.133 Json.135 Json.420; + joinpoint Json.415 Json.137: + let Json.413 : U64 = 1i64; + let Json.412 : U64 = CallByName Num.20 Json.134 Json.413; + let Json.411 : {List U8, U64} = Struct {Json.137, Json.412}; + ret Json.411; in - let Json.344 : U64 = 1i64; - let Json.341 : Int1 = CallByName Num.24 Json.124 Json.344; - if Json.341 then - let Json.343 : I32 = 44i64; - let Json.342 : U8 = CallByName Num.123 Json.343; - let Json.339 : List U8 = CallByName List.4 Json.126 Json.342; - jump Json.340 Json.339; + let Json.419 : U64 = 1i64; + let Json.416 : Int1 = CallByName Num.24 Json.134 Json.419; + if Json.416 then + let Json.418 : I32 = 44i64; + let Json.417 : U8 = CallByName Num.123 Json.418; + let Json.414 : List U8 = CallByName List.4 Json.136 Json.417; + jump Json.415 Json.414; else - jump Json.340 Json.126; + jump Json.415 Json.136; -procedure Json.18 (Json.86): - let Json.322 : Str = CallByName Encode.22 Json.86; - ret Json.322; +procedure Json.18 (Json.96): + let Json.438 : Str = CallByName Encode.22 Json.96; + ret Json.438; -procedure Json.21 (Json.115, Json.116): - let Json.320 : {Str, List Str} = Struct {Json.115, Json.116}; - let Json.319 : {Str, List Str} = CallByName Encode.22 Json.320; - ret Json.319; +procedure Json.21 (Json.125, Json.126): + let Json.398 : {Str, List Str} = Struct {Json.125, Json.126}; + let Json.397 : {Str, List Str} = CallByName Encode.22 Json.398; + ret Json.397; -procedure Json.87 (Json.88, Json.324, Json.86): - let Json.371 : I32 = 34i64; - let Json.370 : U8 = CallByName Num.123 Json.371; - let Json.368 : List U8 = CallByName List.4 Json.88 Json.370; - let Json.369 : List U8 = CallByName Str.12 Json.86; - let Json.365 : List U8 = CallByName List.8 Json.368 Json.369; - let Json.367 : I32 = 34i64; - let Json.366 : U8 = CallByName Num.123 Json.367; - let Json.364 : List U8 = CallByName List.4 Json.365 Json.366; - ret Json.364; +procedure Json.97 (Json.98, Json.440, Json.96): + let Json.449 : I32 = 34i64; + let Json.448 : U8 = CallByName Num.123 Json.449; + let Json.446 : List U8 = CallByName List.4 Json.98 Json.448; + let Json.447 : List U8 = CallByName Str.12 Json.96; + let Json.443 : List U8 = CallByName List.8 Json.446 Json.447; + let Json.445 : I32 = 34i64; + let Json.444 : U8 = CallByName Num.123 Json.445; + let Json.442 : List U8 = CallByName List.4 Json.443 Json.444; + ret Json.442; procedure List.133 (List.134, List.135, List.132): - let List.447 : {List U8, U64} = CallByName Json.119 List.134 List.135; - let List.446 : [C [], C {List U8, U64}] = TagId(1) List.447; - ret List.446; + let List.441 : {List U8, U64} = CallByName Json.129 List.134 List.135; + let List.440 : [C [], C {List U8, U64}] = TagId(1) List.441; + ret List.440; procedure List.18 (List.130, List.131, List.132): - let List.417 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; - let List.420 : U8 = 1i64; - let List.421 : U8 = GetTagId List.417; - let List.422 : Int1 = lowlevel Eq List.420 List.421; - if List.422 then - let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.417; + let List.415 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; + let List.419 : U8 = 1i64; + let List.420 : U8 = GetTagId List.415; + let List.421 : Int1 = lowlevel Eq List.419 List.420; + if List.421 then + let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.415; inc List.137; - dec List.417; + dec List.415; ret List.137; else - let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.417; - dec List.417; - let List.419 : {List U8, U64} = CallByName List.69 List.138; - ret List.419; + let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.415; + dec List.415; + let List.417 : {List U8, U64} = CallByName List.69 List.138; + ret List.417; procedure List.4 (List.101, List.102): - let List.416 : U64 = 1i64; - let List.415 : List U8 = CallByName List.70 List.101 List.416; - let List.414 : List U8 = CallByName List.71 List.415 List.102; - ret List.414; + let List.414 : U64 = 1i64; + let List.413 : List U8 = CallByName List.70 List.101 List.414; + let List.412 : List U8 = CallByName List.71 List.413 List.102; + ret List.412; procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure List.6 (#Attr.2): - let List.424 : U64 = lowlevel ListLen #Attr.2; - ret List.424; + let List.442 : U64 = lowlevel ListLen #Attr.2; + ret List.442; procedure List.66 (#Attr.2, #Attr.3): - let List.445 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.445; + let List.438 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.438; procedure List.69 (#Attr.2): - let List.429 : {List U8, U64} = lowlevel Unreachable #Attr.2; - ret List.429; + let List.418 : {List U8, U64} = lowlevel Unreachable #Attr.2; + ret List.418; procedure List.70 (#Attr.2, #Attr.3): - let List.428 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.428; + let List.387 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.387; procedure List.71 (#Attr.2, #Attr.3): - let List.427 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.427; + let List.385 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.385; -procedure List.75 (List.361, List.362, List.363): - let List.431 : U64 = 0i64; - let List.432 : U64 = CallByName List.6 List.361; - let List.430 : [C [], C {List U8, U64}] = CallByName List.86 List.361 List.362 List.363 List.431 List.432; - ret List.430; +procedure List.75 (List.357, List.358, List.359): + let List.424 : U64 = 0i64; + let List.425 : U64 = CallByName List.6 List.357; + let List.423 : [C [], C {List U8, U64}] = CallByName List.86 List.357 List.358 List.359 List.424 List.425; + ret List.423; procedure List.8 (#Attr.2, #Attr.3): - let List.426 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.426; + let List.444 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.444; -procedure List.86 (List.461, List.462, List.463, List.464, List.465): - joinpoint List.433 List.364 List.365 List.366 List.367 List.368: - let List.435 : Int1 = CallByName Num.22 List.367 List.368; - if List.435 then - let List.444 : Str = CallByName List.66 List.364 List.367; - let List.436 : [C [], C {List U8, U64}] = CallByName List.133 List.365 List.444 List.366; - let List.441 : U8 = 1i64; - let List.442 : U8 = GetTagId List.436; - let List.443 : Int1 = lowlevel Eq List.441 List.442; - if List.443 then - let List.369 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.436; - inc List.369; - dec List.436; - let List.439 : U64 = 1i64; - let List.438 : U64 = CallByName Num.19 List.367 List.439; - jump List.433 List.364 List.369 List.366 List.438 List.368; +procedure List.86 (List.455, List.456, List.457, List.458, List.459): + joinpoint List.426 List.360 List.361 List.362 List.363 List.364: + let List.428 : Int1 = CallByName Num.22 List.363 List.364; + if List.428 then + let List.437 : Str = CallByName List.66 List.360 List.363; + let List.429 : [C [], C {List U8, U64}] = CallByName List.133 List.361 List.437 List.362; + let List.434 : U8 = 1i64; + let List.435 : U8 = GetTagId List.429; + let List.436 : Int1 = lowlevel Eq List.434 List.435; + if List.436 then + let List.365 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.429; + inc List.365; + dec List.429; + let List.432 : U64 = 1i64; + let List.431 : U64 = CallByName Num.19 List.363 List.432; + jump List.426 List.360 List.365 List.362 List.431 List.364; else - let List.370 : [] = UnionAtIndex (Id 0) (Index 0) List.436; - dec List.436; - let List.440 : [C [], C {List U8, U64}] = TagId(0) List.370; - ret List.440; + let List.366 : [] = UnionAtIndex (Id 0) (Index 0) List.429; + dec List.429; + let List.433 : [C [], C {List U8, U64}] = TagId(0) List.366; + ret List.433; else - let List.434 : [C [], C {List U8, U64}] = TagId(1) List.365; - ret List.434; + let List.427 : [C [], C {List U8, U64}] = TagId(1) List.361; + ret List.427; in - jump List.433 List.461 List.462 List.463 List.464 List.465; + jump List.426 List.455 List.456 List.457 List.458 List.459; procedure Num.123 (#Attr.2): let Num.266 : U8 = lowlevel NumIntCast #Attr.2; @@ -235,31 +235,31 @@ procedure Num.24 (#Attr.2, #Attr.3): ret Num.268; procedure Str.12 (#Attr.2): - let Str.217 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.217; + let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.266; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.211 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.211; + let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.260; -procedure Str.9 (Str.69): - let Str.209 : U64 = 0i64; - let Str.210 : U64 = CallByName List.6 Str.69; - let Str.70 : {U64, Str, Int1, U8} = CallByName Str.48 Str.69 Str.209 Str.210; - let Str.206 : Int1 = StructAtIndex 2 Str.70; - if Str.206 then - let Str.208 : Str = StructAtIndex 1 Str.70; - inc Str.208; - dec Str.70; - let Str.207 : [C {U64, U8}, C Str] = TagId(1) Str.208; - ret Str.207; +procedure Str.9 (Str.73): + let Str.258 : U64 = 0i64; + let Str.259 : U64 = CallByName List.6 Str.73; + let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; + let Str.255 : Int1 = StructAtIndex 2 Str.74; + if Str.255 then + let Str.257 : Str = StructAtIndex 1 Str.74; + inc Str.257; + dec Str.74; + let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; + ret Str.256; else - let Str.204 : U8 = StructAtIndex 3 Str.70; - let Str.205 : U64 = StructAtIndex 0 Str.70; - dec Str.70; - let Str.203 : {U64, U8} = Struct {Str.205, Str.204}; - let Str.202 : [C {U64, U8}, C Str] = TagId(0) Str.203; - ret Str.202; + let Str.253 : U8 = StructAtIndex 3 Str.74; + let Str.254 : U64 = StructAtIndex 0 Str.74; + dec Str.74; + let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; + let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; + ret Str.251; procedure Test.0 (): let Test.12 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt index 81035c77b5..0d7ed85b9b 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -33,11 +33,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.117 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.127 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.117 : List U8 = CallByName Json.87 Encode.94 Encode.96 Encode.102; + let Encode.117 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; ret Encode.117; procedure Encode.25 (Encode.100, Encode.101): @@ -47,178 +47,178 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.318 : {} = Struct {}; - ret Json.318; + let Json.396 : {} = Struct {}; + ret Json.396; -procedure Json.117 (Json.118, Json.321, #Attr.12): - let Json.116 : List Str = StructAtIndex 1 #Attr.12; - inc Json.116; - let Json.115 : Str = StructAtIndex 0 #Attr.12; - inc Json.115; +procedure Json.127 (Json.128, Json.399, #Attr.12): + let Json.126 : List Str = StructAtIndex 1 #Attr.12; + inc Json.126; + let Json.125 : Str = StructAtIndex 0 #Attr.12; + inc Json.125; dec #Attr.12; - let Json.365 : I32 = 123i64; - let Json.364 : U8 = CallByName Num.123 Json.365; - let Json.361 : List U8 = CallByName List.4 Json.118 Json.364; - let Json.363 : I32 = 34i64; - let Json.362 : U8 = CallByName Num.123 Json.363; - let Json.359 : List U8 = CallByName List.4 Json.361 Json.362; - let Json.360 : List U8 = CallByName Str.12 Json.115; - let Json.356 : List U8 = CallByName List.8 Json.359 Json.360; - let Json.358 : I32 = 34i64; - let Json.357 : U8 = CallByName Num.123 Json.358; - let Json.353 : List U8 = CallByName List.4 Json.356 Json.357; - let Json.355 : I32 = 58i64; - let Json.354 : U8 = CallByName Num.123 Json.355; - let Json.350 : List U8 = CallByName List.4 Json.353 Json.354; - let Json.352 : I32 = 91i64; - let Json.351 : U8 = CallByName Num.123 Json.352; - let Json.120 : List U8 = CallByName List.4 Json.350 Json.351; - let Json.349 : U64 = CallByName List.6 Json.116; - let Json.337 : {List U8, U64} = Struct {Json.120, Json.349}; - let Json.338 : {} = Struct {}; - let Json.336 : {List U8, U64} = CallByName List.18 Json.116 Json.337 Json.338; - dec Json.116; - let Json.122 : List U8 = StructAtIndex 0 Json.336; - inc Json.122; - dec Json.336; - let Json.335 : I32 = 93i64; - let Json.334 : U8 = CallByName Num.123 Json.335; - let Json.331 : List U8 = CallByName List.4 Json.122 Json.334; - let Json.333 : I32 = 125i64; - let Json.332 : U8 = CallByName Num.123 Json.333; - let Json.330 : List U8 = CallByName List.4 Json.331 Json.332; - ret Json.330; + let Json.437 : I32 = 123i64; + let Json.436 : U8 = CallByName Num.123 Json.437; + let Json.433 : List U8 = CallByName List.4 Json.128 Json.436; + let Json.435 : I32 = 34i64; + let Json.434 : U8 = CallByName Num.123 Json.435; + let Json.431 : List U8 = CallByName List.4 Json.433 Json.434; + let Json.432 : List U8 = CallByName Str.12 Json.125; + let Json.428 : List U8 = CallByName List.8 Json.431 Json.432; + let Json.430 : I32 = 34i64; + let Json.429 : U8 = CallByName Num.123 Json.430; + let Json.425 : List U8 = CallByName List.4 Json.428 Json.429; + let Json.427 : I32 = 58i64; + let Json.426 : U8 = CallByName Num.123 Json.427; + let Json.422 : List U8 = CallByName List.4 Json.425 Json.426; + let Json.424 : I32 = 91i64; + let Json.423 : U8 = CallByName Num.123 Json.424; + let Json.130 : List U8 = CallByName List.4 Json.422 Json.423; + let Json.421 : U64 = CallByName List.6 Json.126; + let Json.409 : {List U8, U64} = Struct {Json.130, Json.421}; + let Json.410 : {} = Struct {}; + let Json.408 : {List U8, U64} = CallByName List.18 Json.126 Json.409 Json.410; + dec Json.126; + let Json.132 : List U8 = StructAtIndex 0 Json.408; + inc Json.132; + dec Json.408; + let Json.407 : I32 = 93i64; + let Json.406 : U8 = CallByName Num.123 Json.407; + let Json.403 : List U8 = CallByName List.4 Json.132 Json.406; + let Json.405 : I32 = 125i64; + let Json.404 : U8 = CallByName Num.123 Json.405; + let Json.402 : List U8 = CallByName List.4 Json.403 Json.404; + ret Json.402; -procedure Json.119 (Json.329, Json.125): - let Json.123 : List U8 = StructAtIndex 0 Json.329; - inc Json.123; - let Json.124 : U64 = StructAtIndex 1 Json.329; - dec Json.329; - let Json.348 : {} = Struct {}; - let Json.126 : List U8 = CallByName Encode.23 Json.123 Json.125 Json.348; - joinpoint Json.343 Json.127: - let Json.341 : U64 = 1i64; - let Json.340 : U64 = CallByName Num.20 Json.124 Json.341; - let Json.339 : {List U8, U64} = Struct {Json.127, Json.340}; - ret Json.339; +procedure Json.129 (Json.401, Json.135): + let Json.133 : List U8 = StructAtIndex 0 Json.401; + inc Json.133; + let Json.134 : U64 = StructAtIndex 1 Json.401; + dec Json.401; + let Json.420 : {} = Struct {}; + let Json.136 : List U8 = CallByName Encode.23 Json.133 Json.135 Json.420; + joinpoint Json.415 Json.137: + let Json.413 : U64 = 1i64; + let Json.412 : U64 = CallByName Num.20 Json.134 Json.413; + let Json.411 : {List U8, U64} = Struct {Json.137, Json.412}; + ret Json.411; in - let Json.347 : U64 = 1i64; - let Json.344 : Int1 = CallByName Num.24 Json.124 Json.347; - if Json.344 then - let Json.346 : I32 = 44i64; - let Json.345 : U8 = CallByName Num.123 Json.346; - let Json.342 : List U8 = CallByName List.4 Json.126 Json.345; - jump Json.343 Json.342; + let Json.419 : U64 = 1i64; + let Json.416 : Int1 = CallByName Num.24 Json.134 Json.419; + if Json.416 then + let Json.418 : I32 = 44i64; + let Json.417 : U8 = CallByName Num.123 Json.418; + let Json.414 : List U8 = CallByName List.4 Json.136 Json.417; + jump Json.415 Json.414; else - jump Json.343 Json.126; + jump Json.415 Json.136; -procedure Json.18 (Json.86): - let Json.325 : Str = CallByName Encode.22 Json.86; - ret Json.325; +procedure Json.18 (Json.96): + let Json.450 : Str = CallByName Encode.22 Json.96; + ret Json.450; -procedure Json.21 (Json.115, Json.116): - let Json.320 : {Str, List Str} = Struct {Json.115, Json.116}; - let Json.319 : {Str, List Str} = CallByName Encode.22 Json.320; - ret Json.319; +procedure Json.21 (Json.125, Json.126): + let Json.398 : {Str, List Str} = Struct {Json.125, Json.126}; + let Json.397 : {Str, List Str} = CallByName Encode.22 Json.398; + ret Json.397; -procedure Json.87 (Json.88, Json.324, Json.86): - let Json.374 : I32 = 34i64; - let Json.373 : U8 = CallByName Num.123 Json.374; - let Json.371 : List U8 = CallByName List.4 Json.88 Json.373; - let Json.372 : List U8 = CallByName Str.12 Json.86; - let Json.368 : List U8 = CallByName List.8 Json.371 Json.372; - let Json.370 : I32 = 34i64; - let Json.369 : U8 = CallByName Num.123 Json.370; - let Json.367 : List U8 = CallByName List.4 Json.368 Json.369; - ret Json.367; +procedure Json.97 (Json.98, Json.440, Json.96): + let Json.449 : I32 = 34i64; + let Json.448 : U8 = CallByName Num.123 Json.449; + let Json.446 : List U8 = CallByName List.4 Json.98 Json.448; + let Json.447 : List U8 = CallByName Str.12 Json.96; + let Json.443 : List U8 = CallByName List.8 Json.446 Json.447; + let Json.445 : I32 = 34i64; + let Json.444 : U8 = CallByName Num.123 Json.445; + let Json.442 : List U8 = CallByName List.4 Json.443 Json.444; + ret Json.442; procedure List.133 (List.134, List.135, List.132): - let List.447 : {List U8, U64} = CallByName Json.119 List.134 List.135; - let List.446 : [C [], C {List U8, U64}] = TagId(1) List.447; - ret List.446; + let List.441 : {List U8, U64} = CallByName Json.129 List.134 List.135; + let List.440 : [C [], C {List U8, U64}] = TagId(1) List.441; + ret List.440; procedure List.18 (List.130, List.131, List.132): - let List.417 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; - let List.420 : U8 = 1i64; - let List.421 : U8 = GetTagId List.417; - let List.422 : Int1 = lowlevel Eq List.420 List.421; - if List.422 then - let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.417; + let List.415 : [C [], C {List U8, U64}] = CallByName List.75 List.130 List.131 List.132; + let List.419 : U8 = 1i64; + let List.420 : U8 = GetTagId List.415; + let List.421 : Int1 = lowlevel Eq List.419 List.420; + if List.421 then + let List.137 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.415; inc List.137; - dec List.417; + dec List.415; ret List.137; else - let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.417; - dec List.417; - let List.419 : {List U8, U64} = CallByName List.69 List.138; - ret List.419; + let List.138 : [] = UnionAtIndex (Id 0) (Index 0) List.415; + dec List.415; + let List.417 : {List U8, U64} = CallByName List.69 List.138; + ret List.417; procedure List.4 (List.101, List.102): - let List.416 : U64 = 1i64; - let List.415 : List U8 = CallByName List.70 List.101 List.416; - let List.414 : List U8 = CallByName List.71 List.415 List.102; - ret List.414; + let List.414 : U64 = 1i64; + let List.413 : List U8 = CallByName List.70 List.101 List.414; + let List.412 : List U8 = CallByName List.71 List.413 List.102; + ret List.412; procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure List.6 (#Attr.2): - let List.424 : U64 = lowlevel ListLen #Attr.2; - ret List.424; + let List.442 : U64 = lowlevel ListLen #Attr.2; + ret List.442; procedure List.66 (#Attr.2, #Attr.3): - let List.445 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.445; + let List.438 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.438; procedure List.69 (#Attr.2): - let List.429 : {List U8, U64} = lowlevel Unreachable #Attr.2; - ret List.429; + let List.418 : {List U8, U64} = lowlevel Unreachable #Attr.2; + ret List.418; procedure List.70 (#Attr.2, #Attr.3): - let List.428 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.428; + let List.387 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.387; procedure List.71 (#Attr.2, #Attr.3): - let List.427 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.427; + let List.385 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.385; -procedure List.75 (List.361, List.362, List.363): - let List.431 : U64 = 0i64; - let List.432 : U64 = CallByName List.6 List.361; - let List.430 : [C [], C {List U8, U64}] = CallByName List.86 List.361 List.362 List.363 List.431 List.432; - ret List.430; +procedure List.75 (List.357, List.358, List.359): + let List.424 : U64 = 0i64; + let List.425 : U64 = CallByName List.6 List.357; + let List.423 : [C [], C {List U8, U64}] = CallByName List.86 List.357 List.358 List.359 List.424 List.425; + ret List.423; procedure List.8 (#Attr.2, #Attr.3): - let List.426 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.426; + let List.444 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.444; -procedure List.86 (List.461, List.462, List.463, List.464, List.465): - joinpoint List.433 List.364 List.365 List.366 List.367 List.368: - let List.435 : Int1 = CallByName Num.22 List.367 List.368; - if List.435 then - let List.444 : Str = CallByName List.66 List.364 List.367; - let List.436 : [C [], C {List U8, U64}] = CallByName List.133 List.365 List.444 List.366; - let List.441 : U8 = 1i64; - let List.442 : U8 = GetTagId List.436; - let List.443 : Int1 = lowlevel Eq List.441 List.442; - if List.443 then - let List.369 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.436; - inc List.369; - dec List.436; - let List.439 : U64 = 1i64; - let List.438 : U64 = CallByName Num.19 List.367 List.439; - jump List.433 List.364 List.369 List.366 List.438 List.368; +procedure List.86 (List.455, List.456, List.457, List.458, List.459): + joinpoint List.426 List.360 List.361 List.362 List.363 List.364: + let List.428 : Int1 = CallByName Num.22 List.363 List.364; + if List.428 then + let List.437 : Str = CallByName List.66 List.360 List.363; + let List.429 : [C [], C {List U8, U64}] = CallByName List.133 List.361 List.437 List.362; + let List.434 : U8 = 1i64; + let List.435 : U8 = GetTagId List.429; + let List.436 : Int1 = lowlevel Eq List.434 List.435; + if List.436 then + let List.365 : {List U8, U64} = UnionAtIndex (Id 1) (Index 0) List.429; + inc List.365; + dec List.429; + let List.432 : U64 = 1i64; + let List.431 : U64 = CallByName Num.19 List.363 List.432; + jump List.426 List.360 List.365 List.362 List.431 List.364; else - let List.370 : [] = UnionAtIndex (Id 0) (Index 0) List.436; - dec List.436; - let List.440 : [C [], C {List U8, U64}] = TagId(0) List.370; - ret List.440; + let List.366 : [] = UnionAtIndex (Id 0) (Index 0) List.429; + dec List.429; + let List.433 : [C [], C {List U8, U64}] = TagId(0) List.366; + ret List.433; else - let List.434 : [C [], C {List U8, U64}] = TagId(1) List.365; - ret List.434; + let List.427 : [C [], C {List U8, U64}] = TagId(1) List.361; + ret List.427; in - jump List.433 List.461 List.462 List.463 List.464 List.465; + jump List.426 List.455 List.456 List.457 List.458 List.459; procedure Num.123 (#Attr.2): let Num.266 : U8 = lowlevel NumIntCast #Attr.2; @@ -241,31 +241,31 @@ procedure Num.24 (#Attr.2, #Attr.3): ret Num.268; procedure Str.12 (#Attr.2): - let Str.217 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.217; + let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.266; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.211 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.211; + let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.260; -procedure Str.9 (Str.69): - let Str.209 : U64 = 0i64; - let Str.210 : U64 = CallByName List.6 Str.69; - let Str.70 : {U64, Str, Int1, U8} = CallByName Str.48 Str.69 Str.209 Str.210; - let Str.206 : Int1 = StructAtIndex 2 Str.70; - if Str.206 then - let Str.208 : Str = StructAtIndex 1 Str.70; - inc Str.208; - dec Str.70; - let Str.207 : [C {U64, U8}, C Str] = TagId(1) Str.208; - ret Str.207; +procedure Str.9 (Str.73): + let Str.258 : U64 = 0i64; + let Str.259 : U64 = CallByName List.6 Str.73; + let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; + let Str.255 : Int1 = StructAtIndex 2 Str.74; + if Str.255 then + let Str.257 : Str = StructAtIndex 1 Str.74; + inc Str.257; + dec Str.74; + let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; + ret Str.256; else - let Str.204 : U8 = StructAtIndex 3 Str.70; - let Str.205 : U64 = StructAtIndex 0 Str.70; - dec Str.70; - let Str.203 : {U64, U8} = Struct {Str.205, Str.204}; - let Str.202 : [C {U64, U8}, C Str] = TagId(0) Str.203; - ret Str.202; + let Str.253 : U8 = StructAtIndex 3 Str.74; + let Str.254 : U64 = StructAtIndex 0 Str.74; + dec Str.74; + let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; + let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; + ret Str.251; procedure Test.0 (): let Test.13 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/guard_pattern_true.txt b/crates/compiler/test_mono/generated/guard_pattern_true.txt index 47bfc64e1f..f535579130 100644 --- a/crates/compiler/test_mono/generated/guard_pattern_true.txt +++ b/crates/compiler/test_mono/generated/guard_pattern_true.txt @@ -1,25 +1,29 @@ -procedure Test.1 (Test.3): - let Test.6 : I64 = 2i64; - joinpoint Test.11: - let Test.10 : I64 = 0i64; - ret Test.10; +procedure Bool.1 (): + let Bool.11 : Int1 = false; + ret Bool.11; + +procedure Test.1 (Test.2): + let Test.5 : I64 = 2i64; + joinpoint Test.10: + let Test.9 : I64 = 0i64; + ret Test.9; in - let Test.13 : I64 = 2i64; - let Test.14 : Int1 = lowlevel Eq Test.13 Test.6; - if Test.14 then - joinpoint Test.8 Test.12: - if Test.12 then - let Test.7 : I64 = 42i64; - ret Test.7; + let Test.12 : I64 = 2i64; + let Test.13 : Int1 = lowlevel Eq Test.12 Test.5; + if Test.13 then + joinpoint Test.7 Test.11: + if Test.11 then + let Test.6 : I64 = 42i64; + ret Test.6; else - jump Test.11; + jump Test.10; in - let Test.9 : Int1 = false; - jump Test.8 Test.9; + let Test.8 : Int1 = CallByName Bool.1; + jump Test.7 Test.8; else - jump Test.11; + jump Test.10; procedure Test.0 (): - let Test.5 : {} = Struct {}; - let Test.4 : I64 = CallByName Test.1 Test.5; - ret Test.4; + let Test.4 : {} = Struct {}; + let Test.3 : I64 = CallByName Test.1 Test.4; + ret Test.3; diff --git a/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt b/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt index 7d73011b72..1565f25f88 100644 --- a/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt +++ b/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt @@ -1,6 +1,6 @@ procedure Bool.7 (#Attr.2, #Attr.3): - let Bool.9 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.9; + let Bool.11 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.11; procedure Test.1 (Test.3): let Test.6 : I64 = 10i64; diff --git a/crates/compiler/test_mono/generated/if_multi_branch.txt b/crates/compiler/test_mono/generated/if_multi_branch.txt index 6178c6a0db..36dddc2fe9 100644 --- a/crates/compiler/test_mono/generated/if_multi_branch.txt +++ b/crates/compiler/test_mono/generated/if_multi_branch.txt @@ -1,13 +1,21 @@ +procedure Bool.1 (): + let Bool.11 : Int1 = false; + ret Bool.11; + +procedure Bool.2 (): + let Bool.12 : Int1 = true; + ret Bool.12; + procedure Test.0 (): - let Test.6 : Int1 = true; - if Test.6 then - let Test.7 : I64 = 1i64; - ret Test.7; + let Test.4 : Int1 = CallByName Bool.2; + if Test.4 then + let Test.5 : I64 = 1i64; + ret Test.5; else - let Test.4 : Int1 = false; - if Test.4 then - let Test.5 : I64 = 2i64; - ret Test.5; - else - let Test.3 : I64 = 3i64; + let Test.2 : Int1 = CallByName Bool.1; + if Test.2 then + let Test.3 : I64 = 2i64; ret Test.3; + else + let Test.1 : I64 = 3i64; + ret Test.1; diff --git a/crates/compiler/test_mono/generated/ir_int_add.txt b/crates/compiler/test_mono/generated/ir_int_add.txt index 6b56056268..0a3a468536 100644 --- a/crates/compiler/test_mono/generated/ir_int_add.txt +++ b/crates/compiler/test_mono/generated/ir_int_add.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure Num.19 (#Attr.2, #Attr.3): let Num.259 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/ir_when_idiv.txt b/crates/compiler/test_mono/generated/ir_when_idiv.txt index a53679812c..6ab0065bc7 100644 --- a/crates/compiler/test_mono/generated/ir_when_idiv.txt +++ b/crates/compiler/test_mono/generated/ir_when_idiv.txt @@ -1,18 +1,18 @@ procedure Bool.7 (#Attr.2, #Attr.3): - let Bool.9 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.9; + let Bool.11 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.11; procedure Num.39 (#Attr.2, #Attr.3): - let Num.263 : I64 = lowlevel NumDivUnchecked #Attr.2 #Attr.3; - ret Num.263; + let Num.259 : I64 = lowlevel NumDivTruncUnchecked #Attr.2 #Attr.3; + ret Num.259; procedure Num.40 (Num.229, Num.230): - let Num.262 : I64 = 0i64; - let Num.259 : Int1 = CallByName Bool.7 Num.230 Num.262; - if Num.259 then - let Num.261 : {} = Struct {}; - let Num.260 : [C {}, C I64] = TagId(0) Num.261; - ret Num.260; + let Num.263 : I64 = 0i64; + let Num.260 : Int1 = CallByName Bool.7 Num.230 Num.263; + if Num.260 then + let Num.262 : {} = Struct {}; + let Num.261 : [C {}, C I64] = TagId(0) Num.262; + ret Num.261; else let Num.258 : I64 = CallByName Num.39 Num.229 Num.230; let Num.257 : [C {}, C I64] = TagId(1) Num.258; diff --git a/crates/compiler/test_mono/generated/is_nil.txt b/crates/compiler/test_mono/generated/is_nil.txt index 474267831b..aaea58f73a 100644 --- a/crates/compiler/test_mono/generated/is_nil.txt +++ b/crates/compiler/test_mono/generated/is_nil.txt @@ -1,18 +1,26 @@ +procedure Bool.1 (): + let Bool.12 : Int1 = false; + ret Bool.12; + +procedure Bool.2 (): + let Bool.11 : Int1 = true; + ret Bool.11; + procedure Test.2 (Test.4): - let Test.13 : U8 = 1i64; - let Test.14 : U8 = GetTagId Test.4; - let Test.15 : Int1 = lowlevel Eq Test.13 Test.14; - if Test.15 then - let Test.11 : Int1 = true; - ret Test.11; + let Test.11 : U8 = 1i64; + let Test.12 : U8 = GetTagId Test.4; + let Test.13 : Int1 = lowlevel Eq Test.11 Test.12; + if Test.13 then + let Test.9 : Int1 = CallByName Bool.2; + ret Test.9; else - let Test.12 : Int1 = false; - ret Test.12; + let Test.10 : Int1 = CallByName Bool.1; + ret Test.10; procedure Test.0 (): - let Test.16 : I64 = 2i64; - let Test.17 : [, C I64 *self] = TagId(1) ; - let Test.10 : [, C I64 *self] = TagId(0) Test.16 Test.17; - let Test.9 : Int1 = CallByName Test.2 Test.10; - dec Test.10; - ret Test.9; + let Test.14 : I64 = 2i64; + let Test.15 : [, C I64 *self] = TagId(1) ; + let Test.8 : [, C I64 *self] = TagId(0) Test.14 Test.15; + let Test.7 : Int1 = CallByName Test.2 Test.8; + dec Test.8; + ret Test.7; diff --git a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt index ccbd053d38..7630ad155e 100644 --- a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt +++ b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt @@ -1,77 +1,81 @@ +procedure Bool.2 (): + let Bool.11 : Int1 = true; + ret Bool.11; + procedure Bool.7 (#Attr.2, #Attr.3): - let Bool.9 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.9; + let Bool.12 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.12; procedure List.2 (List.90, List.91): - let List.399 : U64 = CallByName List.6 List.90; - let List.395 : Int1 = CallByName Num.22 List.91 List.399; - if List.395 then - let List.397 : I64 = CallByName List.66 List.90 List.91; - let List.396 : [C {}, C I64] = TagId(1) List.397; - ret List.396; + let List.395 : U64 = CallByName List.6 List.90; + let List.391 : Int1 = CallByName Num.22 List.91 List.395; + if List.391 then + let List.393 : I64 = CallByName List.66 List.90 List.91; + let List.392 : [C {}, C I64] = TagId(1) List.393; + ret List.392; else - let List.394 : {} = Struct {}; - let List.393 : [C {}, C I64] = TagId(0) List.394; - ret List.393; + let List.390 : {} = Struct {}; + let List.389 : [C {}, C I64] = TagId(0) List.390; + ret List.389; procedure List.6 (#Attr.2): - let List.400 : U64 = lowlevel ListLen #Attr.2; - ret List.400; + let List.396 : U64 = lowlevel ListLen #Attr.2; + ret List.396; procedure List.66 (#Attr.2, #Attr.3): - let List.398 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.398; + let List.394 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.394; -procedure List.9 (List.218): - let List.392 : U64 = 0i64; - let List.385 : [C {}, C I64] = CallByName List.2 List.218 List.392; - let List.389 : U8 = 1i64; - let List.390 : U8 = GetTagId List.385; - let List.391 : Int1 = lowlevel Eq List.389 List.390; - if List.391 then - let List.219 : I64 = UnionAtIndex (Id 1) (Index 0) List.385; - let List.386 : [C Int1, C I64] = TagId(1) List.219; - ret List.386; +procedure List.9 (List.214): + let List.388 : U64 = 0i64; + let List.381 : [C {}, C I64] = CallByName List.2 List.214 List.388; + let List.385 : U8 = 1i64; + let List.386 : U8 = GetTagId List.381; + let List.387 : Int1 = lowlevel Eq List.385 List.386; + if List.387 then + let List.215 : I64 = UnionAtIndex (Id 1) (Index 0) List.381; + let List.382 : [C Int1, C I64] = TagId(1) List.215; + ret List.382; else - let List.388 : Int1 = true; - let List.387 : [C Int1, C I64] = TagId(0) List.388; - ret List.387; + let List.384 : Int1 = true; + let List.383 : [C Int1, C I64] = TagId(0) List.384; + ret List.383; procedure Num.22 (#Attr.2, #Attr.3): let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.257; -procedure Str.27 (Str.89): - let Str.202 : [C Int1, C I64] = CallByName Str.62 Str.89; - ret Str.202; +procedure Str.27 (Str.93): + let Str.251 : [C Int1, C I64] = CallByName Str.66 Str.93; + ret Str.251; procedure Str.47 (#Attr.2): - let Str.210 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.210; + let Str.259 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.259; -procedure Str.62 (Str.190): - let Str.191 : {I64, U8} = CallByName Str.47 Str.190; - let Str.208 : U8 = StructAtIndex 1 Str.191; - let Str.209 : U8 = 0i64; - let Str.205 : Int1 = CallByName Bool.7 Str.208 Str.209; - if Str.205 then - let Str.207 : I64 = StructAtIndex 0 Str.191; - let Str.206 : [C Int1, C I64] = TagId(1) Str.207; - ret Str.206; +procedure Str.66 (Str.222): + let Str.223 : {I64, U8} = CallByName Str.47 Str.222; + let Str.257 : U8 = StructAtIndex 1 Str.223; + let Str.258 : U8 = 0i64; + let Str.254 : Int1 = CallByName Bool.7 Str.257 Str.258; + if Str.254 then + let Str.256 : I64 = StructAtIndex 0 Str.223; + let Str.255 : [C Int1, C I64] = TagId(1) Str.256; + ret Str.255; else - let Str.204 : Int1 = false; - let Str.203 : [C Int1, C I64] = TagId(0) Str.204; - ret Str.203; + let Str.253 : Int1 = false; + let Str.252 : [C Int1, C I64] = TagId(0) Str.253; + ret Str.252; procedure Test.0 (): - let Test.4 : Int1 = true; - if Test.4 then - let Test.6 : List I64 = Array []; - let Test.5 : [C Int1, C I64] = CallByName List.9 Test.6; - dec Test.6; - ret Test.5; + let Test.3 : Int1 = CallByName Bool.2; + if Test.3 then + let Test.5 : List I64 = Array []; + let Test.4 : [C Int1, C I64] = CallByName List.9 Test.5; + dec Test.5; + ret Test.4; else - let Test.3 : Str = ""; - let Test.2 : [C Int1, C I64] = CallByName Str.27 Test.3; - dec Test.3; - ret Test.2; + let Test.2 : Str = ""; + let Test.1 : [C Int1, C I64] = CallByName Str.27 Test.2; + dec Test.2; + ret Test.1; diff --git a/crates/compiler/test_mono/generated/issue_3669.txt b/crates/compiler/test_mono/generated/issue_3669.txt index 5025608363..11d9485149 100644 --- a/crates/compiler/test_mono/generated/issue_3669.txt +++ b/crates/compiler/test_mono/generated/issue_3669.txt @@ -1,6 +1,6 @@ procedure Bool.7 (#Attr.2, #Attr.3): - let Bool.9 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.9; + let Bool.11 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.11; procedure Test.2 (Test.19): joinpoint Test.13 Test.7: diff --git a/crates/compiler/test_mono/generated/list_append.txt b/crates/compiler/test_mono/generated/list_append.txt index 77dd229693..7b6b3d8f20 100644 --- a/crates/compiler/test_mono/generated/list_append.txt +++ b/crates/compiler/test_mono/generated/list_append.txt @@ -1,16 +1,16 @@ procedure List.4 (List.101, List.102): - let List.387 : U64 = 1i64; - let List.386 : List I64 = CallByName List.70 List.101 List.387; - let List.385 : List I64 = CallByName List.71 List.386 List.102; - ret List.385; + let List.384 : U64 = 1i64; + let List.382 : List I64 = CallByName List.70 List.101 List.384; + let List.381 : List I64 = CallByName List.71 List.382 List.102; + ret List.381; procedure List.70 (#Attr.2, #Attr.3): - let List.389 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.389; + let List.385 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.385; procedure List.71 (#Attr.2, #Attr.3): - let List.388 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.388; + let List.383 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.383; procedure Test.0 (): let Test.2 : List I64 = Array [1i64]; diff --git a/crates/compiler/test_mono/generated/list_append_closure.txt b/crates/compiler/test_mono/generated/list_append_closure.txt index c2718f77a5..5042b9fd63 100644 --- a/crates/compiler/test_mono/generated/list_append_closure.txt +++ b/crates/compiler/test_mono/generated/list_append_closure.txt @@ -1,16 +1,16 @@ procedure List.4 (List.101, List.102): - let List.387 : U64 = 1i64; - let List.386 : List I64 = CallByName List.70 List.101 List.387; - let List.385 : List I64 = CallByName List.71 List.386 List.102; - ret List.385; + let List.384 : U64 = 1i64; + let List.382 : List I64 = CallByName List.70 List.101 List.384; + let List.381 : List I64 = CallByName List.71 List.382 List.102; + ret List.381; procedure List.70 (#Attr.2, #Attr.3): - let List.389 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.389; + let List.385 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.385; procedure List.71 (#Attr.2, #Attr.3): - let List.388 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.388; + let List.383 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.383; procedure Test.1 (Test.2): let Test.6 : I64 = 42i64; diff --git a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt index fb0edd59df..2d43d4aab6 100644 --- a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt +++ b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt @@ -1,27 +1,27 @@ procedure List.3 (List.98, List.99, List.100): - let List.388 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.387 : List I64 = StructAtIndex 0 List.388; - inc List.387; - dec List.388; - ret List.387; + let List.384 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; + let List.383 : List I64 = StructAtIndex 0 List.384; + inc List.383; + dec List.384; + ret List.383; procedure List.6 (#Attr.2): - let List.386 : U64 = lowlevel ListLen #Attr.2; - ret List.386; + let List.382 : U64 = lowlevel ListLen #Attr.2; + ret List.382; procedure List.64 (List.95, List.96, List.97): - let List.393 : U64 = CallByName List.6 List.95; - let List.390 : Int1 = CallByName Num.22 List.96 List.393; - if List.390 then - let List.391 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.391; + let List.389 : U64 = CallByName List.6 List.95; + let List.386 : Int1 = CallByName Num.22 List.96 List.389; + if List.386 then + let List.387 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; + ret List.387; else - let List.389 : {List I64, I64} = Struct {List.95, List.97}; - ret List.389; + let List.385 : {List I64, I64} = Struct {List.95, List.97}; + ret List.385; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.392 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.392; + let List.388 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.388; procedure Num.19 (#Attr.2, #Attr.3): let Num.257 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_get.txt b/crates/compiler/test_mono/generated/list_get.txt index a6d352d43e..272cbd8cd4 100644 --- a/crates/compiler/test_mono/generated/list_get.txt +++ b/crates/compiler/test_mono/generated/list_get.txt @@ -1,22 +1,22 @@ procedure List.2 (List.90, List.91): - let List.390 : U64 = CallByName List.6 List.90; - let List.387 : Int1 = CallByName Num.22 List.91 List.390; - if List.387 then - let List.389 : I64 = CallByName List.66 List.90 List.91; - let List.388 : [C {}, C I64] = TagId(1) List.389; - ret List.388; + let List.387 : U64 = CallByName List.6 List.90; + let List.383 : Int1 = CallByName Num.22 List.91 List.387; + if List.383 then + let List.385 : I64 = CallByName List.66 List.90 List.91; + let List.384 : [C {}, C I64] = TagId(1) List.385; + ret List.384; else - let List.386 : {} = Struct {}; - let List.385 : [C {}, C I64] = TagId(0) List.386; - ret List.385; + let List.382 : {} = Struct {}; + let List.381 : [C {}, C I64] = TagId(0) List.382; + ret List.381; procedure List.6 (#Attr.2): - let List.392 : U64 = lowlevel ListLen #Attr.2; - ret List.392; + let List.388 : U64 = lowlevel ListLen #Attr.2; + ret List.388; procedure List.66 (#Attr.2, #Attr.3): - let List.391 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.391; + let List.386 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.386; procedure Num.22 (#Attr.2, #Attr.3): let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_len.txt b/crates/compiler/test_mono/generated/list_len.txt index 6401dd667d..771d479227 100644 --- a/crates/compiler/test_mono/generated/list_len.txt +++ b/crates/compiler/test_mono/generated/list_len.txt @@ -1,10 +1,10 @@ procedure List.6 (#Attr.2): - let List.385 : U64 = lowlevel ListLen #Attr.2; - ret List.385; + let List.381 : U64 = lowlevel ListLen #Attr.2; + ret List.381; procedure List.6 (#Attr.2): - let List.386 : U64 = lowlevel ListLen #Attr.2; - ret List.386; + let List.382 : U64 = lowlevel ListLen #Attr.2; + ret List.382; procedure Num.19 (#Attr.2, #Attr.3): let Num.257 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt index ec453f3360..ff24fdf4c8 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt @@ -1,38 +1,38 @@ procedure List.2 (List.90, List.91): - let List.390 : U64 = CallByName List.6 List.90; - let List.387 : Int1 = CallByName Num.22 List.91 List.390; - if List.387 then - let List.389 : Str = CallByName List.66 List.90 List.91; - let List.388 : [C {}, C Str] = TagId(1) List.389; - ret List.388; + let List.387 : U64 = CallByName List.6 List.90; + let List.383 : Int1 = CallByName Num.22 List.91 List.387; + if List.383 then + let List.385 : Str = CallByName List.66 List.90 List.91; + let List.384 : [C {}, C Str] = TagId(1) List.385; + ret List.384; else - let List.386 : {} = Struct {}; - let List.385 : [C {}, C Str] = TagId(0) List.386; - ret List.385; + let List.382 : {} = Struct {}; + let List.381 : [C {}, C Str] = TagId(0) List.382; + ret List.381; procedure List.5 (#Attr.2, #Attr.3): - let List.391 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; - ret List.391; + let List.389 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + ret List.389; procedure List.6 (#Attr.2): - let List.393 : U64 = lowlevel ListLen #Attr.2; - ret List.393; + let List.388 : U64 = lowlevel ListLen #Attr.2; + ret List.388; procedure List.66 (#Attr.2, #Attr.3): - let List.392 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.392; + let List.386 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.386; procedure Num.22 (#Attr.2, #Attr.3): let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.257; procedure Str.16 (#Attr.2, #Attr.3): - let Str.202 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; - ret Str.202; + let Str.251 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; + ret Str.251; procedure Str.3 (#Attr.2, #Attr.3): - let Str.203 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.203; + let Str.252 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.252; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_map_closure_owns.txt b/crates/compiler/test_mono/generated/list_map_closure_owns.txt index 2cd40864a0..7767b1594c 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_owns.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_owns.txt @@ -1,36 +1,36 @@ procedure List.2 (List.90, List.91): - let List.390 : U64 = CallByName List.6 List.90; - let List.387 : Int1 = CallByName Num.22 List.91 List.390; - if List.387 then - let List.389 : Str = CallByName List.66 List.90 List.91; - let List.388 : [C {}, C Str] = TagId(1) List.389; - ret List.388; + let List.387 : U64 = CallByName List.6 List.90; + let List.383 : Int1 = CallByName Num.22 List.91 List.387; + if List.383 then + let List.385 : Str = CallByName List.66 List.90 List.91; + let List.384 : [C {}, C Str] = TagId(1) List.385; + ret List.384; else - let List.386 : {} = Struct {}; - let List.385 : [C {}, C Str] = TagId(0) List.386; - ret List.385; + let List.382 : {} = Struct {}; + let List.381 : [C {}, C Str] = TagId(0) List.382; + ret List.381; procedure List.5 (#Attr.2, #Attr.3): inc #Attr.2; - let List.391 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.389 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.391; + ret List.389; procedure List.6 (#Attr.2): - let List.393 : U64 = lowlevel ListLen #Attr.2; - ret List.393; + let List.388 : U64 = lowlevel ListLen #Attr.2; + ret List.388; procedure List.66 (#Attr.2, #Attr.3): - let List.392 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.392; + let List.386 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.386; procedure Num.22 (#Attr.2, #Attr.3): let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.257; procedure Str.3 (#Attr.2, #Attr.3): - let Str.203 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.203; + let Str.252 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.252; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_pass_to_function.txt b/crates/compiler/test_mono/generated/list_pass_to_function.txt index b49095993b..5d4c1098f3 100644 --- a/crates/compiler/test_mono/generated/list_pass_to_function.txt +++ b/crates/compiler/test_mono/generated/list_pass_to_function.txt @@ -1,27 +1,27 @@ procedure List.3 (List.98, List.99, List.100): - let List.386 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.385 : List I64 = StructAtIndex 0 List.386; - inc List.385; - dec List.386; - ret List.385; + let List.382 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; + let List.381 : List I64 = StructAtIndex 0 List.382; + inc List.381; + dec List.382; + ret List.381; procedure List.6 (#Attr.2): - let List.392 : U64 = lowlevel ListLen #Attr.2; - ret List.392; + let List.388 : U64 = lowlevel ListLen #Attr.2; + ret List.388; procedure List.64 (List.95, List.96, List.97): - let List.391 : U64 = CallByName List.6 List.95; - let List.388 : Int1 = CallByName Num.22 List.96 List.391; - if List.388 then - let List.389 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.389; + let List.387 : U64 = CallByName List.6 List.95; + let List.384 : Int1 = CallByName Num.22 List.96 List.387; + if List.384 then + let List.385 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; + ret List.385; else - let List.387 : {List I64, I64} = Struct {List.95, List.97}; - ret List.387; + let List.383 : {List I64, I64} = Struct {List.95, List.97}; + ret List.383; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.390 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.390; + let List.386 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.386; procedure Num.22 (#Attr.2, #Attr.3): let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_sort_asc.txt b/crates/compiler/test_mono/generated/list_sort_asc.txt index a824deb62c..4fe3b9e089 100644 --- a/crates/compiler/test_mono/generated/list_sort_asc.txt +++ b/crates/compiler/test_mono/generated/list_sort_asc.txt @@ -1,16 +1,16 @@ procedure List.28 (#Attr.2, #Attr.3): - let List.387 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; + let List.383 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; let #Derived_gen.0 : Int1 = lowlevel ListIsUnique #Attr.2; if #Derived_gen.0 then - ret List.387; + ret List.383; else decref #Attr.2; - ret List.387; + ret List.383; -procedure List.59 (List.213): - let List.386 : {} = Struct {}; - let List.385 : List I64 = CallByName List.28 List.213 List.386; - ret List.385; +procedure List.59 (List.209): + let List.382 : {} = Struct {}; + let List.381 : List I64 = CallByName List.28 List.209 List.382; + ret List.381; procedure Num.46 (#Attr.2, #Attr.3): let Num.257 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/monomorphized_tag.txt b/crates/compiler/test_mono/generated/monomorphized_tag.txt index 3547954b88..5e2bf5a440 100644 --- a/crates/compiler/test_mono/generated/monomorphized_tag.txt +++ b/crates/compiler/test_mono/generated/monomorphized_tag.txt @@ -1,9 +1,8 @@ procedure Test.2 (Test.4, Test.5): - let Test.8 : U8 = 18i64; - ret Test.8; + let Test.7 : U8 = 18i64; + ret Test.7; procedure Test.0 (): - let Test.7 : U8 = 0u8; let Test.1 : Int1 = false; - let Test.6 : U8 = CallByName Test.2 Test.1 Test.7; + let Test.6 : U8 = CallByName Test.2 Test.1 Test.1; ret Test.6; diff --git a/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt b/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt index 988d7238fb..fe89b5144c 100644 --- a/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt +++ b/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt @@ -1,10 +1,14 @@ -procedure Test.4 (Test.8): - let Test.10 : U64 = 1i64; - ret Test.10; +procedure Bool.1 (): + let Bool.12 : Int1 = false; + ret Bool.12; + +procedure Test.4 (Test.6): + let Test.8 : U64 = 1i64; + ret Test.8; procedure Test.0 (): - let Test.1 : Int1 = false; - let Test.2 : Int1 = false; + let Test.1 : Int1 = CallByName Bool.1; + let Test.2 : Int1 = CallByName Bool.1; let Test.3 : {Int1, Int1} = Struct {Test.1, Test.2}; - let Test.9 : U64 = CallByName Test.4 Test.3; - ret Test.9; + let Test.7 : U64 = CallByName Test.4 Test.3; + ret Test.7; diff --git a/crates/compiler/test_mono/generated/quicksort_swap.txt b/crates/compiler/test_mono/generated/quicksort_swap.txt index 475a7f21d4..71f841bdb4 100644 --- a/crates/compiler/test_mono/generated/quicksort_swap.txt +++ b/crates/compiler/test_mono/generated/quicksort_swap.txt @@ -1,43 +1,43 @@ procedure List.2 (List.90, List.91): - let List.400 : U64 = CallByName List.6 List.90; - let List.397 : Int1 = CallByName Num.22 List.91 List.400; - if List.397 then - let List.399 : I64 = CallByName List.66 List.90 List.91; - let List.398 : [C {}, C I64] = TagId(1) List.399; - ret List.398; + let List.403 : U64 = CallByName List.6 List.90; + let List.400 : Int1 = CallByName Num.22 List.91 List.403; + if List.400 then + let List.402 : I64 = CallByName List.66 List.90 List.91; + let List.401 : [C {}, C I64] = TagId(1) List.402; + ret List.401; else - let List.396 : {} = Struct {}; - let List.395 : [C {}, C I64] = TagId(0) List.396; - ret List.395; + let List.399 : {} = Struct {}; + let List.398 : [C {}, C I64] = TagId(0) List.399; + ret List.398; procedure List.3 (List.98, List.99, List.100): - let List.388 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.387 : List I64 = StructAtIndex 0 List.388; - inc List.387; - dec List.388; - ret List.387; + let List.390 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; + let List.389 : List I64 = StructAtIndex 0 List.390; + inc List.389; + dec List.390; + ret List.389; procedure List.6 (#Attr.2): - let List.406 : U64 = lowlevel ListLen #Attr.2; - ret List.406; + let List.388 : U64 = lowlevel ListLen #Attr.2; + ret List.388; procedure List.64 (List.95, List.96, List.97): - let List.405 : U64 = CallByName List.6 List.95; - let List.402 : Int1 = CallByName Num.22 List.96 List.405; - if List.402 then - let List.403 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.403; + let List.387 : U64 = CallByName List.6 List.95; + let List.384 : Int1 = CallByName Num.22 List.96 List.387; + if List.384 then + let List.385 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; + ret List.385; else - let List.401 : {List I64, I64} = Struct {List.95, List.97}; - ret List.401; + let List.383 : {List I64, I64} = Struct {List.95, List.97}; + ret List.383; procedure List.66 (#Attr.2, #Attr.3): - let List.407 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.407; + let List.396 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.396; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.404 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.404; + let List.386 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.386; procedure Num.22 (#Attr.2, #Attr.3): let Num.259 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt b/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt index 95837c3b32..1d0e02c71f 100644 --- a/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt +++ b/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt @@ -1,24 +1,28 @@ +procedure Bool.2 (): + let Bool.11 : Int1 = true; + ret Bool.11; + procedure Num.19 (#Attr.2, #Attr.3): let Num.257 : U32 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.257; procedure Test.1 (Test.2): - let Test.9 : U32 = 0i64; - let Test.8 : U32 = CallByName Test.3 Test.9 Test.2; - ret Test.8; + let Test.8 : U32 = 0i64; + let Test.7 : U32 = CallByName Test.3 Test.8 Test.2; + ret Test.7; -procedure Test.3 (Test.18, Test.19): - joinpoint Test.10 Test.4 Test.2: - let Test.14 : Int1 = true; - if Test.14 then +procedure Test.3 (Test.17, Test.18): + joinpoint Test.9 Test.4 Test.2: + let Test.13 : Int1 = CallByName Bool.2; + if Test.13 then ret Test.4; else - let Test.12 : U32 = CallByName Num.19 Test.4 Test.2; - jump Test.10 Test.12 Test.2; + let Test.11 : U32 = CallByName Num.19 Test.4 Test.2; + jump Test.9 Test.11 Test.2; in - jump Test.10 Test.18 Test.19; + jump Test.9 Test.17 Test.18; procedure Test.0 (): - let Test.7 : U32 = 6i64; - let Test.6 : U32 = CallByName Test.1 Test.7; - ret Test.6; + let Test.6 : U32 = 6i64; + let Test.5 : U32 = CallByName Test.1 Test.6; + ret Test.5; diff --git a/crates/compiler/test_mono/generated/rigids.txt b/crates/compiler/test_mono/generated/rigids.txt index 95cb00abaa..14fc57e1ba 100644 --- a/crates/compiler/test_mono/generated/rigids.txt +++ b/crates/compiler/test_mono/generated/rigids.txt @@ -1,43 +1,43 @@ procedure List.2 (List.90, List.91): - let List.400 : U64 = CallByName List.6 List.90; - let List.397 : Int1 = CallByName Num.22 List.91 List.400; - if List.397 then - let List.399 : I64 = CallByName List.66 List.90 List.91; - let List.398 : [C {}, C I64] = TagId(1) List.399; - ret List.398; + let List.403 : U64 = CallByName List.6 List.90; + let List.400 : Int1 = CallByName Num.22 List.91 List.403; + if List.400 then + let List.402 : I64 = CallByName List.66 List.90 List.91; + let List.401 : [C {}, C I64] = TagId(1) List.402; + ret List.401; else - let List.396 : {} = Struct {}; - let List.395 : [C {}, C I64] = TagId(0) List.396; - ret List.395; + let List.399 : {} = Struct {}; + let List.398 : [C {}, C I64] = TagId(0) List.399; + ret List.398; procedure List.3 (List.98, List.99, List.100): - let List.388 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.387 : List I64 = StructAtIndex 0 List.388; - inc List.387; - dec List.388; - ret List.387; + let List.390 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; + let List.389 : List I64 = StructAtIndex 0 List.390; + inc List.389; + dec List.390; + ret List.389; procedure List.6 (#Attr.2): - let List.406 : U64 = lowlevel ListLen #Attr.2; - ret List.406; + let List.388 : U64 = lowlevel ListLen #Attr.2; + ret List.388; procedure List.64 (List.95, List.96, List.97): - let List.405 : U64 = CallByName List.6 List.95; - let List.402 : Int1 = CallByName Num.22 List.96 List.405; - if List.402 then - let List.403 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.403; + let List.387 : U64 = CallByName List.6 List.95; + let List.384 : Int1 = CallByName Num.22 List.96 List.387; + if List.384 then + let List.385 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; + ret List.385; else - let List.401 : {List I64, I64} = Struct {List.95, List.97}; - ret List.401; + let List.383 : {List I64, I64} = Struct {List.95, List.97}; + ret List.383; procedure List.66 (#Attr.2, #Attr.3): - let List.407 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.407; + let List.396 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.396; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.404 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.404; + let List.386 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.386; procedure Num.22 (#Attr.2, #Attr.3): let Num.259 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/simple_if.txt b/crates/compiler/test_mono/generated/simple_if.txt index 04a1917375..0ffc888c09 100644 --- a/crates/compiler/test_mono/generated/simple_if.txt +++ b/crates/compiler/test_mono/generated/simple_if.txt @@ -1,8 +1,12 @@ +procedure Bool.2 (): + let Bool.11 : Int1 = true; + ret Bool.11; + procedure Test.0 (): - let Test.3 : Int1 = true; - if Test.3 then - let Test.4 : I64 = 1i64; - ret Test.4; + let Test.2 : Int1 = CallByName Bool.2; + if Test.2 then + let Test.3 : I64 = 1i64; + ret Test.3; else - let Test.2 : I64 = 2i64; - ret Test.2; + let Test.1 : I64 = 2i64; + ret Test.1; diff --git a/crates/compiler/test_mono/generated/specialize_closures.txt b/crates/compiler/test_mono/generated/specialize_closures.txt index 5ed689d7af..4dacbd022f 100644 --- a/crates/compiler/test_mono/generated/specialize_closures.txt +++ b/crates/compiler/test_mono/generated/specialize_closures.txt @@ -1,3 +1,7 @@ +procedure Bool.2 (): + let Bool.12 : Int1 = true; + ret Bool.12; + procedure Num.19 (#Attr.2, #Attr.3): let Num.258 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.258; @@ -7,47 +11,47 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.257; procedure Test.1 (Test.2, Test.3): - let Test.17 : U8 = GetTagId Test.2; - joinpoint Test.18 Test.16: - ret Test.16; + let Test.15 : U8 = GetTagId Test.2; + joinpoint Test.16 Test.14: + ret Test.14; in - switch Test.17: + switch Test.15: case 0: - let Test.19 : I64 = CallByName Test.7 Test.3 Test.2; - jump Test.18 Test.19; + let Test.17 : I64 = CallByName Test.7 Test.3 Test.2; + jump Test.16 Test.17; default: - let Test.20 : I64 = CallByName Test.8 Test.3 Test.2; - jump Test.18 Test.20; + let Test.18 : I64 = CallByName Test.8 Test.3 Test.2; + jump Test.16 Test.18; -procedure Test.7 (Test.10, #Attr.12): +procedure Test.7 (Test.9, #Attr.12): let Test.4 : I64 = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let Test.26 : I64 = CallByName Num.19 Test.10 Test.4; - ret Test.26; + let Test.24 : I64 = CallByName Num.19 Test.9 Test.4; + ret Test.24; -procedure Test.8 (Test.11, #Attr.12): +procedure Test.8 (Test.10, #Attr.12): let Test.6 : Int1 = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Test.5 : I64 = UnionAtIndex (Id 1) (Index 0) #Attr.12; if Test.6 then - let Test.24 : I64 = CallByName Num.21 Test.11 Test.5; - ret Test.24; + let Test.22 : I64 = CallByName Num.21 Test.10 Test.5; + ret Test.22; else - ret Test.11; + ret Test.10; procedure Test.0 (): let Test.4 : I64 = 1i64; let Test.5 : I64 = 2i64; - let Test.6 : Int1 = true; - joinpoint Test.22 Test.14: - let Test.15 : I64 = 42i64; - let Test.13 : I64 = CallByName Test.1 Test.14 Test.15; - ret Test.13; + let Test.6 : Int1 = CallByName Bool.2; + joinpoint Test.20 Test.12: + let Test.13 : I64 = 42i64; + let Test.11 : I64 = CallByName Test.1 Test.12 Test.13; + ret Test.11; in - let Test.25 : Int1 = true; - if Test.25 then + let Test.23 : Int1 = CallByName Bool.2; + if Test.23 then let Test.7 : [C I64, C I64 Int1] = TagId(0) Test.4; - jump Test.22 Test.7; + jump Test.20 Test.7; else let Test.8 : [C I64, C I64 Int1] = TagId(1) Test.5 Test.6; - jump Test.22 Test.8; + jump Test.20 Test.8; diff --git a/crates/compiler/test_mono/generated/specialize_lowlevel.txt b/crates/compiler/test_mono/generated/specialize_lowlevel.txt index c022705684..017db92ce7 100644 --- a/crates/compiler/test_mono/generated/specialize_lowlevel.txt +++ b/crates/compiler/test_mono/generated/specialize_lowlevel.txt @@ -1,3 +1,7 @@ +procedure Bool.2 (): + let Bool.11 : Int1 = true; + ret Bool.11; + procedure Num.19 (#Attr.2, #Attr.3): let Num.258 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.258; @@ -8,37 +12,37 @@ procedure Num.21 (#Attr.2, #Attr.3): procedure Test.6 (Test.8, #Attr.12): let Test.4 : I64 = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let Test.22 : I64 = CallByName Num.19 Test.8 Test.4; - ret Test.22; + let Test.21 : I64 = CallByName Num.19 Test.8 Test.4; + ret Test.21; procedure Test.7 (Test.9, #Attr.12): let Test.5 : I64 = UnionAtIndex (Id 1) (Index 0) #Attr.12; - let Test.20 : I64 = CallByName Num.21 Test.9 Test.5; - ret Test.20; + let Test.19 : I64 = CallByName Num.21 Test.9 Test.5; + ret Test.19; procedure Test.0 (): let Test.4 : I64 = 1i64; let Test.5 : I64 = 2i64; - let Test.12 : I64 = 42i64; - joinpoint Test.19 Test.13: - let Test.14 : U8 = GetTagId Test.13; - joinpoint Test.15 Test.11: - ret Test.11; + let Test.11 : I64 = 42i64; + joinpoint Test.18 Test.12: + let Test.13 : U8 = GetTagId Test.12; + joinpoint Test.14 Test.10: + ret Test.10; in - switch Test.14: + switch Test.13: case 0: - let Test.16 : I64 = CallByName Test.6 Test.12 Test.13; - jump Test.15 Test.16; + let Test.15 : I64 = CallByName Test.6 Test.11 Test.12; + jump Test.14 Test.15; default: - let Test.17 : I64 = CallByName Test.7 Test.12 Test.13; - jump Test.15 Test.17; + let Test.16 : I64 = CallByName Test.7 Test.11 Test.12; + jump Test.14 Test.16; in - let Test.21 : Int1 = true; - if Test.21 then + let Test.20 : Int1 = CallByName Bool.2; + if Test.20 then let Test.6 : [C I64, C I64] = TagId(0) Test.4; - jump Test.19 Test.6; + jump Test.18 Test.6; else let Test.7 : [C I64, C I64] = TagId(1) Test.5; - jump Test.19 Test.7; + jump Test.18 Test.7; diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index 143d39fba2..dc04e42488 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -325,7 +325,7 @@ fn guard_pattern_true() { r#" wrapper = \{} -> when 2 is - 2 if False -> 42 + 2 if Bool.false -> 42 _ -> 0 wrapper {} @@ -420,7 +420,7 @@ fn when_joinpoint() { #[mono_test] fn simple_if() { r#" - if True then + if Bool.true then 1 else 2 @@ -430,9 +430,9 @@ fn simple_if() { #[mono_test] fn if_multi_branch() { r#" - if True then + if Bool.true then 1 - else if False then + else if Bool.false then 2 else 3 @@ -730,8 +730,8 @@ fn is_nil() { isNil : ConsList a -> Bool isNil = \list -> when list is - Nil -> True - Cons _ _ -> False + Nil -> Bool.true + Cons _ _ -> Bool.false isNil (Cons 0x2 Nil) "# @@ -747,8 +747,8 @@ fn has_none() { hasNone : ConsList (Maybe a) -> Bool hasNone = \list -> when list is - Nil -> False - Cons Nothing _ -> True + Nil -> Bool.false + Cons Nothing _ -> Bool.true Cons (Just _) xs -> hasNone xs hasNone (Cons (Just 3) Nil) @@ -1024,7 +1024,7 @@ fn somehow_drops_definitions() { apply = \f, x -> f x main = - apply (if True then increment else double) 42 + apply (if Bool.true then increment else double) 42 "# ) } @@ -1047,7 +1047,7 @@ fn specialize_closures() { two = 2 b : Bool - b = True + b = Bool.true increment : I64 -> I64 increment = \x -> x + one @@ -1055,7 +1055,7 @@ fn specialize_closures() { double : I64 -> I64 double = \x -> if b then x * two else x - apply (if True then increment else double) 42 + apply (if Bool.true then increment else double) 42 "# ) } @@ -1082,7 +1082,7 @@ fn specialize_lowlevel() { double : I64 -> I64 double = \x -> x * two - (if True then increment else double) 42 + (if Bool.true then increment else double) 42 "# ) } @@ -1102,7 +1102,7 @@ fn empty_list_of_function_type() { myClosure = \_ -> "bar" choose = - if False then + if Bool.false then myList else [myClosure] @@ -1180,8 +1180,8 @@ fn monomorphized_tag() { app "test" provides [main] to "./platform" main = - b = False - f : Bool, [True, False, Idk] -> U8 + b = Bar + f : [Foo, Bar], [Bar, Baz] -> U8 f = \_, _ -> 18 f b b "# @@ -1195,8 +1195,8 @@ fn monomorphized_tag_with_aliased_args() { app "test" provides [main] to "./platform" main = - b = False - c = False + b = Bool.false + c = Bool.false a = A b c f : [A Bool Bool] -> Nat f = \_ -> 1 @@ -1286,7 +1286,7 @@ fn issue_2725_alias_polymorphic_lambda() { fn issue_2583_specialize_errors_behind_unified_branches() { indoc!( r#" - if True then List.first [] else Str.toI64 "" + if Bool.true then List.first [] else Str.toI64 "" "# ) } @@ -1716,7 +1716,7 @@ fn recursive_call_capturing_function() { a = \b -> c : U32 -> U32 c = \d -> - if True then d else c (d+b) + if Bool.true then d else c (d+b) c 0 a 6 diff --git a/crates/compiler/types/src/subs.rs b/crates/compiler/types/src/subs.rs index b3c2eeff9b..b966adbc4d 100644 --- a/crates/compiler/types/src/subs.rs +++ b/crates/compiler/types/src/subs.rs @@ -1746,7 +1746,7 @@ impl Subs { Symbol::BOOL_BOOL, AliasVariables::default(), Variable::BOOL_ENUM, - AliasKind::Structural, + AliasKind::Opaque, ) }); diff --git a/crates/repl_eval/src/eval.rs b/crates/repl_eval/src/eval.rs index f6cdd7b4be..66d04e5485 100644 --- a/crates/repl_eval/src/eval.rs +++ b/crates/repl_eval/src/eval.rs @@ -125,6 +125,9 @@ fn unroll_newtypes_and_aliases<'a, 'env>( content = env.subs.get_content_without_compacting(field.into_inner()); } Content::Alias(name, _, real_var, kind) => { + if *name == Symbol::BOOL_BOOL { + return (newtype_containers, alias_content, content); + } // We need to pass through aliases too, because their underlying types may have // unrolled newtypes. For example, // T : { a : Str } diff --git a/crates/repl_expect/src/lib.rs b/crates/repl_expect/src/lib.rs index cf581c879d..3bd3ea529e 100644 --- a/crates/repl_expect/src/lib.rs +++ b/crates/repl_expect/src/lib.rs @@ -868,7 +868,7 @@ mod test { @NonEmpty c when nonEmpty is - _ -> False + _ -> Bool.false "# ), indoc!( @@ -883,7 +883,7 @@ mod test { 13│> @NonEmpty c 14│> 15│> when nonEmpty is - 16│> _ -> False + 16│> _ -> Bool.false When it failed, these variables had these values: diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index e337ea5531..63190d6072 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -835,9 +835,9 @@ fn to_expr_report<'b>( alloc.reflow(" condition to evaluate to a "), alloc.type_str("Bool"), alloc.reflow("—either "), - alloc.tag("True".into()), + alloc.tag("Bool.true".into()), alloc.reflow(" or "), - alloc.tag("False".into()), + alloc.tag("Bool.false".into()), alloc.reflow("."), ]), // Note: Elm has a hint here about truthiness. I think that @@ -874,9 +874,9 @@ fn to_expr_report<'b>( alloc.reflow(" condition to evaluate to a "), alloc.type_str("Bool"), alloc.reflow("—either "), - alloc.tag("True".into()), + alloc.tag("Bool.true".into()), alloc.reflow(" or "), - alloc.tag("False".into()), + alloc.tag("Bool.false".into()), alloc.reflow("."), ]), // Note: Elm has a hint here about truthiness. I think that @@ -912,9 +912,9 @@ fn to_expr_report<'b>( alloc.reflow(" guard condition to evaluate to a "), alloc.type_str("Bool"), alloc.reflow("—either "), - alloc.tag("True".into()), + alloc.tag("Bool.true".into()), alloc.reflow(" or "), - alloc.tag("False".into()), + alloc.tag("Bool.false".into()), alloc.reflow("."), ]), ) @@ -1664,11 +1664,7 @@ fn format_category<'b>( alloc.concat([ alloc.text(format!("{}his ", t)), alloc.tag(name.to_owned()), - if name.as_str() == "True" || name.as_str() == "False" { - alloc.text(" boolean") - } else { - alloc.text(" tag") - }, + alloc.text(" tag"), ]), alloc.text(" has the type:"), ), @@ -2585,7 +2581,9 @@ fn to_diff<'b>( (Alias(sym, _, _, AliasKind::Opaque), _) | (_, Alias(sym, _, _, AliasKind::Opaque)) // Skip the hint for numbers; it's not as useful as saying "this type is not a number" - if !OPAQUE_NUM_SYMBOLS.contains(&sym) => + if !OPAQUE_NUM_SYMBOLS.contains(&sym) + // And same for bools + && sym != Symbol::BOOL_BOOL => { let (left, left_able) = to_doc(alloc, Parens::InFn, type1); let (right, right_able) = to_doc(alloc, Parens::InFn, type2); @@ -3982,8 +3980,8 @@ fn pattern_to_doc_help<'b>( Literal(l) => match l { Int(i) => alloc.text(i128::from_ne_bytes(i).to_string()), U128(i) => alloc.text(u128::from_ne_bytes(i).to_string()), - Bit(true) => alloc.text("True"), - Bit(false) => alloc.text("False"), + Bit(true) => alloc.text("Bool.true"), + Bit(false) => alloc.text("Bool.false"), Byte(b) => alloc.text(b.to_string()), Float(f) => alloc.text(f.to_string()), Decimal(d) => alloc.text(RocDec::from_ne_bytes(d).to_string()), diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 8509558671..321b81972a 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -603,10 +603,10 @@ mod test_reporting { Did you mean one of these? - True Str Frac Num + Err "### ); @@ -758,10 +758,10 @@ mod test_reporting { Did you mean one of these? + Ok List - True + Err Box - Str "# ), ); @@ -786,8 +786,8 @@ mod test_reporting { Str - But I need every `if` condition to evaluate to a Bool—either `True` or - `False`. + But I need every `if` condition to evaluate to a Bool—either `Bool.true` + or `Bool.false`. "### ); @@ -814,7 +814,7 @@ mod test_reporting { Num a But I need every `if` guard condition to evaluate to a Bool—either - `True` or `False`. + `Bool.true` or `Bool.false`. "### ); @@ -822,7 +822,7 @@ mod test_reporting { if_2_branch_mismatch, indoc!( r#" - if True then 2 else "foo" + if Bool.true then 2 else "foo" "# ), @r###" @@ -830,8 +830,8 @@ mod test_reporting { This `if` has an `else` branch with a different type from its `then` branch: - 4│ if True then 2 else "foo" - ^^^^^ + 4│ if Bool.true then 2 else "foo" + ^^^^^ The `else` branch is a string of type: @@ -849,7 +849,7 @@ mod test_reporting { if_3_branch_mismatch, indoc!( r#" - if True then 2 else if False then 2 else "foo" + if Bool.true then 2 else if Bool.false then 2 else "foo" "# ), @r###" @@ -857,8 +857,8 @@ mod test_reporting { The 3rd branch of this `if` does not match all the previous branches: - 4│ if True then 2 else if False then 2 else "foo" - ^^^^^ + 4│ if Bool.true then 2 else if Bool.false then 2 else "foo" + ^^^^^ The 3rd branch is a string of type: @@ -1404,7 +1404,7 @@ mod test_reporting { indoc!( r#" x : Num.Int * - x = if True then 3.14 else 4 + x = if Bool.true then 3.14 else 4 x "# @@ -1415,8 +1415,8 @@ mod test_reporting { Something is off with the `then` branch of this `if` expression: 4│ x : Num.Int * - 5│ x = if True then 3.14 else 4 - ^^^^ + 5│ x = if Bool.true then 3.14 else 4 + ^^^^ The 1st branch is a fraction of type: @@ -1960,7 +1960,7 @@ mod test_reporting { // Something is off with the body of the `f` definition: // // 1│ f : a, b -> a - // 2│ f = \x, y -> if True then x else y + // 2│ f = \x, y -> if Bool.true then x else y // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // The body is an anonymous function of type: @@ -1975,7 +1975,7 @@ mod test_reporting { indoc!( r#" f : a, b -> a - f = \x, y -> if True then x else y + f = \x, y -> if Bool.true then x else y f "# @@ -1986,8 +1986,8 @@ mod test_reporting { Something is off with the `else` branch of this `if` expression: 4│ f : a, b -> a - 5│ f = \x, y -> if True then x else y - ^ + 5│ f = \x, y -> if Bool.true then x else y + ^ This `y` value is a: @@ -2380,7 +2380,7 @@ mod test_reporting { 4│ 42 + True ^^^^ - This `True` boolean has the type: + This `True` tag has the type: [True]a @@ -5252,7 +5252,7 @@ mod test_reporting { r#" greeting = "Privet" - if True then 1 else "\(greeting), World!" + if Bool.true then 1 else "\(greeting), World!" "#, ), @r###" @@ -5260,8 +5260,8 @@ mod test_reporting { This `if` has an `else` branch with a different type from its `then` branch: - 6│ if True then 1 else "\(greeting), World!" - ^^^^^^^^^^^^^^^^^^^^^ + 6│ if Bool.true then 1 else "\(greeting), World!" + ^^^^^^^^^^^^^^^^^^^^^ The `else` branch is a string of type: @@ -5280,14 +5280,14 @@ mod test_reporting { $( test_report!( $name, - &format!(r#"if True then "abc" else 1 {} 2"#, $op), + &format!(r#"if Bool.true then "abc" else 1 {} 2"#, $op), |golden| assert_eq!(golden, format!( r#"── TYPE MISMATCH ───────────────────────────────────────── /code/proj/Main.roc ─ This `if` has an `else` branch with a different type from its `then` branch: -4│ if True then "abc" else 1 {} 2 - ^^{}^^ +4│ if Bool.true then "abc" else 1 {} 2 + ^^{}^^ This comparison produces: @@ -5829,7 +5829,7 @@ All branches in an `if` must have the same type! apply_unary_not, indoc!( r#" - foo = True + foo = Bool.true !foo 1 2 "# @@ -6063,8 +6063,8 @@ All branches in an `if` must have the same type! Str - But I need every `expect` condition to evaluate to a Bool—either `True` - or `False`. + But I need every `expect` condition to evaluate to a Bool—either + `Bool.true` or `Bool.false`. "### ); @@ -7616,7 +7616,7 @@ All branches in an `if` must have the same type! r#" F n := n - if True + if Bool.true then @F "" else @F {} "# @@ -7856,7 +7856,7 @@ All branches in an `if` must have the same type! r#" x : [A] when x is - A if True -> "" + A if Bool.true -> "" "# ), @r###" @@ -7865,7 +7865,7 @@ All branches in an `if` must have the same type! This `when` does not cover all the possibilities: 5│> when x is - 6│> A if True -> "" + 6│> A if Bool.true -> "" Other possibilities include: @@ -8563,27 +8563,27 @@ All branches in an `if` must have the same type! eq = \@You {}, @AndI {} -> False "# ), - @r#" - ── TYPE MISMATCH ───────────────────────────────────────── /code/proj/Main.roc ─ + @r###" + ── TYPE MISMATCH ───────────────────────────────────────── /code/proj/Main.roc ─ - Something is off with this specialization of `eq`: + Something is off with this specialization of `eq`: - 9│ eq = \@You {}, @AndI {} -> False - ^^ + 9│ eq = \@You {}, @AndI {} -> False + ^^ - This value is a declared specialization of type: + This value is a declared specialization of type: - You, AndI -> [False, True] + You, AndI -> [False]a - But the type annotation on `eq` says it must match: + But the type annotation on `eq` says it must match: - You, You -> Bool + You, You -> Bool - Tip: Type comparisons between an opaque type are only ever equal if - both types are the same opaque type. Did you mean to create an opaque - type by wrapping it? If I have an opaque type Age := U32 I can create - an instance of this opaque type by doing @Age 23. - "# + Tip: Type comparisons between an opaque type are only ever equal if + both types are the same opaque type. Did you mean to create an opaque + type by wrapping it? If I have an opaque type Age := U32 I can create + an instance of this opaque type by doing @Age 23. + "### ); test_report!( @@ -9643,27 +9643,27 @@ All branches in an `if` must have the same type! indoc!( r#" f : _ -> (_ -> Str) - f = \_ -> if True then {} else f {} + f = \_ -> if Bool.true then {} else f {} f "# ), @r###" - ── TYPE MISMATCH ───────────────────────────────────────── /code/proj/Main.roc ─ + ── TYPE MISMATCH ───────────────────────────────────────── /code/proj/Main.roc ─ - This expression is used in an unexpected way: + This expression is used in an unexpected way: - 5│ f = \_ -> if True then {} else f {} - ^^^^^^^^^^^^^^^^^^^^^^^^^ + 5│ f = \_ -> if Bool.true then {} else f {} + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - It is a value of type: + It is a value of type: - {} + {} - But you are trying to use it as: + But you are trying to use it as: - a -> Str - "### + a -> Str + "### ); test_report!( @@ -10425,7 +10425,7 @@ All branches in an `if` must have the same type! indoc!( r#" f : {a: Str, b ? Str} - f = if True then {a: ""} else {a: "b", b: ""} + f = if Bool.true then {a: ""} else {a: "b", b: ""} f "# ), @@ -10435,8 +10435,8 @@ All branches in an `if` must have the same type! Something is off with the `then` branch of this `if` expression: 4│ f : {a: Str, b ? Str} - 5│ f = if True then {a: ""} else {a: "b", b: ""} - ^^^^^^^ + 5│ f = if Bool.true then {a: ""} else {a: "b", b: ""} + ^^^^^^^ The 1st branch is a record of type: diff --git a/examples/benchmarks/Base64/Encode.roc b/examples/benchmarks/Base64/Encode.roc index afeff2d379..e6135da170 100644 --- a/examples/benchmarks/Base64/Encode.roc +++ b/examples/benchmarks/Base64/Encode.roc @@ -131,19 +131,19 @@ encodeCharacters = \a, b, c, d -> isValidChar : U8 -> Bool isValidChar = \c -> if isAlphaNum c then - True + Bool.true else when c is 43 -> # '+' - True + Bool.true 47 -> # '/' - True + Bool.true _ -> - False + Bool.false isAlphaNum : U8 -> Bool isAlphaNum = \key -> diff --git a/examples/benchmarks/Issue2279.roc b/examples/benchmarks/Issue2279.roc index 647ed7507b..c6d8be7523 100644 --- a/examples/benchmarks/Issue2279.roc +++ b/examples/benchmarks/Issue2279.roc @@ -5,7 +5,7 @@ app "issue2279" main = text = - if True then + if Bool.true then Issue2279Help.text else Issue2279Help.asText 42 diff --git a/examples/benchmarks/NQueens.roc b/examples/benchmarks/NQueens.roc index 6d99f46ae5..4ff4b5201f 100644 --- a/examples/benchmarks/NQueens.roc +++ b/examples/benchmarks/NQueens.roc @@ -28,7 +28,7 @@ lengthHelp = \foobar, acc -> safe : I64, I64, ConsList I64 -> Bool safe = \queen, diagonal, xs -> when xs is - Nil -> True + Nil -> Bool.true Cons q t -> queen != q && queen != q + diagonal && queen != q - diagonal && safe queen (diagonal + 1) t diff --git a/examples/benchmarks/RBTreeCk.roc b/examples/benchmarks/RBTreeCk.roc index de698f0133..89ac43d871 100644 --- a/examples/benchmarks/RBTreeCk.roc +++ b/examples/benchmarks/RBTreeCk.roc @@ -70,8 +70,8 @@ setBlack = \tree -> isRed : Tree a b -> Bool isRed = \tree -> when tree is - Node Red _ _ _ _ -> True - _ -> False + Node Red _ _ _ _ -> Bool.true + _ -> Bool.false lt = \x, y -> x < y diff --git a/examples/benchmarks/RBTreeDel.roc b/examples/benchmarks/RBTreeDel.roc index f138dabe35..5903d09b14 100644 --- a/examples/benchmarks/RBTreeDel.roc +++ b/examples/benchmarks/RBTreeDel.roc @@ -74,8 +74,8 @@ setBlack = \tree -> isRed : Tree a b -> Bool isRed = \tree -> when tree is - Node Red _ _ _ _ -> True - _ -> False + Node Red _ _ _ _ -> Bool.true + _ -> Bool.false ins : Tree I64 Bool, I64, Bool -> Tree I64 Bool ins = \tree, kx, vx -> @@ -93,13 +93,13 @@ ins = \tree, kx, vx -> when Num.compare kx ky is LT -> when isRed a is - True -> balanceLeft (ins a kx vx) ky vy b - False -> Node Black (ins a kx vx) ky vy b + Bool.true -> balanceLeft (ins a kx vx) ky vy b + Bool.false -> Node Black (ins a kx vx) ky vy b GT -> when isRed b is - True -> balanceRight a ky vy (ins b kx vx) - False -> Node Black a ky vy (ins b kx vx) + Bool.true -> balanceRight a ky vy (ins b kx vx) + Bool.false -> Node Black a ky vy (ins b kx vx) EQ -> Node Black a kx vx b @@ -137,8 +137,8 @@ balanceRight = \l, k, v, r -> isBlack : Color -> Bool isBlack = \c -> when c is - Black -> True - Red -> False + Black -> Bool.true + Red -> Bool.false Del a b : [Del (Tree a b) Bool] @@ -155,10 +155,10 @@ makeBlack : Map -> Del I64 Bool makeBlack = \t -> when t is Node Red l k v r -> - Del (Node Black l k v r) False + Del (Node Black l k v r) Bool.false _ -> - Del t True + Del t Bool.true rebalanceLeft = \c, l, k, v, r -> when l is @@ -166,7 +166,7 @@ rebalanceLeft = \c, l, k, v, r -> Del (balanceLeft (setRed l) k v r) (isBlack c) Node Red lx kx vx rx -> - Del (Node Black lx kx vx (balanceLeft (setRed rx) k v r)) False + Del (Node Black lx kx vx (balanceLeft (setRed rx) k v r)) Bool.false _ -> boom "unreachable" @@ -177,7 +177,7 @@ rebalanceRight = \c, l, k, v, r -> Del (balanceRight l k v (setRed r)) (isBlack c) Node Red lx kx vx rx -> - Del (Node Black (balanceRight l k v (setRed lx)) kx vx rx) False + Del (Node Black (balanceRight l k v (setRed lx)) kx vx rx) Bool.false _ -> boom "unreachable" @@ -187,24 +187,24 @@ delMin = \t -> Node Black Leaf k v r -> when r is Leaf -> - Delmin (Del Leaf True) k v + Delmin (Del Leaf Bool.true) k v _ -> - Delmin (Del (setBlack r) False) k v + Delmin (Del (setBlack r) Bool.false) k v Node Red Leaf k v r -> - Delmin (Del r False) k v + Delmin (Del r Bool.false) k v Node c l k v r -> when delMin l is - Delmin (Del lx True) kx vx -> + Delmin (Del lx Bool.true) kx vx -> Delmin (rebalanceRight c lx k v r) kx vx - Delmin (Del lx False) kx vx -> - Delmin (Del (Node c lx k v r) False) kx vx + Delmin (Del lx Bool.false) kx vx -> + Delmin (Del (Node c lx k v r) Bool.false) kx vx Leaf -> - Delmin (Del t False) 0 False + Delmin (Del t Bool.false) 0 Bool.false delete : Tree I64 Bool, I64 -> Tree I64 Bool delete = \t, k -> @@ -216,32 +216,32 @@ del : Tree I64 Bool, I64 -> Del I64 Bool del = \t, k -> when t is Leaf -> - Del Leaf False + Del Leaf Bool.false Node cx lx kx vx rx -> if (k < kx) then when del lx k is - Del ly True -> + Del ly Bool.true -> rebalanceRight cx ly kx vx rx - Del ly False -> - Del (Node cx ly kx vx rx) False + Del ly Bool.false -> + Del (Node cx ly kx vx rx) Bool.false else if (k > kx) then when del rx k is - Del ry True -> + Del ry Bool.true -> rebalanceLeft cx lx kx vx ry - Del ry False -> - Del (Node cx lx kx vx ry) False + Del ry Bool.false -> + Del (Node cx lx kx vx ry) Bool.false else when rx is Leaf -> - if isBlack cx then makeBlack lx else Del lx False + if isBlack cx then makeBlack lx else Del lx Bool.false Node _ _ _ _ _ -> when delMin rx is - Delmin (Del ry True) ky vy -> + Delmin (Del ry Bool.true) ky vy -> rebalanceLeft cx lx ky vy ry - Delmin (Del ry False) ky vy -> - Del (Node cx lx ky vy ry) False + Delmin (Del ry Bool.false) ky vy -> + Del (Node cx lx ky vy ry) Bool.false diff --git a/examples/benchmarks/TestAStar.roc b/examples/benchmarks/TestAStar.roc index 8b1f35c233..cd4eaf846d 100644 --- a/examples/benchmarks/TestAStar.roc +++ b/examples/benchmarks/TestAStar.roc @@ -17,9 +17,12 @@ main = # Task.putLine "No test \(ns)" showBool : Bool -> Str showBool = \b -> - when b is - True -> "True" - False -> "False" + if + b + then + "True" + else + "False" test1 : Bool test1 = diff --git a/examples/benchmarks/platform/Task.roc b/examples/benchmarks/platform/Task.roc index 0502ec4633..fb3232092b 100644 --- a/examples/benchmarks/platform/Task.roc +++ b/examples/benchmarks/platform/Task.roc @@ -66,13 +66,13 @@ getInt = Effect.after Effect.getInt \{ isError, value } -> - when isError is - True -> - # when errorCode is - # # A -> Task.fail InvalidCharacter - # # B -> Task.fail IOError - # _ -> - Task.succeed -1 - - False -> - Task.succeed value + if + isError + then + # when errorCode is + # # A -> Task.fail InvalidCharacter + # # B -> Task.fail IOError + # _ -> + Task.succeed -1 + else + Task.succeed value diff --git a/examples/false-interpreter/Context.roc b/examples/false-interpreter/Context.roc index 3b8626c93a..6849d5fe04 100644 --- a/examples/false-interpreter/Context.roc +++ b/examples/false-interpreter/Context.roc @@ -104,4 +104,4 @@ inWhileScope = \ctx -> scope.whileInfo != None Err ListWasEmpty -> - False + Bool.false diff --git a/examples/interactive/cli-platform/Arg.roc b/examples/interactive/cli-platform/Arg.roc index b0fbe0a01d..1a168f5590 100644 --- a/examples/interactive/cli-platform/Arg.roc +++ b/examples/interactive/cli-platform/Arg.roc @@ -127,7 +127,7 @@ findOneArg : Str, Str, List Str -> Result Str [NotFound]* findOneArg = \long, short, args -> argMatches = \arg -> if arg == "--\(long)" then - True + Bool.true else Bool.not (Str.isEmpty short) && arg == "-\(short)" @@ -314,15 +314,15 @@ parseHelp = \@Parser parser, args -> parseHelp parser2 args ## Creates a parser for a boolean flag argument. -## Flags of value "true" and "false" will be parsed as [True] and [False], respectively. +## Flags of value "true" and "false" will be parsed as [Bool.true] and [Bool.false], respectively. ## All other values will result in a `WrongType` error. bool : _ -> Parser Bool # TODO: panics if parameter annotation given bool = \{ long, short ? "", help ? "" } -> fn = \args -> when findOneArg long short args is Err NotFound -> Err NotFound - Ok "true" -> Ok True - Ok "false" -> Ok False + Ok "true" -> Ok Bool.true + Ok "false" -> Ok Bool.false Ok _ -> Err WrongType @Parser (Arg { long, short, help, type: Bool } fn) @@ -523,13 +523,13 @@ expect expect parser = bool { long: "foo" } - parseHelp parser ["--foo", "true"] == Ok True + parseHelp parser ["--foo", "true"] == Ok Bool.true # bool dashed long argument with value is determined false expect parser = bool { long: "foo" } - parseHelp parser ["--foo", "false"] == Ok False + parseHelp parser ["--foo", "false"] == Ok Bool.false # bool dashed long argument with value is determined wrong type expect @@ -541,13 +541,13 @@ expect expect parser = bool { long: "foo", short: "F" } - parseHelp parser ["-F", "true"] == Ok True + parseHelp parser ["-F", "true"] == Ok Bool.true # bool dashed short argument with value is determined false expect parser = bool { long: "foo", short: "F" } - parseHelp parser ["-F", "false"] == Ok False + parseHelp parser ["-F", "false"] == Ok Bool.false # bool dashed short argument with value is determined wrong type expect @@ -644,7 +644,7 @@ expect parser = bool { long: "foo" } when parseHelp parser ["foo"] is - Ok _ -> False + Ok _ -> Bool.false Err e -> err = formatError e @@ -655,7 +655,7 @@ expect parser = bool { long: "foo" } when parseHelp parser ["--foo", "12"] is - Ok _ -> False + Ok _ -> Bool.false Err e -> err = formatError e @@ -747,7 +747,7 @@ expect when parse parser ["test", "login", "--pw", "123", "--user", "abc"] is Ok result -> result == "logging in abc with 123" - Err _ -> False + Err _ -> Bool.false # subcommand of subcommand parser expect @@ -765,7 +765,7 @@ expect when parse parser ["test", "auth", "login", "--pw", "123", "--user", "abc"] is Ok result -> result == "logging in abc with 123" - Err _ -> False + Err _ -> Bool.false # subcommand not provided expect @@ -773,7 +773,7 @@ expect choice [subCommand (succeed "") "auth", subCommand (succeed "") "publish"] when parseHelp parser [] is - Ok _ -> True + Ok _ -> Bool.true Err e -> err = formatError e @@ -791,7 +791,7 @@ expect choice [subCommand (succeed "") "auth", subCommand (succeed "") "publish"] when parseHelp parser ["logs"] is - Ok _ -> True + Ok _ -> Bool.true Err e -> err = formatError e diff --git a/examples/interactive/cli-platform/Path.roc b/examples/interactive/cli-platform/Path.roc index 7a9453df5e..e04ca42641 100644 --- a/examples/interactive/cli-platform/Path.roc +++ b/examples/interactive/cli-platform/Path.roc @@ -16,7 +16,7 @@ interface Path ## You can canonicalize a [Path] using [Path.canonicalize]. ## ## Comparing canonical paths is often more reliable than comparing raw ones. -## For example, `Path.fromStr "foo/bar/../baz" == Path.fromStr "foo/baz"` will return `False`, +## For example, `Path.fromStr "foo/bar/../baz" == Path.fromStr "foo/baz"` will return `Bool.false`, ## because those are different paths even though their canonical equivalents would be equal. ## ## Also note that canonicalization reads from the file system (in order to resolve symbolic @@ -233,7 +233,7 @@ WindowsRoot : [] # Str.concat prefixStr suffixStr # |> FromStr # InternalPath.wrap content -## Returns `True` if the first path begins with the second. +## Returns `Bool.true` if the first path begins with the second. # startsWith : Path, Path -> Bool # startsWith = \path, prefix -> # when InternalPath.unwrap path is @@ -249,14 +249,14 @@ WindowsRoot : [] # # Compare the two for equality. # Str.isEqUtf8 prefixStr bytesPrefix # else -# False +# Bool.false # FromStr pathStr -> # when InternalPath.unwrap prefix is # FromOperatingSystem prefixBytes | ArbitraryBytes prefixBytes -> # Str.startsWithUtf8 pathStr prefixBytes # FromStr prefixStr -> # Str.startsWith pathStr prefixStr -## Returns `True` if the first path ends with the second. +## Returns `Bool.true` if the first path ends with the second. # endsWith : Path, Path -> Bool # endsWith = \path, prefix -> # when InternalPath.unwrap path is @@ -272,7 +272,7 @@ WindowsRoot : [] # # Compare the two for equality. # Str.startsWithUtf8 suffixStr bytesSuffix # else -# False +# Bool.false # FromStr pathStr -> # when InternalPath.unwrap suffix is # FromOperatingSystem suffixBytes | ArbitraryBytes suffixBytes -> diff --git a/examples/interactive/cli-platform/Url.roc b/examples/interactive/cli-platform/Url.roc index b5b0ef7bbf..7aea2602f1 100644 --- a/examples/interactive/cli-platform/Url.roc +++ b/examples/interactive/cli-platform/Url.roc @@ -152,7 +152,7 @@ appendHelp = \prefix, suffix -> Err NotFound -> # This should never happen, because we already verified # that the suffix startsWith "/" - # TODO `expect False` here with a comment + # TODO `expect Bool.false` here with a comment Str.concat prefix suffix else # prefix ends with "/" but suffix doesn't start with one, so just append. @@ -334,15 +334,15 @@ query = \@Url urlStr -> Ok { after } -> after Err NotFound -> "" -## Returns `True` if the URL has a `?` in it. +## Returns `Bool.true` if the URL has a `?` in it. ## ## Url.fromStr "https://example.com?key=value#stuff" ## |> Url.hasQuery -## # True +## # Bool.true ## ## Url.fromStr "https://example.com#stuff" ## |> Url.hasQuery -## # False +## # Bool.false hasQuery : Url -> Bool hasQuery = \@Url urlStr -> # TODO use Str.contains once it exists. It should have a "fast path" @@ -404,15 +404,15 @@ withFragment = \@Url urlStr, fragmentStr -> # The URL didn't have a fragment, so give it this one @Url "\(urlStr)#\(fragmentStr)" -## Returns `True` if the URL has a `#` in it. +## Returns `Bool.true` if the URL has a `#` in it. ## ## Url.fromStr "https://example.com?key=value#stuff" ## |> Url.hasFragment -## # True +## # Bool.true ## ## Url.fromStr "https://example.com?key=value" ## |> Url.hasFragment -## # False +## # Bool.false hasFragment : Url -> Bool hasFragment = \@Url urlStr -> # TODO use Str.contains once it exists. It should have a "fast path"