diff --git a/src/build/roc/Builtin.roc b/src/build/roc/Builtin.roc index a041b4ed32..e77e1f7e78 100644 --- a/src/build/roc/Builtin.roc +++ b/src/build/roc/Builtin.roc @@ -331,15 +331,15 @@ Builtin :: [].{ from_numeral : Numeral -> Try(U8, [InvalidNumeral(Str), ..others]) from_str : Str -> Try(U8, [BadNumStr, ..others]) - ## List of integers beginning with this `U8` and ending with the other `U8`. - ## (Use [until] instead to end with the other `U8` minus one.) - ## Returns an empty list if this `U8` is greater than the other. + # # List of integers beginning with this `U8` and ending with the other `U8`. + # # (Use [until] instead to end with the other `U8` minus one.) + # # Returns an empty list if this `U8` is greater than the other. to : U8, U8 -> List(U8) to = |start, end| range_to(start, end) - ## List of integers beginning with this `U8` and ending with the other `U8` minus one. - ## (Use [to] instead to end with the other `U8` exactly, instead of minus one.) - ## Returns an empty list if this `U8` is greater than or equal to the other. + # # List of integers beginning with this `U8` and ending with the other `U8` minus one. + # # (Use [to] instead to end with the other `U8` exactly, instead of minus one.) + # # Returns an empty list if this `U8` is greater than or equal to the other. until : U8, U8 -> List(U8) until = |start, end| range_until(start, end) @@ -990,25 +990,25 @@ Builtin :: [].{ } range_to = |var $current, end| { - var $answer = [] # Not bothering with List.with_capacity because this will become an iterator once those exist. + var $answer = [] # Not bothering with List.with_capacity because this will become an iterator once those exist. - while $current <= end { - $answer = $answer.append($current) - $current = $current + 1 - } + while $current <= end { + $answer = $answer.append($current) + $current = $current + 1 + } - $answer + $answer } range_until = |var $current, end| { - var $answer = [] # Not bothering with List.with_capacity because this will become an iterator once those exist. + var $answer = [] # Not bothering with List.with_capacity because this will become an iterator once those exist. - while $current < end { - $answer = $answer.append($current) - $current = $current + 1 - } + while $current < end { + $answer = $answer.append($current) + $current = $current + 1 + } - $answer + $answer } # Implemented by the compiler, does not perform bounds checks diff --git a/src/eval/interpreter.zig b/src/eval/interpreter.zig index fc250d1fa2..0abc93cf29 100644 --- a/src/eval/interpreter.zig +++ b/src/eval/interpreter.zig @@ -1481,13 +1481,15 @@ pub const Interpreter = struct { // Get the result layout - should be List(U8). // If return_rt_var is a flex that would default to a scalar, // we need to ensure we get a proper list layout for correct refcounting. + const result_rt_var = return_rt_var orelse { + self.triggerCrash("str_to_utf8 requires return type info", false, roc_ops); + return error.Crash; + }; const result_layout = blk: { - if (return_rt_var) |rt_var| { - const maybe_layout = try self.getRuntimeLayout(rt_var); - // If the layout is a list, use it - if (maybe_layout.tag == .list or maybe_layout.tag == .list_of_zst) { - break :blk maybe_layout; - } + const maybe_layout = try self.getRuntimeLayout(result_rt_var); + // If the layout is a list, use it + if (maybe_layout.tag == .list or maybe_layout.tag == .list_of_zst) { + break :blk maybe_layout; } // Fallback: create a proper List(U8) layout const u8_layout_idx = try self.runtime_layout_store.insertLayout(Layout.int(.u8));