Merge attempt

This commit is contained in:
Sam Mohr 2024-08-19 23:34:05 -07:00
parent 7c15c16ae0
commit 12df3a04de
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
236 changed files with 9053 additions and 6428 deletions

View file

@ -104,10 +104,10 @@ jobs:
if: needs.check-changes.outputs.run_tests == 'full'
uses: ./.github/workflows/ubuntu_x86_64.yml
start-ubuntu-x86-64-tests-debug:
start-ubuntu-x86-64-nix-tests-debug:
needs: check-changes
if: needs.check-changes.outputs.run_tests == 'full'
uses: ./.github/workflows/ubuntu_x86_64_debug.yml
uses: ./.github/workflows/ubuntu_x86_64_nix_debug.yml
start-windows-release-build-test:
needs: check-changes
@ -133,7 +133,7 @@ jobs:
start-nix-macos-apple-silicon-tests,
start-macos-x86-64-tests,
start-ubuntu-x86-64-tests,
start-ubuntu-x86-64-tests-debug,
start-ubuntu-x86-64-nix-tests-debug,
start-windows-release-build-test,
start-windows-tests,
start-roc-benchmarks

View file

@ -1,42 +0,0 @@
on:
workflow_call:
name: cargo test debug
env:
RUST_BACKTRACE: 1
jobs:
cargo-test-debug:
name: cargo test debug
runs-on: [ubuntu-22.04]
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- run: zig version
- name: Install dependencies
run: |
sudo apt -y install build-essential libunwind-dev pkg-config zlib1g-dev valgrind
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16
sudo rm /usr/bin/clang
sudo ln -s /usr/bin/clang-16 /usr/bin/clang
sudo ln -s /usr/bin/lld-16 /usr/bin/ld.lld
sudo apt -y install libpolly-16-dev
- name: Check if debug flag files are in sync
run: ./ci/check_debug_vars.sh
# for skipped tests; see #6946, #6947
- name: cargo test without --release
env:
RUSTFLAGS: -C link-arg=-fuse-ld=lld
ROC_CHECK_MONO_IR: 1
run: cargo test -- --skip tests/exhaustive/match_on_result_with_uninhabited_error_destructuring_in_lambda_syntax.txt --skip tests::identity_lambda --skip tests::issue_2300 --skip tests::issue_2582_specialize_result_value --skip tests::sum_lambda

View file

@ -0,0 +1,27 @@
on:
workflow_call:
name: cargo test debug nix
env:
RUST_BACKTRACE: 1
jobs:
cargo-test-debug-nix:
name: cargo test debug nix
runs-on: [ubuntu-22.04]
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
# install nix
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Check if debug flag files are in sync
run: ./ci/check_debug_vars.sh
# for skipped tests; see #6946, #6947
- name: cargo test without --release
run: nix develop -c sh -c 'export ROC_CHECK_MONO_IR=1 && cargo test -- --skip tests/exhaustive/match_on_result_with_uninhabited_error_destructuring_in_lambda_syntax.txt --skip tests::identity_lambda --skip tests::issue_2300 --skip tests::issue_2582_specialize_result_value --skip tests::sum_lambda'

69
Cargo.lock generated
View file

@ -723,17 +723,6 @@ dependencies = [
"powerfmt",
]
[[package]]
name = "derive_more"
version = "0.99.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "diff"
version = "0.1.13"
@ -784,12 +773,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d9d8664cf849d7d0f3114a3a387d2f5e4303176d746d5a951aaddc66dfe9240"
[[package]]
name = "doc-comment"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "dunce"
version = "1.0.4"
@ -1700,11 +1683,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [
"crc32fast",
"flate2",
"hashbrown",
"indexmap",
"memchr",
"ruzstd",
]
[[package]]
@ -2516,7 +2497,6 @@ dependencies = [
"roc_solve",
"roc_target",
"roc_types",
"snafu",
"ven_pretty",
]
@ -2536,9 +2516,6 @@ version = "0.0.1"
[[package]]
name = "roc_error_utils"
version = "0.0.1"
dependencies = [
"snafu",
]
[[package]]
name = "roc_exhaustive"
@ -2629,7 +2606,6 @@ dependencies = [
name = "roc_glue"
version = "0.0.1"
dependencies = [
"backtrace",
"bumpalo",
"cli_utils",
"dircpy",
@ -2824,7 +2800,6 @@ dependencies = [
"roc_error_macros",
"roc_ident",
"roc_region",
"snafu",
"static_assertions",
]
@ -3356,17 +3331,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "ruzstd"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d"
dependencies = [
"byteorder",
"derive_more",
"twox-hash",
]
[[package]]
name = "ryu"
version = "1.0.15"
@ -3599,29 +3563,6 @@ version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
[[package]]
name = "snafu"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6"
dependencies = [
"backtrace",
"doc-comment",
"snafu-derive",
]
[[package]]
name = "snafu-derive"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "socket2"
version = "0.4.9"
@ -4227,16 +4168,6 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "twox-hash"
version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if",
"static_assertions",
]
[[package]]
name = "typed-arena"
version = "2.0.2"

View file

@ -137,7 +137,7 @@ maplit = "1.0.2"
memmap2 = "0.5.10"
mimalloc = { version = "0.1.34", default-features = false }
nonempty = "0.8.1"
object = { version = "0.32.2", features = ["read", "write"] }
object = { version = "0.32.2", default-features = false, features = ["read", "write"] }
packed_struct = "0.10.1"
page_size = "0.5.0"
palette = "0.6.1"
@ -171,7 +171,6 @@ serde_json = "1.0.94" # update roc_std/Cargo.toml on change
serial_test = "1.0.0"
signal-hook = "0.3.15"
smallvec = { version = "1.10.0", features = ["const_generics", "const_new"] }
snafu = { version = "0.7.4", features = ["backtraces"] }
static_assertions = "1.1.0" # update roc_std/Cargo.toml on change
strip-ansi-escapes = "0.1.1"
strum = { version = "0.24.1", features = ["derive"] }

View file

@ -17,10 +17,6 @@ if [ -n "$(ls | grep -v "roc_nightly.*tar\.gz" | grep -v "^ci$")" ]; then
done
fi
if [[ "$(uname)" == "Darwin" ]]; then
brew install z3 # used by llvm
fi
# decompress the tar
ls | grep "roc_nightly.*tar\.gz" | xargs tar -xzvf

View file

@ -9,7 +9,7 @@ use roc_fmt::header::fmt_header;
use roc_fmt::Buf;
use roc_parse::ast::{FullAst, SpacesBefore};
use roc_parse::header::parse_module_defs;
use roc_parse::remove_spaces::RemoveSpaces;
use roc_parse::normalize::Normalize;
use roc_parse::{header, parser::SyntaxError, state::State};
#[derive(Copy, Clone, Debug)]
@ -200,8 +200,8 @@ pub fn format_src(arena: &Bump, src: &str) -> Result<String, FormatProblem> {
}
};
let ast_normalized = ast.remove_spaces(arena);
let reparsed_ast_normalized = reparsed_ast.remove_spaces(arena);
let ast_normalized = ast.normalize(arena);
let reparsed_ast_normalized = reparsed_ast.normalize(arena);
// HACK!
// We compare the debug format strings of the ASTs, because I'm finding in practice that _somewhere_ deep inside the ast,

View file

@ -92,9 +92,8 @@ astar = \costFn, moveFn, goal, model ->
modelWithNeighbors : Model position
modelWithNeighbors =
{ modelPopped &
openSet: Set.union modelPopped.openSet newNeighbors,
}
modelPopped
|> &openSet (Set.union modelPopped.openSet newNeighbors)
walker : Model position, position -> Model position
walker = \amodel, n -> updateCost current n amodel

View file

@ -12,40 +12,39 @@ decodeBase64 = \width -> Bytes.Decode.loop loopHelp { remaining: width, string:
loopHelp : { remaining : U64, string : Str } -> ByteDecoder (Bytes.Decode.Step { remaining : U64, string : Str } Str)
loopHelp = \{ remaining, string } ->
if remaining >= 3 then
x, y, z <- Bytes.Decode.map3 Bytes.Decode.u8 Bytes.Decode.u8 Bytes.Decode.u8
Bytes.Decode.map3 Bytes.Decode.u8 Bytes.Decode.u8 Bytes.Decode.u8 \x, y, z ->
a : U32
a = Num.intCast x
b : U32
b = Num.intCast y
c : U32
c = Num.intCast z
combined = Num.bitwiseOr (Num.bitwiseOr (Num.shiftLeftBy a 16) (Num.shiftLeftBy b 8)) c
a : U32
a = Num.intCast x
b : U32
b = Num.intCast y
c : U32
c = Num.intCast z
combined = Num.bitwiseOr (Num.bitwiseOr (Num.shiftLeftBy a 16) (Num.shiftLeftBy b 8)) c
Loop {
remaining: remaining - 3,
string: Str.concat string (bitsToChars combined 0),
}
Loop {
remaining: remaining - 3,
string: Str.concat string (bitsToChars combined 0),
}
else if remaining == 0 then
Bytes.Decode.succeed (Done string)
else if remaining == 2 then
x, y <- Bytes.Decode.map2 Bytes.Decode.u8 Bytes.Decode.u8
Bytes.Decode.map2 Bytes.Decode.u8 Bytes.Decode.u8 \x, y ->
a : U32
a = Num.intCast x
b : U32
b = Num.intCast y
combined = Num.bitwiseOr (Num.shiftLeftBy a 16) (Num.shiftLeftBy b 8)
a : U32
a = Num.intCast x
b : U32
b = Num.intCast y
combined = Num.bitwiseOr (Num.shiftLeftBy a 16) (Num.shiftLeftBy b 8)
Done (Str.concat string (bitsToChars combined 1))
Done (Str.concat string (bitsToChars combined 1))
else
# remaining = 1
x <- Bytes.Decode.map Bytes.Decode.u8
Bytes.Decode.map Bytes.Decode.u8 \x ->
a : U32
a = Num.intCast x
a : U32
a = Num.intCast x
Done (Str.concat string (bitsToChars (Num.shiftLeftBy a 16) 2))
Done (Str.concat string (bitsToChars (Num.shiftLeftBy a 16) 2))
bitsToChars : U32, Int * -> Str
bitsToChars = \bits, missing ->

View file

@ -5,7 +5,12 @@ import Quicksort
main : Task.Task {} []
main =
inputResult = PlatformTask.getInt!
{ value, isError } = PlatformTask.getInt!
inputResult =
if isError then
Err GetIntError
else
Ok value
when inputResult is
Ok n ->

View file

@ -12,7 +12,12 @@ ConsList a : [Nil, Cons a (ConsList a)]
main : Task {} []
main =
inputResult = PlatformTask.getInt!
{ value, isError } = PlatformTask.getInt!
inputResult =
if isError then
Err GetIntError
else
Ok value
when inputResult is
Ok n ->

View file

@ -4,15 +4,15 @@ import pf.Stdin
import pf.Stdout
main =
_ <- Task.await (Stdout.line "\nLet's count down from 3 together - all you have to do is press <ENTER>.")
_ <- Task.await Stdin.line
Stdout.line! "\nLet's count down from 3 together - all you have to do is press <ENTER>."
_ = Stdin.line!
Task.loop 3 tick
tick = \n ->
if n == 0 then
_ <- Task.await (Stdout.line "🎉 SURPRISE! Happy Birthday! 🎂")
Stdout.line! "🎉 SURPRISE! Happy Birthday! 🎂"
Task.ok (Done {})
else
_ <- Task.await (n |> Num.toStr |> \s -> "$(s)..." |> Stdout.line)
_ <- Task.await Stdin.line
Stdout.line! (n |> Num.toStr |> \s -> "$(s)...")
_ = Stdin.line!
Task.ok (Step (n - 1))

View file

@ -4,7 +4,7 @@ import pf.Stdin
import pf.Stdout
main =
_ <- Task.await (Stdout.line "🗣 Shout into this cave and hear the echo! 👂👂👂")
Stdout.line! "🗣 Shout into this cave and hear the echo! 👂👂👂"
Task.loop {} tick

View file

@ -12,7 +12,7 @@ main =
file,
count: numParam { name: "count" },
doubled: numParam { name: "doubled" }
|> cliMap \d -> d * 2,
|> cliMap \d -> d * 2,
}
args = ["parse-args", "file.txt", "5", "7"]
@ -55,23 +55,23 @@ numParam = \{ name } ->
{ params: [param], parser }
cliMap : ArgParser a, (a -> b) -> ArgParser b
cliMap = \{ params, parser }, mapper -> {
params,
parser: \args ->
(data, afterData) <- parser args
|> Result.try
cliMap = \{ params, parser }, mapper ->
mappedParser = \args ->
(data, afterData) = parser? args
Ok (mapper data, afterData),
}
Ok (mapper data, afterData)
{
params,
parser: mappedParser,
}
cliBuild : ArgParser a, ArgParser b, (a, b -> c) -> ArgParser c
cliBuild = \firstWeaver, secondWeaver, combine ->
allParams = List.concat firstWeaver.params secondWeaver.params
combinedParser = \args ->
(firstValue, afterFirst) <- firstWeaver.parser args
|> Result.try
(secondValue, afterSecond) <- secondWeaver.parser afterFirst
|> Result.try
(firstValue, afterFirst) = firstWeaver.parser? args
(secondValue, afterSecond) = secondWeaver.parser? afterFirst
Ok (combine firstValue secondValue, afterSecond)

View file

@ -26,18 +26,17 @@ Letter : [A, B, C, Other]
letterParser : Parser (List U8) Letter
letterParser =
input <- buildPrimitiveParser
buildPrimitiveParser \input ->
valResult =
when input is
[] -> Err (ParsingFailure "Nothing to parse")
['A', ..] -> Ok A
['B', ..] -> Ok B
['C', ..] -> Ok C
_ -> Ok Other
valResult =
when input is
[] -> Err (ParsingFailure "Nothing to parse")
['A', ..] -> Ok A
['B', ..] -> Ok B
['C', ..] -> Ok C
_ -> Ok Other
valResult
|> Result.map \val -> { val, input: List.dropFirst input 1 }
valResult
|> Result.map \val -> { val, input: List.dropFirst input 1 }
expect
input = "B"

View file

@ -23,6 +23,7 @@ mod cli_run {
use serial_test::serial;
use std::iter;
use std::path::Path;
use std::process::ExitStatus;
#[cfg(all(unix, not(target_os = "macos")))]
const ALLOW_VALGRIND: bool = true;
@ -106,6 +107,11 @@ mod cli_run {
assert_multiline_str_eq!(err.as_str(), expected);
}
fn assert_valid_roc_check_status(status: ExitStatus) {
// 0 means no errors or warnings, 2 means just warnings
assert!(status.code().is_some_and(|code| code == 0 || code == 2))
}
fn check_format_check_as_expected(file: &Path, expects_success_exit_code: bool) {
let out = run_roc([CMD_FORMAT, file.to_str().unwrap(), CHECK_FLAG], &[], &[]);
@ -803,7 +809,7 @@ mod cli_run {
fn check_virtual_dom_server() {
let path = file_path_from_root("examples/virtual-dom-wip", "example-server.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
assert_valid_roc_check_status(out.status);
}
// TODO: write a new test once mono bugs are resolved in investigation
@ -812,7 +818,7 @@ mod cli_run {
fn check_virtual_dom_client() {
let path = file_path_from_root("examples/virtual-dom-wip", "example-client.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
assert_valid_roc_check_status(out.status);
}
#[test]
@ -821,7 +827,7 @@ mod cli_run {
fn cli_countdown_check() {
let path = file_path_from_root("crates/cli/tests/cli", "countdown.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
assert_valid_roc_check_status(out.status);
}
#[test]
@ -830,7 +836,7 @@ mod cli_run {
fn cli_echo_check() {
let path = file_path_from_root("crates/cli/tests/cli", "echo.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
assert_valid_roc_check_status(out.status);
}
#[test]
@ -839,7 +845,7 @@ mod cli_run {
fn cli_file_check() {
let path = file_path_from_root("crates/cli/tests/cli", "fileBROKEN.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
assert_valid_roc_check_status(out.status);
}
#[test]
@ -848,7 +854,8 @@ mod cli_run {
fn cli_form_check() {
let path = file_path_from_root("crates/cli/tests/cli", "form.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
dbg!(out.stdout, out.stderr);
assert_valid_roc_check_status(out.status);
}
#[test]
@ -857,7 +864,7 @@ mod cli_run {
fn cli_http_get_check() {
let path = file_path_from_root("crates/cli/tests/cli", "http-get.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
assert_valid_roc_check_status(out.status);
}
#[test]
@ -892,7 +899,7 @@ mod cli_run {
}
#[test]
#[cfg_attr(any(target_os = "windows", target_os = "linux"), ignore = "Segfault")]
#[cfg_attr(target_os = "windows", ignore = "Segfault")]
fn false_interpreter() {
test_roc_app(
"examples/cli/false-interpreter",
@ -1482,9 +1489,9 @@ mod cli_run {
Something is off with the body of the main definition:
6 main : Str -> Task {} []
7 main = /_ ->
8 "this is a string, not a Task {} [] function like the platform expects."
5 main : Str -> Task {} []
6 main = /_ ->
7 "this is a string, not a Task {} [] function like the platform expects."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The body is a string of type:

View file

@ -1,7 +1,4 @@
app "type-error"
packages { pf: "../../../../examples/cli/false-interpreter/platform/main.roc" }
imports []
provides [main] to pf
app [main] { pf: platform "../../../../examples/cli/false-interpreter/platform/main.roc" }
main : Str -> Task {} []
main = \_ ->

View file

@ -1159,7 +1159,7 @@ fn link_macos(
Architecture::Aarch64 => {
ld_child.wait()?;
let mut codesign_cmd = Command::new("codesign");
let mut codesign_cmd = Command::new("/usr/bin/codesign");
codesign_cmd.args(["-s", "-", output_path.to_str().unwrap()]);
debug_print_command(&codesign_cmd);
let codesign_child = codesign_cmd.spawn()?;

View file

@ -129,8 +129,8 @@ hashDict = \hasher, dict -> Hash.hashUnordered hasher (toList dict) List.walk
toInspectorDict : Dict k v -> Inspector f where k implements Inspect & Hash & Eq, v implements Inspect, f implements InspectFormatter
toInspectorDict = \dict ->
fmt <- Inspect.custom
Inspect.apply (Inspect.dict dict walk Inspect.toInspector Inspect.toInspector) fmt
Inspect.custom \fmt ->
Inspect.apply (Inspect.dict dict walk Inspect.toInspector Inspect.toInspector) fmt
## Return an empty dictionary.
## ```roc
@ -894,9 +894,9 @@ calcNumBuckets = \shifts ->
maxBucketCount
fillBucketsFromData = \buckets0, data, shifts ->
buckets1, (key, _), dataIndex <- List.walkWithIndex data buckets0
(bucketIndex, distAndFingerprint) = nextWhileLess buckets1 key shifts
placeAndShiftUp buckets1 { distAndFingerprint, dataIndex: Num.toU32 dataIndex } bucketIndex
List.walkWithIndex data buckets0 \buckets1, (key, _), dataIndex ->
(bucketIndex, distAndFingerprint) = nextWhileLess buckets1 key shifts
placeAndShiftUp buckets1 { distAndFingerprint, dataIndex: Num.toU32 dataIndex } bucketIndex
nextWhileLess : List Bucket, k, U8 -> (U64, U32) where k implements Hash & Eq
nextWhileLess = \buckets, key, shifts ->
@ -1213,15 +1213,15 @@ expect
]
dict =
acc, k <- List.walk badKeys (Dict.empty {})
Dict.update acc k \val ->
when val is
Present p -> Present (p |> Num.addWrap 1)
Missing -> Present 0
List.walk badKeys (Dict.empty {}) \acc, k ->
Dict.update acc k \val ->
when val is
Present p -> Present (p |> Num.addWrap 1)
Missing -> Present 0
allInsertedCorrectly =
acc, k <- List.walk badKeys Bool.true
acc && Dict.contains dict k
List.walk badKeys Bool.true \acc, k ->
acc && Dict.contains dict k
allInsertedCorrectly

View file

@ -138,203 +138,203 @@ dbgInit = \{} -> @DbgFormatter { data: "" }
dbgList : list, ElemWalker (DbgFormatter, Bool) list elem, (elem -> Inspector DbgFormatter) -> Inspector DbgFormatter
dbgList = \content, walkFn, toDbgInspector ->
f0 <- custom
dbgWrite f0 "["
|> \f1 ->
(f2, prependSep), elem <- walkFn content (f1, Bool.false)
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
custom \f0 ->
dbgWrite f0 "["
|> \f1 ->
walkFn content (f1, Bool.false) \(f2, prependSep), elem ->
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
elem
|> toDbgInspector
|> apply f3
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "]"
elem
|> toDbgInspector
|> apply f3
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "]"
dbgSet : set, ElemWalker (DbgFormatter, Bool) set elem, (elem -> Inspector DbgFormatter) -> Inspector DbgFormatter
dbgSet = \content, walkFn, toDbgInspector ->
f0 <- custom
dbgWrite f0 "{"
|> \f1 ->
(f2, prependSep), elem <- walkFn content (f1, Bool.false)
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
custom \f0 ->
dbgWrite f0 "{"
|> \f1 ->
walkFn content (f1, Bool.false) \(f2, prependSep), elem ->
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
elem
|> toDbgInspector
|> apply f3
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "}"
elem
|> toDbgInspector
|> apply f3
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "}"
dbgDict : dict, KeyValWalker (DbgFormatter, Bool) dict key value, (key -> Inspector DbgFormatter), (value -> Inspector DbgFormatter) -> Inspector DbgFormatter
dbgDict = \d, walkFn, keyToInspector, valueToInspector ->
f0 <- custom
dbgWrite f0 "{"
|> \f1 ->
(f2, prependSep), key, value <- walkFn d (f1, Bool.false)
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
custom \f0 ->
dbgWrite f0 "{"
|> \f1 ->
walkFn d (f1, Bool.false) \(f2, prependSep), key, value ->
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
apply (keyToInspector key) f3
|> dbgWrite ": "
|> \x -> apply (valueToInspector value) x
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "}"
apply (keyToInspector key) f3
|> dbgWrite ": "
|> \x -> apply (valueToInspector value) x
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "}"
dbgTag : Str, List (Inspector DbgFormatter) -> Inspector DbgFormatter
dbgTag = \name, fields ->
if List.isEmpty fields then
f0 <- custom
dbgWrite f0 name
custom \f0 ->
dbgWrite f0 name
else
f0 <- custom
dbgWrite f0 "("
|> dbgWrite name
|> \f1 ->
f2, inspector <- List.walk fields f1
dbgWrite f2 " "
|> \x -> apply inspector x
|> dbgWrite ")"
custom \f0 ->
dbgWrite f0 "("
|> dbgWrite name
|> \f1 ->
List.walk fields f1 \f2, inspector ->
dbgWrite f2 " "
|> \x -> apply inspector x
|> dbgWrite ")"
dbgTuple : List (Inspector DbgFormatter) -> Inspector DbgFormatter
dbgTuple = \fields ->
f0 <- custom
dbgWrite f0 "("
|> \f1 ->
(f2, prependSep), inspector <- List.walk fields (f1, Bool.false)
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
custom \f0 ->
dbgWrite f0 "("
|> \f1 ->
List.walk fields (f1, Bool.false) \(f2, prependSep), inspector ->
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
apply inspector f3
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite ")"
apply inspector f3
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite ")"
dbgRecord : List { key : Str, value : Inspector DbgFormatter } -> Inspector DbgFormatter
dbgRecord = \fields ->
f0 <- custom
dbgWrite f0 "{"
|> \f1 ->
(f2, prependSep), { key, value } <- List.walk fields (f1, Bool.false)
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
custom \f0 ->
dbgWrite f0 "{"
|> \f1 ->
List.walk fields (f1, Bool.false) \(f2, prependSep), { key, value } ->
f3 =
if prependSep then
dbgWrite f2 ", "
else
f2
dbgWrite f3 key
|> dbgWrite ": "
|> \x -> apply value x
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "}"
dbgWrite f3 key
|> dbgWrite ": "
|> \x -> apply value x
|> \f4 -> (f4, Bool.true)
|> .0
|> dbgWrite "}"
dbgBool : Bool -> Inspector DbgFormatter
dbgBool = \b ->
if b then
f0 <- custom
dbgWrite f0 "Bool.true"
custom \f0 ->
dbgWrite f0 "Bool.true"
else
f0 <- custom
dbgWrite f0 "Bool.false"
custom \f0 ->
dbgWrite f0 "Bool.false"
dbgStr : Str -> Inspector DbgFormatter
dbgStr = \s ->
f0 <- custom
f0
|> dbgWrite "\""
|> dbgWrite s # TODO: Should we be escaping strings for dbg/logging?
|> dbgWrite "\""
custom \f0 ->
f0
|> dbgWrite "\""
|> dbgWrite s # TODO: Should we be escaping strings for dbg/logging?
|> dbgWrite "\""
dbgOpaque : * -> Inspector DbgFormatter
dbgOpaque = \_ ->
f0 <- custom
dbgWrite f0 "<opaque>"
custom \f0 ->
dbgWrite f0 "<opaque>"
dbgFunction : * -> Inspector DbgFormatter
dbgFunction = \_ ->
f0 <- custom
dbgWrite f0 "<function>"
custom \f0 ->
dbgWrite f0 "<function>"
dbgU8 : U8 -> Inspector DbgFormatter
dbgU8 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgI8 : I8 -> Inspector DbgFormatter
dbgI8 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgU16 : U16 -> Inspector DbgFormatter
dbgU16 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgI16 : I16 -> Inspector DbgFormatter
dbgI16 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgU32 : U32 -> Inspector DbgFormatter
dbgU32 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgI32 : I32 -> Inspector DbgFormatter
dbgI32 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgU64 : U64 -> Inspector DbgFormatter
dbgU64 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgI64 : I64 -> Inspector DbgFormatter
dbgI64 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgU128 : U128 -> Inspector DbgFormatter
dbgU128 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgI128 : I128 -> Inspector DbgFormatter
dbgI128 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgF32 : F32 -> Inspector DbgFormatter
dbgF32 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgF64 : F64 -> Inspector DbgFormatter
dbgF64 = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgDec : Dec -> Inspector DbgFormatter
dbgDec = \num ->
f0 <- custom
dbgWrite f0 (num |> Num.toStr)
custom \f0 ->
dbgWrite f0 (num |> Num.toStr)
dbgWrite : DbgFormatter, Str -> DbgFormatter
dbgWrite = \@DbgFormatter { data }, added ->

View file

@ -1,4 +1,15 @@
module [Result, isOk, isErr, map, mapErr, try, onErr, withDefault]
module [
Result,
isOk,
isErr,
map,
mapErr,
mapBoth,
map2,
try,
onErr,
withDefault,
]
import Bool exposing [Bool]
@ -67,6 +78,22 @@ mapErr = \result, transform ->
Ok v -> Ok v
Err e -> Err (transform e)
## Maps both the `Ok` and `Err` values of a `Result` to new values.
mapBoth : Result ok1 err1, (ok1 -> ok2), (err1 -> err2) -> Result ok2 err2
mapBoth = \result, okTransform, errTransform ->
when result is
Ok val -> Ok (okTransform val)
Err err -> Err (errTransform err)
## Maps the `Ok` values of two `Result`s to a new value using a given transformation,
## or returns the first `Err` value encountered.
map2 : Result a err, Result b err, (a, b -> c) -> Result c err
map2 = \firstResult, secondResult, transform ->
when (firstResult, secondResult) is
(Ok first, Ok second) -> Ok (transform first second)
(Err err, _) -> Err err
(_, Err err) -> Err err
## If the result is `Ok`, transforms the entire result by running a conversion
## function on the value the `Ok` holds. Then returns that new result. If the
## result is `Err`, this has no effect. Use `onErr` to transform an `Err`.

View file

@ -62,8 +62,8 @@ hashSet = \hasher, @Set inner -> Hash.hash hasher inner
toInspectorSet : Set k -> Inspector f where k implements Inspect & Hash & Eq, f implements InspectFormatter
toInspectorSet = \set ->
fmt <- Inspect.custom
Inspect.apply (Inspect.set set walk Inspect.toInspector) fmt
Inspect.custom \fmt ->
Inspect.apply (Inspect.set set walk Inspect.toInspector) fmt
## Creates a new empty `Set`.
## ```roc

View file

@ -202,10 +202,10 @@ fromResult = \res ->
## }
## ```
batch : Task a c -> (Task (a -> b) c -> Task b c)
batch = \current -> \next ->
f <- next |> await
map current f
batch = \current ->
\next ->
await next \f ->
map current f
## Apply each task in a list sequentially, and return a list of the resulting values.
## Each task will be awaited before beginning the next task.

View file

@ -1,6 +1,6 @@
use crate::env::Env;
use crate::procedure::{QualifiedReference, References};
use crate::scope::{PendingAbilitiesInScope, Scope};
use crate::scope::{PendingAbilitiesInScope, Scope, SymbolLookup};
use roc_collections::{ImMap, MutSet, SendMap, VecMap, VecSet};
use roc_module::ident::{Ident, Lowercase, TagName};
use roc_module::symbol::Symbol;
@ -386,7 +386,10 @@ pub(crate) fn make_apply_symbol(
// Look it up in scope!
match scope.lookup_str(ident, region) {
Ok(symbol) => {
Ok(SymbolLookup {
symbol,
module_params: _,
}) => {
references.insert_type_lookup(symbol, QualifiedReference::Unqualified);
Ok(symbol)
}
@ -398,7 +401,10 @@ pub(crate) fn make_apply_symbol(
}
} else {
match env.qualified_lookup(scope, module_name, ident, region) {
Ok(symbol) => {
Ok(SymbolLookup {
symbol,
module_params: _,
}) => {
references.insert_type_lookup(symbol, QualifiedReference::Qualified);
Ok(symbol)
}

View file

@ -602,7 +602,8 @@ impl Constraints {
| Constraint::Exhaustive { .. }
| Constraint::Resolve(..)
| Constraint::IngestedFile(..)
| Constraint::CheckCycle(..) => false,
| Constraint::CheckCycle(..)
| Constraint::ImportParams(..) => false,
}
}
@ -685,6 +686,15 @@ impl Constraints {
) -> Constraint {
Constraint::IngestedFile(type_index, file_path, bytes)
}
pub fn import_params(
&mut self,
opt_type_index: Option<TypeOrVar>,
module_id: ModuleId,
region: Region,
) -> Constraint {
Constraint::ImportParams(opt_type_index, module_id, region)
}
}
roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8);
@ -787,6 +797,7 @@ pub enum Constraint {
CheckCycle(Index<Cycle>, IllegalCycleMark),
IngestedFile(TypeOrVar, Box<PathBuf>, Arc<Vec<u8>>),
ImportParams(Option<TypeOrVar>, ModuleId, Region),
}
#[derive(Debug, Clone, Copy, Default)]
@ -865,6 +876,9 @@ impl std::fmt::Debug for Constraint {
Self::IngestedFile(arg0, arg1, arg2) => {
write!(f, "IngestedFile({arg0:?}, {arg1:?}, {arg2:?})")
}
Self::ImportParams(arg0, arg1, arg2) => {
write!(f, "ImportParams({arg0:?}, {arg1:?}, {arg2:?})")
}
}
}
}

View file

@ -288,6 +288,22 @@ fn deep_copy_expr_help<C: CopyEnv>(env: &mut C, copied: &mut Vec<Variable>, expr
loc_elems: loc_elems.iter().map(|le| le.map(|e| go_help!(e))).collect(),
},
Var(sym, var) => Var(*sym, sub!(*var)),
ParamsVar {
symbol,
params,
var,
} => ParamsVar {
symbol: *symbol,
params: *params,
var: sub!(*var),
},
ImportParams(module_id, region, opt_provided) => ImportParams(
*module_id,
*region,
opt_provided
.as_ref()
.map(|(var, expr)| (sub!(*var), Box::new(go_help!(&expr)))),
),
&AbilityMember(sym, specialization, specialization_var) => {
AbilityMember(sym, specialization, sub!(specialization_var))
}

View file

@ -3,12 +3,14 @@
use crate::def::Def;
use crate::expr::Expr::{self, *};
use crate::expr::{
ClosureData, DeclarationTag, Declarations, FunctionDef, OpaqueWrapFunctionData, WhenBranch,
ClosureData, DeclarationTag, Declarations, FunctionDef, OpaqueWrapFunctionData,
StructAccessorData, WhenBranch,
};
use crate::pattern::{Pattern, RecordDestruct, TupleDestruct};
use roc_module::symbol::{Interns, ModuleId, Symbol};
use roc_types::types::IndexOrField;
use ven_pretty::{text, Arena, DocAllocator, DocBuilder};
pub struct Ctx<'a> {
@ -206,7 +208,13 @@ fn expr<'a>(c: &Ctx, p: EPrec, f: &'a Arena<'a>, e: &'a Expr) -> DocBuilder<'a,
.append("]")
.group(),
),
Var(sym, _) | AbilityMember(sym, _, _) => pp_sym(c, f, *sym),
Var(sym, _) | ParamsVar { symbol: sym, .. } | AbilityMember(sym, _, _) => {
pp_sym(c, f, *sym)
}
ImportParams(_, _, Some((_, params_expr))) => expr(c, p, f, params_expr),
ImportParams(module_id, _, None) => {
text!(f, "<no params for {:?}>", module_id)
}
When {
loc_cond, branches, ..
} => maybe_paren!(
@ -375,7 +383,10 @@ fn expr<'a>(c: &Ctx, p: EPrec, f: &'a Arena<'a>, e: &'a Expr) -> DocBuilder<'a,
OpaqueWrapFunction(OpaqueWrapFunctionData { opaque_name, .. }) => {
text!(f, "@{}", opaque_name.as_str(c.interns))
}
RecordAccessor(_) => todo!(),
RecordAccessor(StructAccessorData { field, .. }) => match field {
IndexOrField::Index(index) => text!(f, ".{}", index),
IndexOrField::Field(name) => text!(f, ".{}", name),
},
RecordUpdate {
symbol, updates, ..
} => f

View file

@ -10,6 +10,7 @@ use crate::annotation::IntroducedVariables;
use crate::annotation::OwnedNamedOrAble;
use crate::derive;
use crate::env::Env;
use crate::expr::canonicalize_record;
use crate::expr::get_lookup_symbols;
use crate::expr::AnnotatedMark;
use crate::expr::ClosureData;
@ -18,6 +19,7 @@ use crate::expr::Expr::{self, *};
use crate::expr::StructAccessorData;
use crate::expr::{canonicalize_expr, Output, Recursive};
use crate::pattern::{canonicalize_def_header_pattern, BindingsFromPattern, Pattern};
use crate::procedure::QualifiedReference;
use crate::procedure::References;
use crate::scope::create_alias;
use crate::scope::{PendingAbilitiesInScope, Scope};
@ -160,6 +162,13 @@ enum PendingValueDef<'a> {
&'a Loc<ast::TypeAnnotation<'a>>,
&'a Loc<ast::Expr<'a>>,
),
/// Module params from an import
ImportParams {
symbol: Symbol,
loc_pattern: Loc<Pattern>,
module_id: ModuleId,
opt_provided: Option<ast::Collection<'a, Loc<AssignedField<'a, ast::Expr<'a>>>>>,
},
/// Ingested file
IngestedFile(
Loc<Pattern>,
@ -174,6 +183,12 @@ impl PendingValueDef<'_> {
PendingValueDef::AnnotationOnly(loc_pattern, _) => loc_pattern,
PendingValueDef::Body(loc_pattern, _) => loc_pattern,
PendingValueDef::TypedBody(_, loc_pattern, _, _) => loc_pattern,
PendingValueDef::ImportParams {
loc_pattern,
symbol: _,
module_id: _,
opt_provided: _,
} => loc_pattern,
PendingValueDef::IngestedFile(loc_pattern, _, _) => loc_pattern,
}
}
@ -485,6 +500,16 @@ fn canonicalize_alias<'a>(
}
}
#[macro_export]
macro_rules! params_in_abilities_unimplemented {
($lookup:expr) => {
match $lookup.module_params {
None => $lookup.symbol,
Some(_) => unimplemented!("params in abilities"),
}
};
}
/// Canonicalizes a claimed ability implementation like `{ eq }` or `{ eq: myEq }`.
/// Returns a mapping of the ability member to the implementation symbol.
/// If there was an error, a problem will be recorded and nothing is returned.
@ -503,7 +528,7 @@ fn canonicalize_claimed_ability_impl<'a>(
let member_symbol =
match env.qualified_lookup_with_module_id(scope, ability_home, label_str, region) {
Ok(symbol) => symbol,
Ok(lookup) => params_in_abilities_unimplemented!(lookup),
Err(_) => {
env.problem(Problem::NotAnAbilityMember {
ability,
@ -546,8 +571,13 @@ fn canonicalize_claimed_ability_impl<'a>(
// To handle both cases, try checking for a shadow first, then check for a direct
// reference. We want to check for a direct reference second so that if there is a
// shadow, we won't accidentally grab the imported symbol.
let opt_impl_symbol = (scope.lookup_ability_member_shadow(member_symbol))
.or_else(|| scope.lookup_str(label_str, region).ok());
let opt_impl_symbol =
(scope.lookup_ability_member_shadow(member_symbol)).or_else(|| {
scope
.lookup_str(label_str, region)
.map(|s| params_in_abilities_unimplemented!(s))
.ok()
});
match opt_impl_symbol {
// It's possible that even if we find a symbol it is still only the member
@ -599,7 +629,7 @@ fn canonicalize_claimed_ability_impl<'a>(
label.value,
label.region,
) {
Ok(symbol) => symbol,
Ok(lookup) => params_in_abilities_unimplemented!(lookup),
Err(_) => {
env.problem(Problem::NotAnAbilityMember {
ability,
@ -611,7 +641,7 @@ fn canonicalize_claimed_ability_impl<'a>(
};
let impl_symbol = match scope.lookup(&impl_ident.into(), impl_region) {
Ok(symbol) => symbol,
Ok(symbol) => params_in_abilities_unimplemented!(symbol),
Err(err) => {
env.problem(Problem::RuntimeError(err));
return Err(());
@ -1109,8 +1139,24 @@ fn canonicalize_value_defs<'a>(
PendingValue::ExpectFx(pending_expect) => {
pending_expect_fx.push(pending_expect);
}
PendingValue::ModuleImport(introduced_import) => {
imports_introduced.push(introduced_import);
PendingValue::ModuleImport(PendingModuleImport {
module_id,
region,
exposed_symbols,
params,
}) => {
imports_introduced.push(IntroducedImport {
module_id,
region,
exposed_symbols,
});
pending_value_defs.push(PendingValueDef::ImportParams {
symbol: params.symbol,
loc_pattern: params.loc_pattern,
opt_provided: params.opt_provided,
module_id,
});
}
PendingValue::InvalidIngestedFile => { /* skip */ }
PendingValue::ImportNameConflict => { /* skip */ }
@ -1558,7 +1604,7 @@ impl DefOrdering {
fn insert_symbol_references(&mut self, def_id: u32, def_references: &DefReferences) {
match def_references {
DefReferences::Value(references) => {
let it = references.value_lookups().chain(references.calls());
let it = references.value_lookups();
for referenced in it {
if let Some(ref_id) = self.get_id(*referenced) {
@ -2352,6 +2398,50 @@ fn canonicalize_pending_value_def<'a>(
None,
)
}
ImportParams {
symbol,
loc_pattern,
module_id,
opt_provided,
} => {
// Insert a reference to the record so that we don't report it as unused
// If the whole module is unused, we'll report that separately
output
.references
.insert_value_lookup(symbol, QualifiedReference::Unqualified);
let (opt_var_record, references) = match opt_provided {
Some(params) => {
let (record, can_output) =
canonicalize_record(env, var_store, scope, loc_pattern.region, params);
let references = can_output.references.clone();
output.union(can_output);
(Some((var_store.fresh(), Box::new(record))), references)
}
None => (None, References::new()),
};
let loc_expr = Loc::at(
loc_pattern.region,
Expr::ImportParams(module_id, loc_pattern.region, opt_var_record),
);
let def = single_can_def(
loc_pattern,
loc_expr,
var_store.fresh(),
None,
SendMap::default(),
);
DefOutput {
output,
references: DefReferences::Value(references),
def,
}
}
IngestedFile(loc_pattern, opt_loc_ann, path_literal) => {
let relative_path =
if let ast::StrLiteral::PlainLine(ingested_path) = path_literal.value {
@ -2892,7 +2982,7 @@ enum PendingValue<'a> {
Dbg(PendingExpectOrDbg<'a>),
Expect(PendingExpectOrDbg<'a>),
ExpectFx(PendingExpectOrDbg<'a>),
ModuleImport(IntroducedImport),
ModuleImport(PendingModuleImport<'a>),
SignatureDefMismatch,
InvalidIngestedFile,
ImportNameConflict,
@ -2903,6 +2993,19 @@ struct PendingExpectOrDbg<'a> {
preceding_comment: Region,
}
struct PendingModuleImport<'a> {
module_id: ModuleId,
region: Region,
exposed_symbols: Vec<(Symbol, Region)>,
params: PendingModuleImportParams<'a>,
}
struct PendingModuleImportParams<'a> {
symbol: Symbol,
loc_pattern: Loc<Pattern>,
opt_provided: Option<ast::Collection<'a, Loc<AssignedField<'a, ast::Expr<'a>>>>>,
}
pub struct IntroducedImport {
module_id: ModuleId,
region: Region,
@ -3042,10 +3145,27 @@ fn to_pending_value_def<'a>(
None => module_name.clone(),
};
// Generate a symbol for the module params def
// We do this even if params weren't provided so that solve can report if they are missing
let params_sym = scope.gen_unique_symbol();
let params_region = module_import.params.map(|p| p.params.region).unwrap_or(region);
let params =
PendingModuleImportParams {
symbol: params_sym,
loc_pattern: Loc::at(params_region, Pattern::Identifier(params_sym)),
opt_provided: module_import.params.map(|p| p.params.value),
};
let provided_params_sym = if module_import.params.is_some() {
// Only add params to scope if they are provided
Some(params_sym)
} else {
None
};
if let Err(existing_import) =
scope
.modules
.insert(name_with_alias.clone(), module_id, region)
.insert(name_with_alias.clone(), module_id, provided_params_sym, region)
{
env.problems.push(Problem::ImportNameConflict {
name: name_with_alias,
@ -3056,7 +3176,7 @@ fn to_pending_value_def<'a>(
});
return PendingValue::ImportNameConflict;
}
};
let exposed_names = module_import
.exposed
@ -3108,13 +3228,13 @@ fn to_pending_value_def<'a>(
}))
}
}
}
PendingValue::ModuleImport(IntroducedImport {
PendingValue::ModuleImport(PendingModuleImport {
module_id,
region,
exposed_symbols,
params,
})
}
IngestedFileImport(ingested_file) => {

View file

@ -1,6 +1,6 @@
#![allow(clippy::manual_map)]
use crate::suffixed::{apply_task_await, unwrap_suffixed_expression, EUnwrapped};
use crate::suffixed::{apply_try_function, unwrap_suffixed_expression, EUnwrapped};
use bumpalo::collections::Vec;
use bumpalo::Bump;
use roc_error_macros::internal_error;
@ -12,6 +12,7 @@ use roc_parse::ast::{
AssignedField, Collection, ModuleImportParams, OldRecordBuilderField, Pattern, StrLiteral,
StrSegment, TypeAnnotation, ValueDef, WhenBranch,
};
use roc_problem::can::Problem;
use roc_region::all::{LineInfo, Loc, Region};
// BinOp precedence logic adapted from Gluon by Markus Westerlind
@ -74,13 +75,14 @@ fn desugar_value_def<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> ValueDef<'a> {
use ValueDef::*;
match def {
Body(loc_pattern, loc_expr) => Body(
desugar_loc_pattern(arena, loc_pattern, src, line_info, module_path),
desugar_expr(arena, loc_expr, src, line_info, module_path),
desugar_loc_pattern(arena, loc_pattern, src, line_info, module_path, problems),
desugar_expr(arena, loc_expr, src, line_info, module_path, problems),
),
ann @ Annotation(_, _) => *ann,
AnnotatedBody {
@ -93,16 +95,29 @@ fn desugar_value_def<'a>(
ann_pattern,
ann_type,
lines_between,
body_pattern: desugar_loc_pattern(arena, body_pattern, src, line_info, module_path),
body_expr: desugar_expr(arena, body_expr, src, line_info, module_path),
body_pattern: desugar_loc_pattern(
arena,
body_pattern,
src,
line_info,
module_path,
problems,
),
body_expr: desugar_expr(arena, body_expr, src, line_info, module_path, problems),
},
Dbg {
condition,
preceding_comment,
} => {
let desugared_condition =
&*arena.alloc(desugar_expr(arena, condition, src, line_info, module_path));
let desugared_condition = &*arena.alloc(desugar_expr(
arena,
condition,
src,
line_info,
module_path,
problems,
));
Dbg {
condition: desugared_condition,
preceding_comment: *preceding_comment,
@ -112,8 +127,14 @@ fn desugar_value_def<'a>(
condition,
preceding_comment,
} => {
let desugared_condition =
&*arena.alloc(desugar_expr(arena, condition, src, line_info, module_path));
let desugared_condition = &*arena.alloc(desugar_expr(
arena,
condition,
src,
line_info,
module_path,
problems,
));
Expect {
condition: desugared_condition,
preceding_comment: *preceding_comment,
@ -123,8 +144,14 @@ fn desugar_value_def<'a>(
condition,
preceding_comment,
} => {
let desugared_condition =
&*arena.alloc(desugar_expr(arena, condition, src, line_info, module_path));
let desugared_condition = &*arena.alloc(desugar_expr(
arena,
condition,
src,
line_info,
module_path,
problems,
));
ExpectFx {
condition: desugared_condition,
preceding_comment: *preceding_comment,
@ -140,7 +167,16 @@ fn desugar_value_def<'a>(
let desugared_params =
params.map(|ModuleImportParams { before, params }| ModuleImportParams {
before,
params: desugar_field_collection(arena, params, src, line_info, module_path),
params: params.map(|params| {
desugar_field_collection(
arena,
*params,
src,
line_info,
module_path,
problems,
)
}),
});
ModuleImport(roc_parse::ast::ModuleImport {
@ -172,7 +208,7 @@ fn desugar_value_def<'a>(
)),
lines_between: &[],
body_pattern: new_pat,
body_expr: desugar_expr(arena, stmt_expr, src, line_info, module_path),
body_expr: desugar_expr(arena, stmt_expr, src, line_info, module_path, problems),
}
}
}
@ -185,9 +221,17 @@ pub fn desugar_defs_node_values<'a>(
line_info: &mut Option<LineInfo>,
module_path: &str,
top_level_def: bool,
problems: &mut std::vec::Vec<Problem>,
) {
for value_def in defs.value_defs.iter_mut() {
*value_def = desugar_value_def(arena, arena.alloc(*value_def), src, line_info, module_path);
*value_def = desugar_value_def(
arena,
arena.alloc(*value_def),
src,
line_info,
module_path,
problems,
);
}
// `desugar_defs_node_values` is called recursively in `desugar_expr`
@ -218,11 +262,20 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
sub_arg,
sub_pat,
sub_new,
target,
}) => desugar_value_def_suffixed(
arena,
Body(
loc_pattern,
apply_task_await(arena, loc_expr.region, sub_arg, sub_pat, sub_new, None),
apply_try_function(
arena,
loc_expr.region,
sub_arg,
sub_pat,
sub_new,
None,
target,
),
),
),
Err(..) => Body(
@ -252,6 +305,7 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
sub_arg,
sub_pat,
sub_new,
target,
}) => desugar_value_def_suffixed(
arena,
AnnotatedBody {
@ -259,13 +313,14 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
ann_type,
lines_between,
body_pattern,
body_expr: apply_task_await(
body_expr: apply_try_function(
arena,
body_expr.region,
sub_arg,
sub_pat,
sub_new,
Some((ann_pattern, ann_type)),
target,
),
},
),
@ -299,6 +354,7 @@ pub fn desugar_expr<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> &'a Loc<Expr<'a>> {
match &loc_expr.value {
Float(..)
@ -331,6 +387,7 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
)));
arena.alloc(Loc { region, value })
@ -339,7 +396,7 @@ pub fn desugar_expr<'a>(
let region = loc_expr.region;
let new_lines = Vec::from_iter_in(
lines.iter().map(|segments| {
desugar_str_segments(arena, segments, src, line_info, module_path)
desugar_str_segments(arena, segments, src, line_info, module_path, problems)
}),
arena,
);
@ -362,6 +419,7 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
)
.value,
paths,
@ -369,14 +427,24 @@ pub fn desugar_expr<'a>(
arena.alloc(Loc { region, value })
}
// desugar the sub_expression, but leave the TaskAwaitBang as this will
// desugar the sub_expression, but leave the TrySuffix as this will
// be unwrapped later in desugar_value_def_suffixed
TaskAwaitBang(sub_expr) => {
TrySuffix {
expr: sub_expr,
target,
} => {
let intermediate = arena.alloc(Loc::at(loc_expr.region, **sub_expr));
let new_sub_loc_expr = desugar_expr(arena, intermediate, src, line_info, module_path);
let new_sub_loc_expr =
desugar_expr(arena, intermediate, src, line_info, module_path, problems);
let new_sub_expr = arena.alloc(new_sub_loc_expr.value);
arena.alloc(Loc::at(loc_expr.region, TaskAwaitBang(new_sub_expr)))
arena.alloc(Loc::at(
loc_expr.region,
TrySuffix {
expr: new_sub_expr,
target: *target,
},
))
}
RecordAccess(sub_expr, paths) => {
let region = loc_expr.region;
@ -391,6 +459,7 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
)
.value,
paths,
@ -402,7 +471,14 @@ pub fn desugar_expr<'a>(
let mut new_items = Vec::with_capacity_in(items.len(), arena);
for item in items.iter() {
new_items.push(desugar_expr(arena, item, src, line_info, module_path));
new_items.push(desugar_expr(
arena,
item,
src,
line_info,
module_path,
problems,
));
}
let new_items = new_items.into_bump_slice();
let value: Expr<'a> = List(items.replace_items(new_items));
@ -413,7 +489,8 @@ pub fn desugar_expr<'a>(
})
}
Record(fields) => {
let fields = desugar_field_collection(arena, *fields, src, line_info, module_path);
let fields =
desugar_field_collection(arena, *fields, src, line_info, module_path, problems);
arena.alloc(Loc {
region: loc_expr.region,
value: Record(fields),
@ -422,7 +499,7 @@ pub fn desugar_expr<'a>(
Tuple(fields) => {
let mut allocated = Vec::with_capacity_in(fields.len(), arena);
for field in fields.iter() {
let expr = desugar_expr(arena, field, src, line_info, module_path);
let expr = desugar_expr(arena, field, src, line_info, module_path, problems);
allocated.push(expr);
}
let fields = fields.replace_items(allocated.into_bump_slice());
@ -434,11 +511,12 @@ pub fn desugar_expr<'a>(
RecordUpdate { fields, update } => {
// NOTE the `update` field is always a `Var { .. }`, we only desugar it to get rid of
// any spaces before/after
let new_update = desugar_expr(arena, update, src, line_info, module_path);
let new_update = desugar_expr(arena, update, src, line_info, module_path, problems);
let mut allocated = Vec::with_capacity_in(fields.len(), arena);
for field in fields.iter() {
let value = desugar_field(arena, &field.value, src, line_info, module_path);
let value =
desugar_field(arena, &field.value, src, line_info, module_path, problems);
allocated.push(Loc {
value,
region: field.region,
@ -454,11 +532,65 @@ pub fn desugar_expr<'a>(
},
})
}
RecordUpdater(field_name) => {
let region = loc_expr.region;
let closure_body = RecordUpdate {
update: arena.alloc(Loc {
region,
value: Expr::Var {
module_name: "",
ident: "#record_updater_record",
},
}),
fields: Collection::with_items(
Vec::from_iter_in(
[Loc::at(
region,
AssignedField::RequiredValue(
Loc::at(region, field_name),
&[],
&*arena.alloc(Loc {
region,
value: Expr::Var {
module_name: "",
ident: "#record_updater_field",
},
}),
),
)],
arena,
)
.into_bump_slice(),
),
};
arena.alloc(Loc {
region,
value: Closure(
arena.alloc_slice_copy(&[
Loc::at(
region,
Pattern::Identifier {
ident: "#record_updater_record",
},
),
Loc::at(
region,
Pattern::Identifier {
ident: "#record_updater_field",
},
),
]),
arena.alloc(Loc::at(region, closure_body)),
),
})
}
Closure(loc_patterns, loc_ret) => arena.alloc(Loc {
region: loc_expr.region,
value: Closure(
desugar_loc_patterns(arena, loc_patterns, src, line_info, module_path),
desugar_expr(arena, loc_ret, src, line_info, module_path),
desugar_loc_patterns(arena, loc_patterns, src, line_info, module_path, problems),
desugar_expr(arena, loc_ret, src, line_info, module_path, problems),
),
}),
Backpassing(loc_patterns, loc_body, loc_ret) => {
@ -466,12 +598,19 @@ pub fn desugar_expr<'a>(
//
// loc_ret
// first desugar the body, because it may contain |>
let desugared_body = desugar_expr(arena, loc_body, src, line_info, module_path);
let problem_region = Region::span_across(
&Region::across_all(loc_patterns.iter().map(|loc_pattern| &loc_pattern.region)),
&loc_body.region,
);
problems.push(Problem::DeprecatedBackpassing(problem_region));
let desugared_ret = desugar_expr(arena, loc_ret, src, line_info, module_path);
// first desugar the body, because it may contain |>
let desugared_body =
desugar_expr(arena, loc_body, src, line_info, module_path, problems);
let desugared_ret = desugar_expr(arena, loc_ret, src, line_info, module_path, problems);
let desugared_loc_patterns =
desugar_loc_patterns(arena, loc_patterns, src, line_info, module_path);
desugar_loc_patterns(arena, loc_patterns, src, line_info, module_path, problems);
let closure = Expr::Closure(desugared_loc_patterns, desugared_ret);
let loc_closure = Loc::at(loc_expr.region, closure);
@ -507,7 +646,7 @@ pub fn desugar_expr<'a>(
RecordBuilder { mapper, fields } => {
// NOTE the `mapper` is always a `Var { .. }`, we only desugar it to get rid of
// any spaces before/after
let new_mapper = desugar_expr(arena, mapper, src, line_info, module_path);
let new_mapper = desugar_expr(arena, mapper, src, line_info, module_path, problems);
if fields.is_empty() {
return arena.alloc(Loc {
@ -531,7 +670,8 @@ pub fn desugar_expr<'a>(
for field in fields.items {
let (name, value, ignored) =
match desugar_field(arena, &field.value, src, line_info, module_path) {
match desugar_field(arena, &field.value, src, line_info, module_path, problems)
{
AssignedField::RequiredValue(loc_name, _, loc_val) => {
(loc_name, loc_val, false)
}
@ -769,11 +909,20 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
),
Defs(defs, loc_ret) => {
let mut defs = (*defs).clone();
desugar_defs_node_values(arena, &mut defs, src, line_info, module_path, false);
let loc_ret = desugar_expr(arena, loc_ret, src, line_info, module_path);
desugar_defs_node_values(
arena,
&mut defs,
src,
line_info,
module_path,
false,
problems,
);
let loc_ret = desugar_expr(arena, loc_ret, src, line_info, module_path, problems);
arena.alloc(Loc::at(loc_expr.region, Defs(arena.alloc(defs), loc_ret)))
}
@ -805,14 +954,21 @@ pub fn desugar_expr<'a>(
}
};
desugared_args.push(desugar_expr(arena, arg, src, line_info, module_path));
desugared_args.push(desugar_expr(
arena,
arg,
src,
line_info,
module_path,
problems,
));
}
let desugared_args = desugared_args.into_bump_slice();
let mut apply: &Loc<Expr> = arena.alloc(Loc {
value: Apply(
desugar_expr(arena, loc_fn, src, line_info, module_path),
desugar_expr(arena, loc_fn, src, line_info, module_path, problems),
desugared_args,
*called_via,
),
@ -824,7 +980,8 @@ pub fn desugar_expr<'a>(
Some(apply_exprs) => {
for expr in apply_exprs {
let desugared_expr = desugar_expr(arena, expr, src, line_info, module_path);
let desugared_expr =
desugar_expr(arena, expr, src, line_info, module_path, problems);
let args = std::slice::from_ref(arena.alloc(apply));
@ -845,17 +1002,31 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
));
let mut desugared_branches = Vec::with_capacity_in(branches.len(), arena);
for branch in branches.iter() {
let desugared_expr =
desugar_expr(arena, &branch.value, src, line_info, module_path);
let desugared_patterns =
desugar_loc_patterns(arena, branch.patterns, src, line_info, module_path);
desugar_expr(arena, &branch.value, src, line_info, module_path, problems);
let desugared_patterns = desugar_loc_patterns(
arena,
branch.patterns,
src,
line_info,
module_path,
problems,
);
let desugared_guard = if let Some(guard) = &branch.guard {
Some(*desugar_expr(arena, guard, src, line_info, module_path))
Some(*desugar_expr(
arena,
guard,
src,
line_info,
module_path,
problems,
))
} else {
None
};
@ -893,8 +1064,14 @@ pub fn desugar_expr<'a>(
},
};
let loc_fn_var = arena.alloc(Loc { region, value });
let desugared_args =
arena.alloc([desugar_expr(arena, loc_arg, src, line_info, module_path)]);
let desugared_args = arena.alloc([desugar_expr(
arena,
loc_arg,
src,
line_info,
module_path,
problems,
)]);
arena.alloc(Loc {
value: Apply(loc_fn_var, desugared_args, CalledVia::UnaryOp(op)),
@ -913,6 +1090,7 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
)
}
ParensAround(expr) => {
@ -925,6 +1103,7 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
);
arena.alloc(Loc {
@ -940,14 +1119,15 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
));
let mut desugared_if_thens = Vec::with_capacity_in(if_thens.len(), arena);
for (condition, then_branch) in if_thens.iter() {
desugared_if_thens.push((
*desugar_expr(arena, condition, src, line_info, module_path),
*desugar_expr(arena, then_branch, src, line_info, module_path),
*desugar_expr(arena, condition, src, line_info, module_path, problems),
*desugar_expr(arena, then_branch, src, line_info, module_path, problems),
));
}
@ -957,14 +1137,21 @@ pub fn desugar_expr<'a>(
})
}
Expect(condition, continuation) => {
let desugared_condition =
&*arena.alloc(desugar_expr(arena, condition, src, line_info, module_path));
let desugared_condition = &*arena.alloc(desugar_expr(
arena,
condition,
src,
line_info,
module_path,
problems,
));
let desugared_continuation = &*arena.alloc(desugar_expr(
arena,
continuation,
src,
line_info,
module_path,
problems,
));
arena.alloc(Loc {
value: Expect(desugared_condition, desugared_continuation),
@ -980,6 +1167,7 @@ pub fn desugar_expr<'a>(
src,
line_info,
module_path,
problems,
));
let region = condition.region;
@ -992,8 +1180,14 @@ pub fn desugar_expr<'a>(
value: inspect_fn,
region,
});
let desugared_inspect_args =
arena.alloc([desugar_expr(arena, condition, src, line_info, module_path)]);
let desugared_inspect_args = arena.alloc([desugar_expr(
arena,
condition,
src,
line_info,
module_path,
problems,
)]);
let dbg_str = arena.alloc(Loc {
value: Apply(loc_inspect_fn_var, desugared_inspect_args, CalledVia::Space),
@ -1038,6 +1232,7 @@ fn desugar_str_segments<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> &'a [StrSegment<'a>] {
Vec::from_iter_in(
segments.iter().map(|segment| match segment {
@ -1054,6 +1249,7 @@ fn desugar_str_segments<'a>(
src,
line_info,
module_path,
problems,
);
StrSegment::DeprecatedInterpolated(Loc {
region: loc_desugared.region,
@ -1070,6 +1266,7 @@ fn desugar_str_segments<'a>(
src,
line_info,
module_path,
problems,
);
StrSegment::Interpolated(Loc {
region: loc_desugared.region,
@ -1088,11 +1285,12 @@ fn desugar_field_collection<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> Collection<'a, Loc<AssignedField<'a, Expr<'a>>>> {
let mut allocated = Vec::with_capacity_in(fields.len(), arena);
for field in fields.iter() {
let value = desugar_field(arena, &field.value, src, line_info, module_path);
let value = desugar_field(arena, &field.value, src, line_info, module_path, problems);
allocated.push(Loc::at(field.region, value));
}
@ -1106,6 +1304,7 @@ fn desugar_field<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> AssignedField<'a, Expr<'a>> {
use roc_parse::ast::AssignedField::*;
@ -1116,7 +1315,7 @@ fn desugar_field<'a>(
region: loc_str.region,
},
spaces,
desugar_expr(arena, loc_expr, src, line_info, module_path),
desugar_expr(arena, loc_expr, src, line_info, module_path, problems),
),
OptionalValue(loc_str, spaces, loc_expr) => OptionalValue(
Loc {
@ -1124,7 +1323,7 @@ fn desugar_field<'a>(
region: loc_str.region,
},
spaces,
desugar_expr(arena, loc_expr, src, line_info, module_path),
desugar_expr(arena, loc_expr, src, line_info, module_path, problems),
),
IgnoredValue(loc_str, spaces, loc_expr) => IgnoredValue(
Loc {
@ -1132,7 +1331,7 @@ fn desugar_field<'a>(
region: loc_str.region,
},
spaces,
desugar_expr(arena, loc_expr, src, line_info, module_path),
desugar_expr(arena, loc_expr, src, line_info, module_path, problems),
),
LabelOnly(loc_str) => {
// Desugar { x } into { x: x }
@ -1150,11 +1349,22 @@ fn desugar_field<'a>(
region: loc_str.region,
},
&[],
desugar_expr(arena, arena.alloc(loc_expr), src, line_info, module_path),
desugar_expr(
arena,
arena.alloc(loc_expr),
src,
line_info,
module_path,
problems,
),
)
}
SpaceBefore(field, _spaces) => desugar_field(arena, field, src, line_info, module_path),
SpaceAfter(field, _spaces) => desugar_field(arena, field, src, line_info, module_path),
SpaceBefore(field, _spaces) => {
desugar_field(arena, field, src, line_info, module_path, problems)
}
SpaceAfter(field, _spaces) => {
desugar_field(arena, field, src, line_info, module_path, problems)
}
Malformed(string) => Malformed(string),
}
@ -1166,11 +1376,19 @@ fn desugar_loc_patterns<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> &'a [Loc<Pattern<'a>>] {
Vec::from_iter_in(
loc_patterns.iter().map(|loc_pattern| Loc {
region: loc_pattern.region,
value: desugar_pattern(arena, loc_pattern.value, src, line_info, module_path),
value: desugar_pattern(
arena,
loc_pattern.value,
src,
line_info,
module_path,
problems,
),
}),
arena,
)
@ -1183,10 +1401,18 @@ fn desugar_loc_pattern<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> &'a Loc<Pattern<'a>> {
arena.alloc(Loc {
region: loc_pattern.region,
value: desugar_pattern(arena, loc_pattern.value, src, line_info, module_path),
value: desugar_pattern(
arena,
loc_pattern.value,
src,
line_info,
module_path,
problems,
),
})
}
@ -1196,6 +1422,7 @@ fn desugar_pattern<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> Pattern<'a> {
use roc_parse::ast::Pattern::*;
@ -1219,7 +1446,14 @@ fn desugar_pattern<'a>(
let desugared_arg_patterns = Vec::from_iter_in(
arg_patterns.iter().map(|arg_pattern| Loc {
region: arg_pattern.region,
value: desugar_pattern(arena, arg_pattern.value, src, line_info, module_path),
value: desugar_pattern(
arena,
arg_pattern.value,
src,
line_info,
module_path,
problems,
),
}),
arena,
)
@ -1230,8 +1464,14 @@ fn desugar_pattern<'a>(
RecordDestructure(field_patterns) => {
let mut allocated = Vec::with_capacity_in(field_patterns.len(), arena);
for field_pattern in field_patterns.iter() {
let value =
desugar_pattern(arena, field_pattern.value, src, line_info, module_path);
let value = desugar_pattern(
arena,
field_pattern.value,
src,
line_info,
module_path,
problems,
);
allocated.push(Loc {
value,
region: field_pattern.region,
@ -1243,15 +1483,17 @@ fn desugar_pattern<'a>(
}
RequiredField(name, field_pattern) => RequiredField(
name,
desugar_loc_pattern(arena, field_pattern, src, line_info, module_path),
desugar_loc_pattern(arena, field_pattern, src, line_info, module_path, problems),
),
OptionalField(name, expr) => OptionalField(
name,
desugar_expr(arena, expr, src, line_info, module_path, problems),
),
OptionalField(name, expr) => {
OptionalField(name, desugar_expr(arena, expr, src, line_info, module_path))
}
Tuple(patterns) => {
let mut allocated = Vec::with_capacity_in(patterns.len(), arena);
for pattern in patterns.iter() {
let value = desugar_pattern(arena, pattern.value, src, line_info, module_path);
let value =
desugar_pattern(arena, pattern.value, src, line_info, module_path, problems);
allocated.push(Loc {
value,
region: pattern.region,
@ -1264,7 +1506,8 @@ fn desugar_pattern<'a>(
List(patterns) => {
let mut allocated = Vec::with_capacity_in(patterns.len(), arena);
for pattern in patterns.iter() {
let value = desugar_pattern(arena, pattern.value, src, line_info, module_path);
let value =
desugar_pattern(arena, pattern.value, src, line_info, module_path, problems);
allocated.push(Loc {
value,
region: pattern.region,
@ -1275,14 +1518,14 @@ fn desugar_pattern<'a>(
List(patterns)
}
As(sub_pattern, symbol) => As(
desugar_loc_pattern(arena, sub_pattern, src, line_info, module_path),
desugar_loc_pattern(arena, sub_pattern, src, line_info, module_path, problems),
symbol,
),
SpaceBefore(sub_pattern, _spaces) => {
desugar_pattern(arena, *sub_pattern, src, line_info, module_path)
desugar_pattern(arena, *sub_pattern, src, line_info, module_path, problems)
}
SpaceAfter(sub_pattern, _spaces) => {
desugar_pattern(arena, *sub_pattern, src, line_info, module_path)
desugar_pattern(arena, *sub_pattern, src, line_info, module_path, problems)
}
}
}
@ -1403,6 +1646,7 @@ fn binop_to_function(binop: BinOp) -> (&'static str, &'static str) {
}
}
#[allow(clippy::too_many_arguments)]
fn desugar_bin_ops<'a>(
arena: &'a Bump,
whole_region: Region,
@ -1411,19 +1655,27 @@ fn desugar_bin_ops<'a>(
src: &'a str,
line_info: &mut Option<LineInfo>,
module_path: &str,
problems: &mut std::vec::Vec<Problem>,
) -> &'a Loc<Expr<'a>> {
let mut arg_stack: Vec<&'a Loc<Expr>> = Vec::with_capacity_in(lefts.len() + 1, arena);
let mut op_stack: Vec<Loc<BinOp>> = Vec::with_capacity_in(lefts.len(), arena);
for (loc_expr, loc_op) in lefts {
arg_stack.push(desugar_expr(arena, loc_expr, src, line_info, module_path));
arg_stack.push(desugar_expr(
arena,
loc_expr,
src,
line_info,
module_path,
problems,
));
match run_binop_step(arena, whole_region, &mut arg_stack, &mut op_stack, *loc_op) {
Err(problem) => return problem,
Ok(()) => continue,
}
}
let mut expr = desugar_expr(arena, right, src, line_info, module_path);
let mut expr = desugar_expr(arena, right, src, line_info, module_path, problems);
for (left, loc_op) in arg_stack.into_iter().zip(op_stack.into_iter()).rev() {
expr = arena.alloc(new_op_call_expr(arena, left, loc_op, expr));

View file

@ -1,7 +1,7 @@
use std::path::Path;
use crate::procedure::References;
use crate::scope::Scope;
use crate::scope::{ModuleLookup, Scope, SymbolLookup};
use bumpalo::Bump;
use roc_collections::{MutMap, VecSet};
use roc_module::ident::{Ident, ModuleName};
@ -74,7 +74,7 @@ impl<'a> Env<'a> {
module_name_str: &str,
ident: &str,
region: Region,
) -> Result<Symbol, RuntimeError> {
) -> Result<SymbolLookup, RuntimeError> {
debug_assert!(
!module_name_str.is_empty(),
"Called env.qualified_lookup with an unqualified ident: {ident:?}"
@ -82,8 +82,10 @@ impl<'a> Env<'a> {
let module_name = ModuleName::from(module_name_str);
match scope.modules.get_id(&module_name) {
Some(module_id) => self.qualified_lookup_help(scope, module_id, ident, region),
match scope.modules.lookup(&module_name) {
Some(lookedup_module) => {
self.qualified_lookup_help(scope, lookedup_module, ident, region)
}
None => Err(RuntimeError::ModuleNotImported {
module_name: module_name.clone(),
imported_modules: scope
@ -106,11 +108,11 @@ impl<'a> Env<'a> {
module_id: ModuleId,
ident: &str,
region: Region,
) -> Result<Symbol, RuntimeError> {
if !scope.modules.has_id(module_id) {
Err(self.module_exists_but_not_imported(scope, module_id, region))
) -> Result<SymbolLookup, RuntimeError> {
if let Some(module) = scope.modules.lookup_by_id(&module_id) {
self.qualified_lookup_help(scope, module, ident, region)
} else {
self.qualified_lookup_help(scope, module_id, ident, region)
Err(self.module_exists_but_not_imported(scope, module_id, region))
}
}
@ -118,18 +120,18 @@ impl<'a> Env<'a> {
fn qualified_lookup_help(
&mut self,
scope: &Scope,
module_id: ModuleId,
module: ModuleLookup,
ident: &str,
region: Region,
) -> Result<Symbol, RuntimeError> {
) -> Result<SymbolLookup, RuntimeError> {
let is_type_name = ident.starts_with(|c: char| c.is_uppercase());
// You can do qualified lookups on your own module, e.g.
// if I'm in the Foo module, I can do a `Foo.bar` lookup.
if module_id == self.home {
if module.id == self.home {
match scope.locals.ident_ids.get_id(ident) {
Some(ident_id) => {
let symbol = Symbol::new(module_id, ident_id);
let symbol = Symbol::new(module.id, ident_id);
if is_type_name {
self.qualified_type_lookups.insert(symbol);
@ -137,7 +139,7 @@ impl<'a> Env<'a> {
self.qualified_value_lookups.insert(symbol);
}
Ok(symbol)
Ok(SymbolLookup::no_params(symbol))
}
None => {
let error = RuntimeError::LookupNotInScope {
@ -157,10 +159,10 @@ impl<'a> Env<'a> {
}
}
} else {
match self.dep_idents.get(&module_id) {
match self.dep_idents.get(&module.id) {
Some(exposed_ids) => match exposed_ids.get_id(ident) {
Some(ident_id) => {
let symbol = Symbol::new(module_id, ident_id);
let symbol = Symbol::new(module.id, ident_id);
if is_type_name {
self.qualified_type_lookups.insert(symbol);
@ -168,12 +170,12 @@ impl<'a> Env<'a> {
self.qualified_value_lookups.insert(symbol);
}
Ok(symbol)
Ok(module.into_symbol(symbol))
}
None => Err(RuntimeError::ValueNotExposed {
module_name: self
.qualified_module_ids
.get_name(module_id)
.get_name(module.id)
.expect("Module ID known, but not in the module IDs somehow")
.as_inner()
.clone(),
@ -182,7 +184,7 @@ impl<'a> Env<'a> {
exposed_values: exposed_ids.exposed_values(),
}),
},
_ => Err(self.module_exists_but_not_imported(scope, module_id, region)),
_ => Err(self.module_exists_but_not_imported(scope, module.id, region)),
}
}
}

View file

@ -7,9 +7,10 @@ use crate::num::{
finish_parsing_base, finish_parsing_float, finish_parsing_num, float_expr_from_result,
int_expr_from_result, num_expr_from_result, FloatBound, IntBound, NumBound,
};
use crate::params_in_abilities_unimplemented;
use crate::pattern::{canonicalize_pattern, BindingsFromPattern, Pattern, PermitShadows};
use crate::procedure::{QualifiedReference, References};
use crate::scope::Scope;
use crate::scope::{Scope, SymbolLookup};
use crate::traverse::{walk_expr, Visitor};
use roc_collections::soa::Index;
use roc_collections::{SendMap, VecMap, VecSet};
@ -17,7 +18,7 @@ use roc_error_macros::internal_error;
use roc_module::called_via::CalledVia;
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
use roc_module::low_level::LowLevel;
use roc_module::symbol::Symbol;
use roc_module::symbol::{ModuleId, Symbol};
use roc_parse::ast::{self, Defs, PrecedenceConflict, StrLiteral};
use roc_parse::ident::Accessor;
use roc_parse::pattern::PatternType::*;
@ -107,6 +108,12 @@ pub enum Expr {
// Lookups
Var(Symbol, Variable),
/// Like Var, but from a module with params
ParamsVar {
symbol: Symbol,
params: Symbol,
var: Variable,
},
AbilityMember(
/// Actual member name
Symbol,
@ -177,6 +184,9 @@ pub enum Expr {
elems: Vec<(Variable, Box<Loc<Expr>>)>,
},
/// Module params expression in import
ImportParams(ModuleId, Region, Option<(Variable, Box<Expr>)>),
/// The "crash" keyword
Crash {
msg: Box<Loc<Expr>>,
@ -308,6 +318,11 @@ impl Expr {
Self::SingleQuote(..) => Category::Character,
Self::List { .. } => Category::List,
&Self::Var(sym, _) => Category::Lookup(sym),
&Self::ParamsVar {
symbol,
params: _,
var: _,
} => Category::Lookup(symbol),
&Self::AbilityMember(sym, _, _) => Category::Lookup(sym),
Self::When { .. } => Category::When,
Self::If { .. } => Category::If,
@ -324,6 +339,8 @@ impl Expr {
Self::RecordAccessor(data) => Category::Accessor(data.field.clone()),
Self::TupleAccess { index, .. } => Category::TupleAccess(*index),
Self::RecordUpdate { .. } => Category::Record,
Self::ImportParams(_, _, Some((_, expr))) => expr.category(),
Self::ImportParams(_, _, None) => Category::Unknown,
Self::Tag {
name, arguments, ..
} => Category::TagApply {
@ -631,34 +648,7 @@ pub fn canonicalize_expr<'a>(
(answer, Output::default())
}
ast::Expr::Record(fields) => {
if fields.is_empty() {
(EmptyRecord, Output::default())
} else {
match canonicalize_fields(env, var_store, scope, region, fields.items) {
Ok((can_fields, output)) => (
Record {
record_var: var_store.fresh(),
fields: can_fields,
},
output,
),
Err(CanonicalizeRecordProblem::InvalidOptionalValue {
field_name,
field_region,
record_region,
}) => (
Expr::RuntimeError(roc_problem::can::RuntimeError::InvalidOptionalValue {
field_name,
field_region,
record_region,
}),
Output::default(),
),
}
}
}
ast::Expr::Record(fields) => canonicalize_record(env, var_store, scope, region, *fields),
ast::Expr::RecordUpdate {
fields,
update: loc_update,
@ -1030,6 +1020,9 @@ pub fn canonicalize_expr<'a>(
ast::Expr::Backpassing(_, _, _) => {
internal_error!("Backpassing should have been desugared by now")
}
ast::Expr::RecordUpdater(_) => {
internal_error!("Record updater should have been desugared by now")
}
ast::Expr::Closure(loc_arg_patterns, loc_body_expr) => {
let (closure_data, output) =
canonicalize_closure(env, var_store, scope, loc_arg_patterns, loc_body_expr, None);
@ -1127,7 +1120,9 @@ pub fn canonicalize_expr<'a>(
output,
)
}
ast::Expr::TaskAwaitBang(..) => internal_error!("a Expr::TaskAwaitBang expression was not completely removed in desugar_value_def_suffixed"),
ast::Expr::TrySuffix { .. } => internal_error!(
"a Expr::TrySuffix expression was not completely removed in desugar_value_def_suffixed"
),
ast::Expr::Tag(tag) => {
let variant_var = var_store.fresh();
let ext_var = var_store.fresh();
@ -1379,7 +1374,10 @@ pub fn canonicalize_expr<'a>(
use roc_problem::can::RuntimeError::*;
let sub_region = Region::span_across(&loc_name.region, &loc_value.region);
let problem = OptionalFieldInRecordBuilder {record: region, field: sub_region };
let problem = OptionalFieldInRecordBuilder {
record: region,
field: sub_region,
};
env.problem(Problem::RuntimeError(problem.clone()));
(RuntimeError(problem), Output::default())
@ -1452,6 +1450,42 @@ pub fn canonicalize_expr<'a>(
)
}
pub fn canonicalize_record<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
scope: &mut Scope,
region: Region,
fields: ast::Collection<'a, Loc<ast::AssignedField<'a, ast::Expr<'a>>>>,
) -> (Expr, Output) {
use Expr::*;
if fields.is_empty() {
(EmptyRecord, Output::default())
} else {
match canonicalize_fields(env, var_store, scope, region, fields.items) {
Ok((can_fields, output)) => (
Record {
record_var: var_store.fresh(),
fields: can_fields,
},
output,
),
Err(CanonicalizeRecordProblem::InvalidOptionalValue {
field_name,
field_region,
record_region,
}) => (
Expr::RuntimeError(roc_problem::can::RuntimeError::InvalidOptionalValue {
field_name,
field_region,
record_region,
}),
Output::default(),
),
}
}
}
pub fn canonicalize_closure<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
@ -1881,19 +1915,19 @@ fn canonicalize_var_lookup(
// Since module_name was empty, this is an unqualified var.
// Look it up in scope!
match scope.lookup_str(ident, region) {
Ok(symbol) => {
Ok(lookup) => {
output
.references
.insert_value_lookup(symbol, QualifiedReference::Unqualified);
.insert_value_lookup(lookup.symbol, QualifiedReference::Unqualified);
if scope.abilities_store.is_ability_member_name(symbol) {
if scope.abilities_store.is_ability_member_name(lookup.symbol) {
AbilityMember(
symbol,
params_in_abilities_unimplemented!(lookup),
Some(scope.abilities_store.fresh_specialization_id()),
var_store.fresh(),
)
} else {
Var(symbol, var_store.fresh())
lookup_to_expr(lookup, var_store.fresh())
}
}
Err(problem) => {
@ -1906,19 +1940,19 @@ fn canonicalize_var_lookup(
// Since module_name was nonempty, this is a qualified var.
// Look it up in the env!
match env.qualified_lookup(scope, module_name, ident, region) {
Ok(symbol) => {
Ok(lookup) => {
output
.references
.insert_value_lookup(symbol, QualifiedReference::Qualified);
.insert_value_lookup(lookup.symbol, QualifiedReference::Qualified);
if scope.abilities_store.is_ability_member_name(symbol) {
if scope.abilities_store.is_ability_member_name(lookup.symbol) {
AbilityMember(
symbol,
params_in_abilities_unimplemented!(lookup),
Some(scope.abilities_store.fresh_specialization_id()),
var_store.fresh(),
)
} else {
Var(symbol, var_store.fresh())
lookup_to_expr(lookup, var_store.fresh())
}
}
Err(problem) => {
@ -1936,6 +1970,24 @@ fn canonicalize_var_lookup(
(can_expr, output)
}
fn lookup_to_expr(
SymbolLookup {
symbol,
module_params: params,
}: SymbolLookup,
var: Variable,
) -> Expr {
if let Some(params) = params {
Expr::ParamsVar {
symbol,
params,
var,
}
} else {
Expr::Var(symbol, var)
}
}
/// Currently uses the heuristic of "only inline if it's a builtin"
pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
use Expr::*;
@ -1954,6 +2006,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
| other @ RecordAccessor { .. }
| other @ RecordUpdate { .. }
| other @ Var(..)
| other @ ParamsVar { .. }
| other @ AbilityMember(..)
| other @ RunLowLevel { .. }
| other @ TypedHole { .. }
@ -2217,6 +2270,14 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
);
}
ImportParams(module_id, region, Some((var, expr))) => ImportParams(
module_id,
region,
Some((var, Box::new(inline_calls(var_store, *expr)))),
),
ImportParams(module_id, region, None) => ImportParams(module_id, region, None),
RecordAccess {
record_var,
ext_var,
@ -2407,6 +2468,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
| ast::Expr::Num(_)
| ast::Expr::NonBase10Int { .. }
| ast::Expr::AccessorFunction(_)
| ast::Expr::RecordUpdater(_)
| ast::Expr::Crash
| ast::Expr::Underscore(_)
| ast::Expr::MalformedIdent(_, _)
@ -2460,7 +2522,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
ast::Expr::TupleAccess(sub_expr, _)
| ast::Expr::ParensAround(sub_expr)
| ast::Expr::RecordAccess(sub_expr, _)
| ast::Expr::TaskAwaitBang(sub_expr) => is_valid_interpolation(sub_expr),
| ast::Expr::TrySuffix { expr: sub_expr, .. } => is_valid_interpolation(sub_expr),
ast::Expr::Apply(loc_expr, args, _called_via) => {
is_valid_interpolation(&loc_expr.value)
&& args
@ -3141,6 +3203,11 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
while let Some(expr) = stack.pop() {
match expr {
Expr::Var(symbol, var)
| Expr::ParamsVar {
symbol,
params: _,
var,
}
| Expr::RecordUpdate {
symbol,
record_var: var,
@ -3245,6 +3312,9 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
Expr::Tuple { elems, .. } => {
stack.extend(elems.iter().map(|(_, elem)| &elem.value));
}
Expr::ImportParams(_, _, Some((_, expr))) => {
stack.push(expr);
}
Expr::Expect {
loc_continuation, ..
}
@ -3271,6 +3341,7 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
| Expr::EmptyRecord
| Expr::TypedHole(_)
| Expr::RuntimeError(_)
| Expr::ImportParams(_, _, None)
| Expr::OpaqueWrapFunction(_) => {}
}
}

View file

@ -5,9 +5,11 @@ use crate::annotation::{canonicalize_annotation, AnnotationFor};
use crate::def::{canonicalize_defs, report_unused_imports, Def};
use crate::env::Env;
use crate::expr::{
ClosureData, DbgLookup, Declarations, ExpectLookup, Expr, Output, PendingDerives,
AnnotatedMark, ClosureData, DbgLookup, Declarations, ExpectLookup, Expr, Output, PendingDerives,
};
use crate::pattern::{
canonicalize_record_destructure, BindingsFromPattern, Pattern, PermitShadows,
};
use crate::pattern::{BindingsFromPattern, Pattern};
use crate::procedure::References;
use crate::scope::Scope;
use bumpalo::Bump;
@ -17,7 +19,7 @@ use roc_module::ident::Ident;
use roc_module::ident::Lowercase;
use roc_module::symbol::{IdentIds, IdentIdsByModule, ModuleId, PackageModuleIds, Symbol};
use roc_parse::ast::{Defs, TypeAnnotation};
use roc_parse::header::HeaderType;
use roc_parse::header::{HeaderType, ModuleParams};
use roc_parse::pattern::PatternType;
use roc_problem::can::{Problem, RuntimeError};
use roc_region::all::{Loc, Region};
@ -135,6 +137,7 @@ pub struct Module {
pub abilities_store: PendingAbilitiesStore,
pub loc_expects: VecMap<Region, Vec<ExpectLookup>>,
pub loc_dbgs: VecMap<Symbol, DbgLookup>,
pub params_pattern: Option<(Variable, AnnotatedMark, Loc<Pattern>)>,
}
#[derive(Debug, Default)]
@ -148,6 +151,7 @@ pub struct RigidVariables {
pub struct ModuleOutput {
pub aliases: MutMap<Symbol, Alias>,
pub rigid_variables: RigidVariables,
pub params_pattern: Option<(Variable, AnnotatedMark, Loc<Pattern>)>,
pub declarations: Declarations,
pub exposed_imports: MutMap<Symbol, Region>,
pub exposed_symbols: VecSet<Symbol>,
@ -181,7 +185,7 @@ fn has_no_implementation(expr: &Expr) -> bool {
pub fn canonicalize_module_defs<'a>(
arena: &'a Bump,
loc_defs: &'a mut Defs<'a>,
header_type: &roc_parse::header::HeaderType,
header_type: &'a roc_parse::header::HeaderType,
home: ModuleId,
module_path: &'a str,
src: &'a str,
@ -197,6 +201,7 @@ pub fn canonicalize_module_defs<'a>(
opt_shorthand: Option<&'a str>,
) -> ModuleOutput {
let mut can_exposed_imports = MutMap::default();
let mut scope = Scope::new(
home,
qualified_module_ids
@ -235,7 +240,15 @@ pub fn canonicalize_module_defs<'a>(
// operators, and then again on *their* nested operators, ultimately applying the
// rules multiple times unnecessarily.
crate::desugar::desugar_defs_node_values(arena, loc_defs, src, &mut None, module_path, true);
crate::desugar::desugar_defs_node_values(
arena,
loc_defs,
src,
&mut None,
module_path,
true,
&mut env.problems,
);
let mut rigid_variables = RigidVariables::default();
@ -286,9 +299,42 @@ pub fn canonicalize_module_defs<'a>(
}
}
let mut output = Output::default();
let params_pattern = header_type.get_params().as_ref().map(
|ModuleParams {
pattern,
before_arrow: _,
after_arrow: _,
}| {
let can_pattern = canonicalize_record_destructure(
&mut env,
var_store,
&mut scope,
&mut output,
PatternType::ModuleParams,
&pattern.value,
pattern.region,
PermitShadows(false),
);
let loc_pattern = Loc::at(pattern.region, can_pattern);
for (symbol, _) in BindingsFromPattern::new(&loc_pattern) {
env.top_level_symbols.insert(symbol);
}
(
var_store.fresh(),
AnnotatedMark::new(var_store),
loc_pattern,
)
},
);
let (defs, output, symbols_introduced, imports_introduced) = canonicalize_defs(
&mut env,
Output::default(),
output,
var_store,
&mut scope,
loc_defs,
@ -676,6 +722,7 @@ pub fn canonicalize_module_defs<'a>(
scope,
aliases,
rigid_variables,
params_pattern,
declarations,
referenced_values,
exposed_imports: can_exposed_imports,
@ -969,6 +1016,7 @@ fn fix_values_captured_in_closure_expr(
| SingleQuote(..)
| IngestedFile(..)
| Var(..)
| ParamsVar { .. }
| AbilityMember(..)
| EmptyRecord
| TypedHole { .. }
@ -1080,6 +1128,12 @@ fn fix_values_captured_in_closure_expr(
}
}
ImportParams(_, _, Some((_, expr))) => {
fix_values_captured_in_closure_expr(expr, no_capture_symbols, closure_captures);
}
ImportParams(_, _, None) => {}
Tuple { elems, .. } => {
for (_var, expr) in elems.iter_mut() {
fix_values_captured_in_closure_expr(

View file

@ -623,132 +623,16 @@ pub fn canonicalize_pattern<'a>(
}
}
RecordDestructure(patterns) => {
let ext_var = var_store.fresh();
let whole_var = var_store.fresh();
let mut destructs = Vec::with_capacity(patterns.len());
let mut opt_erroneous = None;
for loc_pattern in patterns.iter() {
match loc_pattern.value {
Identifier { ident: label } => {
match scope.introduce(label.into(), region) {
Ok(symbol) => {
output.references.insert_bound(symbol);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Required,
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
RequiredField(label, loc_guard) => {
// a guard does not introduce the label into scope!
let symbol =
scope.scopeless_symbol(&Ident::from(label), loc_pattern.region);
let can_guard = canonicalize_pattern(
env,
var_store,
scope,
output,
pattern_type,
&loc_guard.value,
loc_guard.region,
permit_shadows,
);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Guard(var_store.fresh(), can_guard),
},
});
}
OptionalField(label, loc_default) => {
// an optional DOES introduce the label into scope!
match scope.introduce(label.into(), region) {
Ok(symbol) => {
let (can_default, expr_output) = canonicalize_expr(
env,
var_store,
scope,
loc_default.region,
&loc_default.value,
);
// an optional field binds the symbol!
output.references.insert_bound(symbol);
output.union(expr_output);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Optional(var_store.fresh(), can_default),
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
_ => unreachable!("Any other pattern should have given a parse error"),
}
}
// If we encountered an erroneous pattern (e.g. one with shadowing),
// use the resulting RuntimeError. Otherwise, return a successful record destructure.
opt_erroneous.unwrap_or(Pattern::RecordDestructure {
whole_var,
ext_var,
destructs,
})
}
RecordDestructure(patterns) => canonicalize_record_destructure(
env,
var_store,
scope,
output,
pattern_type,
patterns,
region,
permit_shadows,
),
RequiredField(_name, _loc_pattern) => {
unreachable!("should have been handled in RecordDestructure");
@ -894,6 +778,144 @@ pub fn canonicalize_pattern<'a>(
}
}
#[allow(clippy::too_many_arguments)]
pub fn canonicalize_record_destructure<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
scope: &mut Scope,
output: &mut Output,
pattern_type: PatternType,
patterns: &ast::Collection<Loc<ast::Pattern<'a>>>,
region: Region,
permit_shadows: PermitShadows,
) -> Pattern {
use ast::Pattern::*;
let ext_var = var_store.fresh();
let whole_var = var_store.fresh();
let mut destructs = Vec::with_capacity(patterns.len());
let mut opt_erroneous = None;
for loc_pattern in patterns.iter() {
match loc_pattern.value {
Identifier { ident: label } => {
match scope.introduce(label.into(), region) {
Ok(symbol) => {
output.references.insert_bound(symbol);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Required,
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
RequiredField(label, loc_guard) => {
// a guard does not introduce the label into scope!
let symbol = scope.scopeless_symbol(&Ident::from(label), loc_pattern.region);
let can_guard = canonicalize_pattern(
env,
var_store,
scope,
output,
pattern_type,
&loc_guard.value,
loc_guard.region,
permit_shadows,
);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Guard(var_store.fresh(), can_guard),
},
});
}
OptionalField(label, loc_default) => {
// an optional DOES introduce the label into scope!
match scope.introduce(label.into(), region) {
Ok(symbol) => {
let (can_default, expr_output) = canonicalize_expr(
env,
var_store,
scope,
loc_default.region,
&loc_default.value,
);
// an optional field binds the symbol!
output.references.insert_bound(symbol);
output.union(expr_output);
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
label: Lowercase::from(label),
symbol,
typ: DestructType::Optional(var_store.fresh(), can_default),
},
});
}
Err((shadowed_symbol, shadow, new_symbol)) => {
env.problem(Problem::RuntimeError(RuntimeError::Shadowing {
original_region: shadowed_symbol.region,
shadow: shadow.clone(),
kind: ShadowKind::Variable,
}));
// No matter what the other patterns
// are, we're definitely shadowed and will
// get a runtime exception as soon as we
// encounter the first bad pattern.
opt_erroneous = Some(Pattern::Shadowed(
shadowed_symbol.region,
shadow,
new_symbol,
));
}
};
}
_ => unreachable!("Any other pattern should have given a parse error"),
}
}
// If we encountered an erroneous pattern (e.g. one with shadowing),
// use the resulting RuntimeError. Otherwise, return a successful record destructure.
opt_erroneous.unwrap_or(Pattern::RecordDestructure {
whole_var,
ext_var,
destructs,
})
}
/// When we detect an unsupported pattern type (e.g. 5 = 1 + 2 is unsupported because you can't
/// assign to Int patterns), report it to Env and return an UnsupportedPattern runtime error pattern.
fn unsupported_pattern(env: &mut Env, pattern_type: PatternType, region: Region) -> Pattern {

View file

@ -1,8 +1,8 @@
use roc_collections::{VecMap, VecSet};
use roc_error_macros::internal_error;
use roc_module::ident::{Ident, ModuleName};
use roc_module::symbol::{IdentId, IdentIds, ModuleId, ScopeModules, Symbol};
use roc_problem::can::RuntimeError;
use roc_module::symbol::{IdentId, IdentIds, ModuleId, ModuleIds, Symbol};
use roc_problem::can::{RuntimeError, ScopeModuleSource};
use roc_region::all::{Loc, Region};
use roc_types::subs::Variable;
use roc_types::types::{Alias, AliasKind, AliasVar, Type};
@ -76,7 +76,7 @@ impl Scope {
}
}
pub fn lookup(&self, ident: &Ident, region: Region) -> Result<Symbol, RuntimeError> {
pub fn lookup(&self, ident: &Ident, region: Region) -> Result<SymbolLookup, RuntimeError> {
self.lookup_str(ident.as_str(), region)
}
@ -91,7 +91,7 @@ impl Scope {
.push(("Set".into(), Symbol::SET_SET, Region::zero()));
}
pub fn lookup_str(&self, ident: &str, region: Region) -> Result<Symbol, RuntimeError> {
pub fn lookup_str(&self, ident: &str, region: Region) -> Result<SymbolLookup, RuntimeError> {
use ContainsIdent::*;
match self.scope_contains_ident(ident) {
@ -205,14 +205,19 @@ impl Scope {
}
}
fn has_imported_symbol(&self, ident: &str) -> Option<(Symbol, Region)> {
for (import, shadow, original_region) in self.imported_symbols.iter() {
if ident == import.as_str() {
return Some((*shadow, *original_region));
}
}
None
fn has_imported_symbol(&self, ident: &str) -> Option<(SymbolLookup, Region)> {
self.imported_symbols
.iter()
.find_map(|(import, symbol, original_region)| {
if ident == import.as_str() {
match self.modules.lookup_by_id(&symbol.module_id()) {
Some(module) => Some((module.into_symbol(*symbol), *original_region)),
None => Some((SymbolLookup::no_params(*symbol), *original_region)),
}
} else {
None
}
})
}
/// Is an identifier in scope, either in the locals or imports
@ -229,7 +234,7 @@ impl Scope {
ContainsIdent::InScope(original_symbol, original_region) => {
// the ident is already in scope; up to the caller how to handle that
// (usually it's shadowing, but it is valid to shadow ability members)
Err((original_symbol, original_region))
Err((original_symbol.symbol, original_region))
}
ContainsIdent::NotPresent => {
// We know nothing about this ident yet; introduce it to the scope
@ -389,7 +394,13 @@ impl Scope {
region: Region,
) -> Result<(), (Symbol, Region)> {
match self.scope_contains_ident(ident.as_str()) {
ContainsIdent::InScope(symbol, region) => Err((symbol, region)),
ContainsIdent::InScope(
SymbolLookup {
symbol,
module_params: _,
},
region,
) => Err((symbol, region)),
ContainsIdent::NotPresent | ContainsIdent::NotInScope(_) => {
self.imported_symbols.push((ident, symbol, region));
Ok(())
@ -534,7 +545,7 @@ pub fn create_alias(
#[derive(Debug)]
enum ContainsIdent {
InScope(Symbol, Region),
InScope(SymbolLookup, Region),
NotInScope(IdentId),
NotPresent,
}
@ -561,7 +572,7 @@ impl ScopedIdentIds {
fn has_in_scope(&self, ident: &Ident) -> Option<(Symbol, Region)> {
match self.contains_ident(ident.as_str()) {
ContainsIdent::InScope(symbol, region) => Some((symbol, region)),
ContainsIdent::InScope(symbol, region) => Some((symbol.symbol, region)),
ContainsIdent::NotInScope(_) | ContainsIdent::NotPresent => None,
}
}
@ -574,7 +585,10 @@ impl ScopedIdentIds {
for ident_id in self.ident_ids.get_id_many(ident) {
let index = ident_id.index();
if self.in_scope[index] {
return InScope(Symbol::new(self.home, ident_id), self.regions[index]);
return InScope(
SymbolLookup::no_params(Symbol::new(self.home, ident_id)),
self.regions[index],
);
} else {
result = NotInScope(ident_id)
}
@ -646,6 +660,149 @@ impl ScopedIdentIds {
}
}
#[derive(Debug, Clone)]
pub struct ScopeModules {
/// The ids of all modules in scope
ids: Vec<ModuleId>,
/// The alias or original name of each module in scope
names: Vec<ModuleName>,
/// Why is this module in scope?
sources: Vec<ScopeModuleSource>,
/// The params of a module if any
params: Vec<Option<Symbol>>,
}
impl ScopeModules {
pub fn new(home_id: ModuleId, home_name: ModuleName) -> Self {
let builtins = ModuleIds::default();
let builtins_iter = builtins.iter();
let count = builtins_iter.len();
let mut ids = Vec::with_capacity(count + 1);
let mut names = Vec::with_capacity(count + 1);
let mut sources = vec![ScopeModuleSource::Builtin; count];
let mut params = vec![None; count];
for (module_id, module_name) in builtins_iter {
ids.push(module_id);
names.push(module_name.clone());
}
if !home_id.is_builtin() {
ids.push(home_id);
names.push(home_name);
sources.push(ScopeModuleSource::Current);
params.push(None);
}
Self {
ids,
names,
sources,
params,
}
}
pub fn lookup(&self, module_name: &ModuleName) -> Option<ModuleLookup> {
self.names
.iter()
.position(|name| name == module_name)
.map(|index| ModuleLookup {
id: self.ids[index],
params: self.params[index],
})
}
pub fn lookup_by_id(&self, module_id: &ModuleId) -> Option<ModuleLookup> {
self.ids
.iter()
.position(|id| id == module_id)
.map(|index| ModuleLookup {
id: self.ids[index],
params: self.params[index],
})
}
pub fn available_names(&self) -> impl Iterator<Item = &ModuleName> {
self.names.iter()
}
pub fn insert(
&mut self,
module_name: ModuleName,
module_id: ModuleId,
params_symbol: Option<Symbol>,
region: Region,
) -> Result<(), ScopeModuleSource> {
if let Some(index) = self.names.iter().position(|name| name == &module_name) {
if self.ids[index] == module_id {
return Ok(());
}
return Err(self.sources[index]);
}
self.ids.push(module_id);
self.names.push(module_name);
self.sources.push(ScopeModuleSource::Import(region));
self.params.push(params_symbol);
Ok(())
}
pub fn len(&self) -> usize {
debug_assert_eq!(self.ids.len(), self.names.len());
debug_assert_eq!(self.ids.len(), self.sources.len());
debug_assert_eq!(self.ids.len(), self.params.len());
self.ids.len()
}
pub fn is_empty(&self) -> bool {
self.ids.is_empty()
}
pub fn truncate(&mut self, len: usize) {
self.ids.truncate(len);
self.names.truncate(len);
self.sources.truncate(len);
self.params.truncate(len);
}
}
#[derive(Debug, Clone)]
pub struct SymbolLookup {
pub symbol: Symbol,
pub module_params: Option<Symbol>,
}
impl SymbolLookup {
pub fn new(symbol: Symbol, params: Option<Symbol>) -> Self {
Self {
symbol,
module_params: params,
}
}
pub fn no_params(symbol: Symbol) -> Self {
Self::new(symbol, None)
}
}
pub struct ModuleLookup {
pub id: ModuleId,
pub params: Option<Symbol>,
}
impl ModuleLookup {
pub fn into_symbol(&self, symbol: Symbol) -> SymbolLookup {
debug_assert_eq!(symbol.module_id(), self.id);
SymbolLookup {
symbol,
module_params: self.params,
}
}
}
#[cfg(test)]
mod test {
use super::*;
@ -701,7 +858,7 @@ mod test {
let lookup = scope.lookup(&ident, Region::zero()).unwrap();
assert_eq!(first, lookup);
assert_eq!(first, lookup.symbol);
}
#[test]
@ -857,6 +1014,6 @@ mod test {
let lookup = scope.lookup(&ident, Region::zero()).unwrap();
assert_eq!(symbol, lookup);
assert_eq!(symbol, lookup.symbol);
}
}

View file

@ -6,7 +6,7 @@ use roc_error_macros::internal_error;
use roc_module::called_via::CalledVia;
use roc_module::ident::ModuleName;
use roc_parse::ast::Expr::{self, *};
use roc_parse::ast::{is_expr_suffixed, Pattern, TypeAnnotation, ValueDef, WhenBranch};
use roc_parse::ast::{is_expr_suffixed, Pattern, TryTarget, TypeAnnotation, ValueDef, WhenBranch};
use roc_region::all::{Loc, Region};
use std::cell::Cell;
@ -34,14 +34,17 @@ pub enum EUnwrapped<'a> {
/// e.g. x = first! (second! 42)
/// The first unwrap will produce
/// `UnwrappedDefExpr<first (second! 42)>`
UnwrappedDefExpr(&'a Loc<Expr<'a>>),
UnwrappedDefExpr {
loc_expr: &'a Loc<Expr<'a>>,
target: TryTarget,
},
/// Suffixed sub expression
/// e.g. x = first! (second! 42)
/// In this example, the second unwrap (after unwrapping the top level `first!`) will produce
/// `UnwrappedSubExpr<{ sub_arg: second 42, sub_pat: #!0_arg, sub_new: #!0_arg }>`
UnwrappedSubExpr {
/// the unwrapped expression argument for Task.await
/// the unwrapped expression argument for `try` functions
sub_arg: &'a Loc<Expr<'a>>,
/// the pattern for the closure
@ -49,6 +52,9 @@ pub enum EUnwrapped<'a> {
/// the expression to replace the unwrapped
sub_new: &'a Loc<Expr<'a>>,
/// The type of the target for the suffix, e.g. a Task or Result
target: TryTarget,
},
/// Malformed use of the suffix
@ -59,12 +65,16 @@ fn init_unwrapped_err<'a>(
arena: &'a Bump,
unwrapped_expr: &'a Loc<Expr<'a>>,
maybe_def_pat: Option<&'a Loc<Pattern<'a>>>,
target: TryTarget,
) -> Result<&'a Loc<Expr<'a>>, EUnwrapped<'a>> {
match maybe_def_pat {
Some(..) => {
// we have a def pattern, so no need to generate a new pattern
// as this should only be created in the first call from a def
Err(EUnwrapped::UnwrappedDefExpr(unwrapped_expr))
Err(EUnwrapped::UnwrappedDefExpr {
loc_expr: unwrapped_expr,
target,
})
}
None => {
// Provide an intermediate answer expression and pattern when unwrapping a
@ -87,13 +97,14 @@ fn init_unwrapped_err<'a>(
sub_arg: unwrapped_expr,
sub_pat,
sub_new,
target,
})
}
}
}
/// Descend through the AST and unwrap each suffixed expression
/// when an expression is unwrapped, we apply a `Task.await` and
/// when an expression is unwrapped, we apply the appropriate try function and
/// then descend through the AST again until there are no more suffixed
/// expressions, or we hit an error
pub fn unwrap_suffixed_expression<'a>(
@ -103,10 +114,13 @@ pub fn unwrap_suffixed_expression<'a>(
) -> Result<&'a Loc<Expr<'a>>, EUnwrapped<'a>> {
let unwrapped_expression = {
match loc_expr.value {
Expr::TaskAwaitBang(sub_expr) => {
Expr::TrySuffix {
expr: sub_expr,
target,
} => {
let unwrapped_sub_expr = arena.alloc(Loc::at(loc_expr.region, *sub_expr));
init_unwrapped_err(arena, unwrapped_sub_expr, maybe_def_pat)
init_unwrapped_err(arena, unwrapped_sub_expr, maybe_def_pat, target)
}
Expr::Defs(..) => unwrap_suffixed_expression_defs_help(arena, loc_expr, maybe_def_pat),
@ -154,15 +168,22 @@ pub fn unwrap_suffixed_expression<'a>(
.alloc(Loc::at(loc_expr.region, Expect(condition, unwrapped_expr)));
return Ok(new_expect);
}
Err(EUnwrapped::UnwrappedDefExpr(unwrapped_expr)) => {
Err(EUnwrapped::UnwrappedDefExpr {
loc_expr: unwrapped_expr,
target,
}) => {
let new_expect = arena
.alloc(Loc::at(loc_expr.region, Expect(condition, unwrapped_expr)));
Err(EUnwrapped::UnwrappedDefExpr(new_expect))
Err(EUnwrapped::UnwrappedDefExpr {
loc_expr: new_expect,
target,
})
}
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg: unwrapped_expr,
sub_pat,
sub_new,
target,
}) => {
let new_expect = arena
.alloc(Loc::at(loc_expr.region, Expect(condition, unwrapped_expr)));
@ -170,6 +191,7 @@ pub fn unwrap_suffixed_expression<'a>(
sub_arg: new_expect,
sub_pat,
sub_new,
target,
})
}
Err(EUnwrapped::Malformed) => Err(EUnwrapped::Malformed),
@ -208,13 +230,14 @@ pub fn unwrap_suffixed_expression_parens_help<'a>(
));
Ok(new_parens)
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
internal_error!("unreachable, child expressions from ParensAround should generate UnwrappedSubExpr instead");
}
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg,
sub_pat,
sub_new,
target,
}) => {
let new_parens = arena.alloc(Loc::at(
loc_expr.region,
@ -224,6 +247,7 @@ pub fn unwrap_suffixed_expression_parens_help<'a>(
sub_arg,
sub_pat,
sub_new: new_parens,
target,
})
}
Err(err) => Err(err),
@ -247,13 +271,13 @@ pub fn unwrap_suffixed_expression_closure_help<'a>(
let new_closure = arena.alloc(Loc::at(loc_expr.region, Expr::Closure(closure_args, unwrapped_expr)));
Ok(new_closure)
}
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
let new_closure_loc_ret = apply_task_await(arena, loc_expr.region, sub_arg, sub_pat, sub_new, None);
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
let new_closure_loc_ret = apply_try_function(arena, loc_expr.region, sub_arg, sub_pat, sub_new, None, target);
let new_closure = arena.alloc(Loc::at(loc_expr.region, Expr::Closure(closure_args, new_closure_loc_ret)));
Ok(new_closure)
}
Err(err) => {
debug_assert!(false,"the closure Defs was malformd, got {:#?}", err);
debug_assert!(false,"the closure Defs was malformed, got {:#?}", err);
Err(EUnwrapped::Malformed)
}
}
@ -278,22 +302,22 @@ pub fn unwrap_suffixed_expression_apply_help<'a>(
Ok(new_arg) => {
*arg = new_arg;
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
internal_error!("unreachable, unwrapped arg cannot be def expression as `None` was passed as pattern");
}
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new: new_arg }) => {
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new: new_arg, target }) => {
*arg = new_arg;
let new_apply = arena.alloc(Loc::at(loc_expr.region, Apply(function, local_args, called_via)));
return Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new: new_apply});
return Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new: new_apply, target });
}
Err(err) => return Err(err),
}
}
// special case for when our Apply function is a suffixed Var (but not multiple suffixed)
if let Expr::TaskAwaitBang(sub_expr) = function.value {
if let Expr::TrySuffix { expr: sub_expr, target } = function.value {
let unwrapped_function = arena.alloc(Loc::at(
loc_expr.region,
*sub_expr,
@ -301,7 +325,7 @@ pub fn unwrap_suffixed_expression_apply_help<'a>(
let new_apply = arena.alloc(Loc::at(loc_expr.region, Expr::Apply(unwrapped_function, local_args, called_via)));
return init_unwrapped_err(arena, new_apply, maybe_def_pat);
return init_unwrapped_err(arena, new_apply, maybe_def_pat, target);
}
// function is another expression
@ -310,15 +334,14 @@ pub fn unwrap_suffixed_expression_apply_help<'a>(
let new_apply = arena.alloc(Loc::at(loc_expr.region, Expr::Apply(new_function, local_args, called_via)));
Ok(new_apply)
}
Err(EUnwrapped::UnwrappedDefExpr(unwrapped_function)) => {
Err(EUnwrapped::UnwrappedDefExpr { loc_expr: unwrapped_function, target }) => {
let new_apply = arena.alloc(Loc::at(loc_expr.region, Expr::Apply(unwrapped_function, local_args, called_via)));
Err(EUnwrapped::UnwrappedDefExpr(new_apply))
Err(EUnwrapped::UnwrappedDefExpr { loc_expr: new_apply, target })
}
Err(EUnwrapped::UnwrappedSubExpr { sub_arg: unwrapped_function, sub_pat, sub_new }) => {
Err(EUnwrapped::UnwrappedSubExpr { sub_arg: unwrapped_function, sub_pat, sub_new, target }) => {
let new_apply = arena.alloc(Loc::at(loc_expr.region, Expr::Apply(sub_new, local_args, called_via)));
Err(EUnwrapped::UnwrappedSubExpr { sub_arg: unwrapped_function, sub_pat, sub_new:new_apply})
Err(EUnwrapped::UnwrappedSubExpr { sub_arg: unwrapped_function, sub_pat, sub_new:new_apply, target })
}
Err(err) => Err(err)
}
@ -361,21 +384,23 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
return unwrap_suffixed_expression(arena, new_if, maybe_def_pat);
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
internal_error!("unexpected, unwrapped if-then-else Def expr should have intermediate answer as `None` was passed as pattern");
}
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg,
sub_pat,
sub_new,
target,
}) => {
let unwrapped_expression = apply_task_await(
let unwrapped_expression = apply_try_function(
arena,
sub_arg.region,
sub_arg,
sub_pat,
sub_new,
None,
target,
);
let mut new_if_thens = Vec::new_in(arena);
@ -422,13 +447,14 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
return unwrap_suffixed_expression(arena, new_if, maybe_def_pat);
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
internal_error!("unexpected, unwrapped if-then-else Def expr should have intermediate answer as `None` was passed as pattern");
}
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg,
sub_pat,
sub_new,
target,
}) => {
if before.is_empty() {
let mut new_if_thens = Vec::new_in(arena);
@ -445,13 +471,14 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
),
));
let unwrapped_if_then = apply_task_await(
let unwrapped_if_then = apply_try_function(
arena,
sub_arg.region,
sub_arg,
sub_pat,
new_if,
None,
target,
);
return unwrap_suffixed_expression(
@ -473,13 +500,14 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
),
));
let after_if_then = apply_task_await(
let after_if_then = apply_try_function(
arena,
sub_arg.region,
sub_arg,
sub_pat,
after_if,
None,
target,
);
let before_if_then = arena.alloc(Loc::at(
@ -507,16 +535,24 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
Expr::If(if_thens, unwrapped_final_else),
)));
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
internal_error!("unexpected, unwrapped if-then-else Def expr should have intermediate answer as `None` was passed as pattern");
}
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg,
sub_pat,
sub_new,
target,
}) => {
let unwrapped_final_else =
apply_task_await(arena, sub_arg.region, sub_arg, sub_pat, sub_new, None);
let unwrapped_final_else = apply_try_function(
arena,
sub_arg.region,
sub_arg,
sub_pat,
sub_new,
None,
target,
);
let new_if = arena.alloc(Loc::at(
loc_expr.region,
@ -551,7 +587,7 @@ pub fn unwrap_suffixed_expression_when_help<'a>(
if is_expr_suffixed(&branch_loc_expr.value) {
let unwrapped_branch_value = match unwrap_suffixed_expression(arena, branch_loc_expr, None) {
Ok(unwrapped_branch_value) => unwrapped_branch_value,
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => apply_task_await(arena, branch_loc_expr.region, sub_arg, sub_pat, sub_new, None),
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => apply_try_function(arena, branch_loc_expr.region, sub_arg, sub_pat, sub_new, None, target),
Err(..) => return Err(EUnwrapped::Malformed),
};
@ -578,12 +614,12 @@ pub fn unwrap_suffixed_expression_when_help<'a>(
let new_when = arena.alloc(Loc::at(loc_expr.region, Expr::When(unwrapped_condition, branches)));
Ok(new_when)
}
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
let new_when = arena.alloc(Loc::at(loc_expr.region, Expr::When(sub_new, branches)));
let applied_task_await = apply_task_await(arena,loc_expr.region,sub_arg,sub_pat,new_when, None);
let applied_task_await = apply_try_function(arena,loc_expr.region,sub_arg,sub_pat,new_when, None, target);
Ok(applied_task_await)
}
Err(EUnwrapped::UnwrappedDefExpr(..))
Err(EUnwrapped::UnwrappedDefExpr { .. })
| Err(EUnwrapped::Malformed) => Err(EUnwrapped::Malformed)
}
@ -631,7 +667,7 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
current_value_def.replace_expr(unwrapped_def);
local_defs.replace_with_value_def(tag_index, current_value_def, def_expr.region);
}
Err(EUnwrapped::UnwrappedDefExpr(unwrapped_expr)) => {
Err(EUnwrapped::UnwrappedDefExpr { loc_expr: unwrapped_expr, target }) => {
let split_defs = local_defs.split_defs_around(tag_index);
let before_empty = split_defs.before.is_empty();
let after_empty = split_defs.after.is_empty();
@ -640,48 +676,60 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
// We pass None as a def pattern here because it's desugaring of the ret expression
let next_expr = match unwrap_suffixed_expression(arena,loc_ret, None) {
Ok(next_expr) => next_expr,
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
// We need to apply Task.ok here as the defs final expression was unwrapped
apply_task_await(arena,def_expr.region,sub_arg,sub_pat,sub_new, None)
apply_try_function(arena,def_expr.region,sub_arg,sub_pat,sub_new, None, target)
}
Err(EUnwrapped::UnwrappedDefExpr(..)) | Err(EUnwrapped::Malformed) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) | Err(EUnwrapped::Malformed) => {
// TODO handle case when we have maybe_def_pat so can return an unwrapped up
return Err(EUnwrapped::Malformed);
},
};
return unwrap_suffixed_expression(arena, apply_task_await(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr, ann_type), maybe_def_pat);
return unwrap_suffixed_expression(
arena,
apply_try_function(
arena,
def_expr.region,
unwrapped_expr,
def_pattern,
next_expr,
ann_type,
target,
),
maybe_def_pat
);
} else if before_empty {
// NIL before, SOME after -> FIRST DEF
let new_defs = arena.alloc(Loc::at(def_expr.region, Defs(arena.alloc(split_defs.after), loc_ret)));
let next_expr = match unwrap_suffixed_expression(arena,new_defs,maybe_def_pat){
Ok(next_expr) => next_expr,
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
apply_task_await(arena, def_expr.region, sub_arg, sub_pat, sub_new, None)
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
apply_try_function(arena, def_expr.region, sub_arg, sub_pat, sub_new, None, target)
}
Err(EUnwrapped::UnwrappedDefExpr(..)) | Err(EUnwrapped::Malformed) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) | Err(EUnwrapped::Malformed) => {
// TODO handle case when we have maybe_def_pat so can return an unwrapped up
return Err(EUnwrapped::Malformed);
},
};
return unwrap_suffixed_expression(arena, apply_task_await(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr,ann_type), maybe_def_pat);
return unwrap_suffixed_expression(arena, apply_try_function(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr, ann_type, target), maybe_def_pat);
} else if after_empty {
// SOME before, NIL after -> LAST DEF
// We pass None as a def pattern here because it's desugaring of the ret expression
match unwrap_suffixed_expression(arena,loc_ret,None){
Ok(new_loc_ret) => {
let applied_task_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
let applied_task_await = apply_try_function(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type, target);
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_task_await)));
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
},
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
let new_loc_ret = apply_task_await(arena,def_expr.region,sub_arg,sub_pat,sub_new, None);
let applied_task_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
let new_loc_ret = apply_try_function(arena,def_expr.region,sub_arg,sub_pat,sub_new, None, target);
let applied_task_await = apply_try_function(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type, target);
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_task_await)));
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
// TODO confirm this is correct with test case
return Err(EUnwrapped::Malformed);
}
@ -695,28 +743,28 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
match unwrap_suffixed_expression(arena,after_defs,maybe_def_pat){
Ok(new_loc_ret) => {
let applied_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
let applied_await = apply_try_function(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type, target);
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_await)));
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
},
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
let new_loc_ret = apply_task_await(arena, def_expr.region, sub_arg, sub_pat, sub_new, None);
let applied_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
let new_loc_ret = apply_try_function(arena, def_expr.region, sub_arg, sub_pat, sub_new, None, target);
let applied_await = apply_try_function(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type, target);
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_await)));
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
}
Err(EUnwrapped::UnwrappedDefExpr(..)) | Err(EUnwrapped::Malformed) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) | Err(EUnwrapped::Malformed) => {
// TODO handle case when we have maybe_def_pat so can return an unwrapped up
return Err(EUnwrapped::Malformed);
},
};
}
}
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
let new_body_def = ValueDef::Body(def_pattern, sub_new);
local_defs.replace_with_value_def(tag_index,new_body_def, sub_new.region);
let new_defs_expr = arena.alloc(Loc::at(def_expr.region,Defs(arena.alloc(local_defs), loc_ret)));
let replaced_def = apply_task_await(arena,def_expr.region,sub_arg,sub_pat,new_defs_expr, ann_type);
let replaced_def = apply_try_function(arena,def_expr.region,sub_arg,sub_pat,new_defs_expr, ann_type, target);
return unwrap_suffixed_expression(arena,replaced_def,maybe_def_pat);
}
Err(err) => return Err(err)
@ -730,12 +778,12 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
Ok(new_loc_ret) => {
Ok(arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(local_defs), new_loc_ret))))
},
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
let new_loc_ret = apply_task_await(arena, loc_expr.region,sub_arg,sub_pat,sub_new, None);
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new, target }) => {
let new_loc_ret = apply_try_function(arena, loc_expr.region,sub_arg,sub_pat,sub_new, None, target);
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(local_defs), new_loc_ret)));
unwrap_suffixed_expression(arena, new_defs, None)
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
// TODO confirm this is correct with test case
Err(EUnwrapped::Malformed)
}
@ -769,6 +817,7 @@ fn unwrap_low_level_dbg<'a>(
sub_arg,
sub_pat,
sub_new,
target,
}) => {
let new_dbg = arena.alloc(Loc::at(
loc_expr.region,
@ -777,18 +826,19 @@ fn unwrap_low_level_dbg<'a>(
unwrap_suffixed_expression(
arena,
apply_task_await(
apply_try_function(
arena,
new_dbg.region,
sub_arg,
sub_pat,
new_dbg,
None,
target,
),
maybe_def_pat,
)
}
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
Err(EUnwrapped::UnwrappedDefExpr { .. }) => {
internal_error!(
"unreachable, arg of LowLevelDbg should generate UnwrappedSubExpr instead"
);
@ -805,17 +855,24 @@ fn unwrap_low_level_dbg<'a>(
));
Ok(&*new_dbg)
}
Err(EUnwrapped::UnwrappedDefExpr(unwrapped_expr)) => {
Err(EUnwrapped::UnwrappedDefExpr {
loc_expr: unwrapped_expr,
target,
}) => {
let new_dbg = arena.alloc(Loc::at(
loc_expr.region,
LowLevelDbg(dbg_src, arg, unwrapped_expr),
));
Err(EUnwrapped::UnwrappedDefExpr(new_dbg))
Err(EUnwrapped::UnwrappedDefExpr {
loc_expr: new_dbg,
target,
})
}
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg: unwrapped_expr,
sub_pat,
sub_new,
target,
}) => {
let new_dbg = arena.alloc(Loc::at(
loc_expr.region,
@ -825,6 +882,7 @@ fn unwrap_low_level_dbg<'a>(
sub_arg: new_dbg,
sub_pat,
sub_new,
target,
})
}
Err(EUnwrapped::Malformed) => Err(EUnwrapped::Malformed),
@ -836,25 +894,26 @@ fn unwrap_low_level_dbg<'a>(
}
}
/// Helper for `Task.await loc_expr \loc_pat -> loc_cont`
pub fn apply_task_await<'a>(
/// Helper for try_function loc_expr \loc_pat -> loc_cont`
pub fn apply_try_function<'a>(
arena: &'a Bump,
region: Region,
loc_expr: &'a Loc<Expr<'a>>,
loc_pat: &'a Loc<Pattern<'a>>,
loc_cont: &'a Loc<Expr<'a>>,
maybe_loc_ann: Option<(&'a Loc<Pattern>, &'a Loc<TypeAnnotation<'a>>)>,
target: TryTarget,
) -> &'a Loc<Expr<'a>> {
let task_await_first_arg = match maybe_loc_ann {
let try_function_first_arg = match maybe_loc_ann {
Some((loc_ann_pat, loc_type)) => {
// loc_ann_pat : loc_type
// loc_pat = loc_expr!
// loc_cont
// desugar to
// Task.await
// try_function
// (
// #!0_expr : Task loc_type _
// #!0_expr : Target loc_type _
// #!0_expr = loc_expr
// #!0_expr
// )
@ -875,8 +934,12 @@ pub fn apply_task_await<'a>(
let new_ident = arena.alloc(new_ident);
// #!0_expr (pattern)
// #!0_expr : Task loc_type _
// #!0_expr : Target loc_type _
// #!0_expr = loc_expr
let target_type_name = match target {
TryTarget::Task => "Task",
TryTarget::Result => "Result",
};
let value_def = ValueDef::AnnotatedBody {
ann_pattern: arena.alloc(Loc::at(
loc_ann_pat.region,
@ -893,7 +956,7 @@ pub fn apply_task_await<'a>(
loc_type.region,
TypeAnnotation::Apply(
arena.alloc(""),
arena.alloc("Task"),
arena.alloc(target_type_name),
arena.alloc([
*loc_type,
Loc::at(loc_type.region, TypeAnnotation::Inferred),
@ -918,7 +981,7 @@ pub fn apply_task_await<'a>(
));
// (
// #!0_expr : Task loc_type _
// #!0_expr : Target loc_type _
// #!0_expr = loc_expr
// #!0_expr
// )
@ -935,7 +998,7 @@ pub fn apply_task_await<'a>(
// loc_cont
// desugar to
// Task.await loc_expr \loc_pat -> loc_cont
// try_function loc_expr \loc_pat -> loc_cont
loc_expr
}
};
@ -945,25 +1008,29 @@ pub fn apply_task_await<'a>(
// \x -> x!
// \x -> x
if is_matching_intermediate_answer(loc_pat, loc_cont) {
return task_await_first_arg;
return try_function_first_arg;
}
// \loc_pat -> loc_cont
let closure = arena.alloc(Loc::at(region, Closure(arena.alloc([*loc_pat]), loc_cont)));
// Task.await task_first_arg closure
// try_function first_arg closure
let (try_function_module, try_function_ident, called_via) = match target {
TryTarget::Task => (ModuleName::TASK, "await", CalledVia::BangSuffix),
TryTarget::Result => (ModuleName::RESULT, "try", CalledVia::QuestionSuffix),
};
arena.alloc(Loc::at(
region,
Apply(
arena.alloc(Loc {
region,
value: Var {
module_name: ModuleName::TASK,
ident: "await",
module_name: try_function_module,
ident: try_function_ident,
},
}),
arena.alloc([task_await_first_arg, closure]),
CalledVia::BangSuffix,
arena.alloc([try_function_first_arg, closure]),
called_via,
),
))
}

View file

@ -266,6 +266,7 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
walk_list(visitor, *elem_var, loc_elems);
}
Expr::Var(..) => { /* terminal */ }
Expr::ParamsVar { .. } => { /* terminal */ }
Expr::AbilityMember(..) => { /* terminal */ }
Expr::If {
cond_var,
@ -317,6 +318,8 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
.iter()
.for_each(|(var, elem)| visitor.visit_expr(&elem.value, elem.region, *var)),
Expr::EmptyRecord => { /* terminal */ }
Expr::ImportParams(_, region, Some((_, expr))) => visitor.visit_expr(expr, *region, var),
Expr::ImportParams(_, _, None) => { /* terminal */ }
Expr::RecordAccess {
field_var,
loc_expr,

View file

@ -59,6 +59,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
expr_str,
&mut None,
arena.alloc("TestPath"),
&mut Default::default(),
);
let mut scope = Scope::new(

View file

@ -12,7 +12,15 @@ mod suffixed_tests {
($src:expr) => {{
let arena = &Bump::new();
let mut defs = parse_defs_with(arena, indoc!($src)).unwrap();
desugar_defs_node_values(arena, &mut defs, $src, &mut None, "test.roc", true);
desugar_defs_node_values(
arena,
&mut defs,
$src,
&mut None,
"test.roc",
true,
&mut Default::default(),
);
let snapshot = format!("{:#?}", &defs);
println!("{}", snapshot);

View file

@ -566,7 +566,12 @@ pub fn constrain_expr(
constraints.exists([*ret_var], and)
}
Var(symbol, variable) => {
Var(symbol, variable)
| ParamsVar {
symbol,
params: _,
var: variable,
} => {
// Save the expectation in the variable, then lookup the symbol's type in the environment
let expected_type = *constraints[expected].get_type_ref();
let store_expected = constraints.store(expected_type, *variable, file!(), line!());
@ -575,6 +580,22 @@ pub fn constrain_expr(
constraints.and_constraint([store_expected, lookup_constr])
}
ImportParams(module_id, region, Some((var, params))) => {
let index = constraints.push_variable(*var);
let expected_params = constraints.push_expected_type(Expected::ForReason(
Reason::ImportParams(*module_id),
index,
*region,
));
let expr_con =
constrain_expr(types, constraints, env, *region, params, expected_params);
let params_con = constraints.import_params(Some(index), *module_id, *region);
let expr_and_params = constraints.and_constraint([expr_con, params_con]);
constraints.exists([*var], expr_and_params)
}
ImportParams(module_id, region, None) => {
constraints.import_params(None, *module_id, *region)
}
&AbilityMember(symbol, specialization_id, specialization_var) => {
// Save the expectation in the `specialization_var` so we know what to specialize, then
// lookup the member in the environment.
@ -4089,6 +4110,8 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
return true;
}
OpaqueRef { argument, .. } => expr = &argument.1.value,
ImportParams(_, _, Some((_, params))) => expr = params,
ImportParams(_, _, None) => return false,
Str(_)
| IngestedFile(..)
| List { .. }
@ -4115,7 +4138,8 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
| ZeroArgumentTag { .. }
| Tag { .. }
| AbilityMember(..)
| Var(..) => return false,
| Var(..)
| ParamsVar { .. } => return false,
}
}
}

View file

@ -1,11 +1,15 @@
use crate::expr::{constrain_def_make_constraint, constrain_def_pattern, Env};
use crate::pattern::{constrain_pattern, PatternState};
use roc_can::abilities::{PendingAbilitiesStore, PendingMemberType};
use roc_can::constraint::{Constraint, Constraints, Generalizable};
use roc_can::expected::Expected;
use roc_can::expr::Declarations;
use roc_can::expected::{Expected, PExpected};
use roc_can::expr::{AnnotatedMark, Declarations};
use roc_can::pattern::Pattern;
use roc_collections::MutMap;
use roc_error_macros::internal_error;
use roc_module::symbol::{ModuleId, Symbol};
use roc_region::all::{Loc, Region};
use roc_types::subs::Variable;
use roc_types::types::{AnnotationSource, Category, Type, Types};
pub fn constrain_module(
@ -14,9 +18,18 @@ pub fn constrain_module(
symbols_from_requires: Vec<(Loc<Symbol>, Loc<Type>)>,
abilities_store: &PendingAbilitiesStore,
declarations: &Declarations,
params_pattern: &Option<(Variable, AnnotatedMark, Loc<Pattern>)>,
home: ModuleId,
) -> Constraint {
let constraint = crate::expr::constrain_decls(types, constraints, home, declarations);
let constraint = match params_pattern {
Some(params_pattern) => {
constrain_params(types, constraints, home, constraint, params_pattern)
}
None => constraint,
};
let constraint = constrain_symbols_from_requires(
types,
constraints,
@ -33,6 +46,63 @@ pub fn constrain_module(
constraint
}
fn constrain_params(
types: &mut Types,
constraints: &mut Constraints,
home: ModuleId,
constraint: Constraint,
(pattern_var, _, loc_pattern): &(Variable, AnnotatedMark, Loc<Pattern>),
) -> Constraint {
let mut env = Env {
home,
rigids: MutMap::default(),
resolutions_to_make: vec![],
};
let index = constraints.push_variable(*pattern_var);
let expected_params = constraints.push_pat_expected_type(PExpected::NoExpectation(index));
let mut state = PatternState::default();
let closed_con = match loc_pattern.value {
Pattern::RecordDestructure {
whole_var: _,
ext_var,
destructs: _,
} => {
// Disallow record extension for module params
let empty_rec = constraints.push_type(types, Types::EMPTY_RECORD);
constraints.store(empty_rec, ext_var, file!(), line!())
}
_ => internal_error!("Only record destructures are allowed in module params. This should've been caught earlier."),
};
state.constraints.push(closed_con);
constrain_pattern(
types,
constraints,
&mut env,
&loc_pattern.value,
loc_pattern.region,
expected_params,
&mut state,
);
let pattern_constraints = constraints.and_constraint(state.constraints);
let cons = constraints.let_constraint(
[],
state.vars,
state.headers,
pattern_constraints,
constraint,
Generalizable(true),
);
constraints.exists([*pattern_var], cons)
}
fn constrain_symbols_from_requires(
types: &mut Types,
constraints: &mut Constraints,

View file

@ -252,14 +252,14 @@ impl<'a> Formattable for ModuleImportParams<'a> {
fn is_multiline(&self) -> bool {
let ModuleImportParams { before, params } = self;
!before.is_empty() || is_collection_multiline(params)
!before.is_empty() || is_collection_multiline(&params.value)
}
fn format_with_options(&self, buf: &mut Buf, _parens: Parens, newlines: Newlines, indent: u16) {
let ModuleImportParams { before, params } = self;
fmt_default_spaces(buf, before, indent);
fmt_collection(buf, indent, Braces::Curly, *params, newlines);
fmt_collection(buf, indent, Braces::Curly, params.value, newlines);
}
}

View file

@ -10,7 +10,7 @@ use crate::Buf;
use roc_module::called_via::{self, BinOp};
use roc_parse::ast::{
is_expr_suffixed, AssignedField, Base, Collection, CommentOrNewline, Expr, ExtractSpaces,
OldRecordBuilderField, Pattern, WhenBranch,
OldRecordBuilderField, Pattern, TryTarget, WhenBranch,
};
use roc_parse::ast::{StrLiteral, StrSegment};
use roc_parse::ident::Accessor;
@ -39,6 +39,7 @@ impl<'a> Formattable for Expr<'a> {
| NonBase10Int { .. }
| SingleQuote(_)
| AccessorFunction(_)
| RecordUpdater(_)
| Var { .. }
| Underscore { .. }
| MalformedIdent(_, _)
@ -47,7 +48,7 @@ impl<'a> Formattable for Expr<'a> {
| OpaqueRef(_)
| Crash => false,
RecordAccess(inner, _) | TupleAccess(inner, _) | TaskAwaitBang(inner) => {
RecordAccess(inner, _) | TupleAccess(inner, _) | TrySuffix { expr: inner, .. } => {
inner.is_multiline()
}
@ -510,6 +511,11 @@ impl<'a> Formattable for Expr<'a> {
Accessor::TupleIndex(key) => buf.push_str(key),
}
}
RecordUpdater(key) => {
buf.indent(indent);
buf.push('&');
buf.push_str(key);
}
RecordAccess(expr, key) => {
expr.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
buf.push('.');
@ -520,9 +526,12 @@ impl<'a> Formattable for Expr<'a> {
buf.push('.');
buf.push_str(key);
}
TaskAwaitBang(expr) => {
TrySuffix { expr, target } => {
expr.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
buf.push('!');
match target {
TryTarget::Task => buf.push('!'),
TryTarget::Result => buf.push('?'),
}
}
MalformedIdent(str, _) => {
buf.indent(indent);
@ -615,6 +624,22 @@ fn starts_with_newline(expr: &Expr) -> bool {
}
}
fn fmt_str_body(body: &str, buf: &mut Buf) {
for c in body.chars() {
match c {
// Format blank characters as unicode escapes
'\u{200a}' => buf.push_str("\\u(200a)"),
'\u{200b}' => buf.push_str("\\u(200b)"),
'\u{200c}' => buf.push_str("\\u(200c)"),
'\u{feff}' => buf.push_str("\\u(feff)"),
// Don't change anything else in the string
' ' => buf.push_str_allow_spaces(" "),
'\n' => buf.push_str_allow_spaces("\n"),
_ => buf.push(c),
}
}
}
fn format_str_segment(seg: &StrSegment, buf: &mut Buf, indent: u16) {
use StrSegment::*;
@ -624,10 +649,10 @@ fn format_str_segment(seg: &StrSegment, buf: &mut Buf, indent: u16) {
// a line break in the input string
match string.strip_suffix('\n') {
Some(string_without_newline) => {
buf.push_str_allow_spaces(string_without_newline);
fmt_str_body(string_without_newline, buf);
buf.newline();
}
None => buf.push_str_allow_spaces(string),
None => fmt_str_body(string, buf),
}
}
Unicode(loc_str) => {
@ -687,7 +712,7 @@ pub fn fmt_str_literal(buf: &mut Buf, literal: StrLiteral, indent: u16) {
buf.push_newline_literal();
for line in string.split('\n') {
buf.indent(indent);
buf.push_str_allow_spaces(line);
fmt_str_body(line, buf);
buf.push_newline_literal();
}
buf.indent(indent);
@ -695,7 +720,7 @@ pub fn fmt_str_literal(buf: &mut Buf, literal: StrLiteral, indent: u16) {
} else {
buf.indent(indent);
buf.push('"');
buf.push_str_allow_spaces(string);
fmt_str_body(string, buf);
buf.push('"');
};
}

View file

@ -171,11 +171,17 @@ pub fn fmt_module_header<'a>(buf: &mut Buf, header: &'a ModuleHeader<'a>) {
let mut indent = fmt_spaces_with_outdent(buf, header.after_keyword, 0);
if let Some(params) = &header.params {
if is_collection_multiline(&params.params) {
if is_collection_multiline(&params.pattern.value) {
indent = INDENT;
}
fmt_collection(buf, indent, Braces::Curly, params.params, Newlines::Yes);
fmt_collection(
buf,
indent,
Braces::Curly,
params.pattern.value,
Newlines::Yes,
);
indent = fmt_spaces_with_outdent(buf, params.before_arrow, indent);
buf.push_str("->");

View file

@ -51,6 +51,8 @@ pub fn infer_expr(
exposed_by_module: &Default::default(),
derived_module,
function_kind: FunctionKind::LambdaSet,
params_pattern: None,
module_params_vars: Default::default(),
#[cfg(debug_assertions)]
checkmate: None,
};
@ -172,6 +174,7 @@ pub fn can_expr_with<'a>(
expr_str,
&mut None,
arena.alloc("TestPath"),
&mut Default::default(),
);
let mut scope = Scope::new(

View file

@ -4816,7 +4816,7 @@ mod test_reporting {
expression_indentation_end,
indoc!(
r"
f <- Foo.foo
f = Foo.foo
"
),
@r#"
@ -4827,8 +4827,8 @@ mod test_reporting {
1 app "test" provides [main] to "./platform"
2
3 main =
4 f <- Foo.foo
^
4 f = Foo.foo
^
Looks like the indentation ends prematurely here. Did you mean to have
another expression after this line?
@ -6618,34 +6618,6 @@ All branches in an `if` must have the same type!
"
);
test_report!(
backpassing_type_error,
indoc!(
r#"
x <- List.map ["a", "b"]
x + 1
"#
),
@r#"
TYPE MISMATCH in /code/proj/Main.roc
This 2nd argument to `map` has an unexpected type:
4> x <- List.map ["a", "b"]
5>
6> x + 1
The argument is an anonymous function of type:
Num * -> Num *
But `map` needs its 2nd argument to be:
Str -> Num *
"#
);
test_report!(
expect_expr_type_error,
indoc!(
@ -10199,9 +10171,9 @@ All branches in an `if` must have the same type!
withOpen : (Handle -> Result {} *) -> Result {} *
withOpen = \callback ->
handle <- await (open {})
{} <- await (callback handle)
close handle
await (open {}) \handle ->
await (callback handle) \_ ->
close handle
withOpen
"
@ -10213,9 +10185,9 @@ All branches in an `if` must have the same type!
10 withOpen : (Handle -> Result {} *) -> Result {} *
11 withOpen = \callback ->
12> handle <- await (open {})
13> {} <- await (callback handle)
14> close handle
12> await (open {}) \handle ->
13> await (callback handle) \_ ->
14> close handle
The type annotation on `withOpen` says this `await` call should have the
type:
@ -10228,6 +10200,7 @@ All branches in an `if` must have the same type!
Tip: Any connection between types must use a named type variable, not
a `*`! Maybe the annotation on `withOpen` should have a named type
variable in place of the `*`?
"
);
@ -10831,7 +10804,7 @@ All branches in an `if` must have the same type!
7 a: <- "a",
^^^
Tip: Remove `<-` to assign the field directly.
Tip: Remove <- to assign the field directly.
"#
);
@ -10963,7 +10936,7 @@ All branches in an `if` must have the same type!
6 { xyz <-
^^^
Note: Record builders need a mapper function before the `<-` to combine
Note: Record builders need a mapper function before the <- to combine
fields together with.
"#
);
@ -11845,6 +11818,32 @@ All branches in an `if` must have the same type!
@r"
"
);
test_report!(
deprecated_backpassing,
indoc!(
r#"
foo = \bar ->
baz <- Result.try bar
Ok (baz * 3)
foo (Ok 123)
"#
),
@r###"
BACKPASSING DEPRECATED in /code/proj/Main.roc
Backpassing (<-) like this will soon be deprecated:
5 baz <- Result.try bar
^^^^^^^^^^^^^^^^^^^^^
You should use a ! for awaiting tasks or a ? for trying results, and
functions everywhere else.
"###
);
test_report!(
unknown_shorthand_no_deps,
indoc!(
@ -13882,7 +13881,7 @@ All branches in an `if` must have the same type!
"#
),
@r#"
DEFINITIONs ONLY USED IN RECURSION in /code/proj/Main.roc
DEFINITIONS ONLY USED IN RECURSION in /code/proj/Main.roc
These 2 definitions are only used in mutual recursion with themselves:
@ -13891,6 +13890,7 @@ All branches in an `if` must have the same type!
If you don't intend to use or export any of them, they should all be
removed!
"#
);
@ -13954,7 +13954,7 @@ All branches in an `if` must have the same type!
"#
),
@r#"
DEFINITIONs ONLY USED IN RECURSION in /code/proj/Main.roc
DEFINITIONS ONLY USED IN RECURSION in /code/proj/Main.roc
These 2 definitions are only used in mutual recursion with themselves:
@ -13963,6 +13963,7 @@ All branches in an `if` must have the same type!
If you don't intend to use or export any of them, they should all be
removed!
"#
);

View file

@ -2396,6 +2396,13 @@ fn update<'a>(
.pending_abilities
.insert(module_id, constrained_module.module.abilities_store.clone());
if let Some(params_pattern) = constrained_module.module.params_pattern.clone() {
state
.module_cache
.param_patterns
.insert(module_id, params_pattern);
}
state
.module_cache
.constrained
@ -3551,6 +3558,7 @@ fn load_builtin_module_help<'a>(
header_type: HeaderType::Builtin {
name: header::ModuleName::new(name_stem),
exposes: unspace(arena, header.exposes.items),
opt_params: header.params,
},
module_comments: comments,
header_imports: header.interface_imports,
@ -3838,6 +3846,7 @@ fn parse_header<'a>(
header_type: HeaderType::Module {
name: roc_parse::header::ModuleName::new(module_name),
exposes: unspace(arena, header.exposes.items),
opt_params: header.params,
},
module_comments: comments,
header_imports: header.interface_imports,
@ -4379,7 +4388,7 @@ pub fn add_imports(
def_types: &mut Vec<(Symbol, Loc<TypeOrVar>)>,
imported_rigid_vars: &mut Vec<Variable>,
imported_flex_vars: &mut Vec<Variable>,
) -> (Vec<Variable>, AbilitiesStore) {
) -> (Vec<Variable>, VecMap<ModuleId, Variable>, AbilitiesStore) {
let mut import_variables = Vec::new();
let mut cached_symbol_vars = VecMap::default();
@ -4486,7 +4495,31 @@ pub fn add_imports(
},
);
(import_variables, abilities_store)
let mut imported_param_vars = VecMap::default();
for (module_id, _) in exposed_for_module.exposed_by_module.iter_all() {
let ExposedModuleTypes {
exposed_types_storage_subs: exposed_types,
..
} = exposed_for_module.exposed_by_module.get(module_id).unwrap();
if let Some(stored_aprams_var) = exposed_types.stored_params_var {
let copied_import = exposed_types
.storage_subs
.export_variable_to(subs, stored_aprams_var);
let copied_import_var = extend_imports_data_with_copied_import(
copied_import,
&mut import_variables,
imported_rigid_vars,
imported_flex_vars,
);
imported_param_vars.insert(*module_id, copied_import_var);
}
}
(import_variables, imported_param_vars, abilities_store)
}
enum OnSymbolNotFound {
@ -4608,6 +4641,7 @@ fn run_solve_solve(
aliases,
rigid_variables,
abilities_store: pending_abilities,
params_pattern,
..
} = module;
@ -4617,7 +4651,7 @@ fn run_solve_solve(
let mut subs = Subs::new_from_varstore(var_store);
let (import_variables, abilities_store) = add_imports(
let (import_variables, imported_param_vars, abilities_store) = add_imports(
module.module_id,
&mut constraints,
&mut subs,
@ -4655,6 +4689,8 @@ fn run_solve_solve(
derived_module,
#[cfg(debug_assertions)]
checkmate,
params_pattern: params_pattern.map(|(_, _, pattern)| pattern.value),
module_params_vars: imported_param_vars,
};
let solve_output = roc_solve::module::run_solve(
@ -4739,6 +4775,11 @@ fn run_solve<'a>(
// TODO remove when we write builtins in roc
let aliases = module.aliases.clone();
let opt_params_var = module
.params_pattern
.as_ref()
.map(|(params_var, _, _)| *params_var);
let mut module = module;
let loc_expects = std::mem::take(&mut module.loc_expects);
let loc_dbgs = std::mem::take(&mut module.loc_dbgs);
@ -4810,6 +4851,7 @@ fn run_solve<'a>(
module_id,
&mut solved_subs,
&exposed_vars_by_symbol,
opt_params_var,
&solved_implementations,
&abilities_store,
);
@ -5059,6 +5101,7 @@ fn canonicalize_and_constrain<'a>(
module_output.symbols_from_requires,
&module_output.scope.abilities_store,
&module_output.declarations,
&module_output.params_pattern,
module_id,
)
};
@ -5116,6 +5159,7 @@ fn canonicalize_and_constrain<'a>(
abilities_store: module_output.scope.abilities_store,
loc_expects: module_output.loc_expects,
loc_dbgs: module_output.loc_dbgs,
params_pattern: module_output.params_pattern,
};
let constrained_module = ConstrainedModule {
@ -5459,6 +5503,7 @@ fn make_specializations<'a>(
) -> Msg<'a> {
let make_specializations_start = Instant::now();
let mut update_mode_ids = UpdateModeIds::new();
// do the thing
let mut mono_env = roc_mono::ir::Env {
arena,

View file

@ -4,12 +4,13 @@ use crate::module::{
ModuleHeader, ParsedModule, TypeCheckedModule,
};
use roc_can::abilities::PendingAbilitiesStore;
use roc_can::expr::AnnotatedMark;
use roc_collections::{MutMap, MutSet, VecMap};
use roc_module::ident::ModuleName;
use roc_module::symbol::{ModuleId, PQModuleName, Symbol};
use roc_mono::ir::ExternalSpecializations;
use roc_problem::Severity;
use roc_region::all::Region;
use roc_region::all::{Loc, Region};
use roc_solve_problem::TypeError;
use roc_types::subs::Variable;
use roc_types::types::Alias;
@ -26,6 +27,8 @@ pub(crate) struct ModuleCache<'a> {
pub(crate) aliases: MutMap<ModuleId, MutMap<Symbol, (bool, Alias)>>,
pub(crate) pending_abilities: MutMap<ModuleId, PendingAbilitiesStore>,
pub(crate) constrained: MutMap<ModuleId, ConstrainedModule>,
pub(crate) param_patterns:
MutMap<ModuleId, (Variable, AnnotatedMark, Loc<roc_can::pattern::Pattern>)>,
pub(crate) typechecked: MutMap<ModuleId, TypeCheckedModule<'a>>,
pub(crate) checked: MutMap<ModuleId, CheckedModule>,
pub(crate) found_specializations: MutMap<ModuleId, FoundSpecializationsModule<'a>>,
@ -101,6 +104,7 @@ impl Default for ModuleCache<'_> {
aliases: Default::default(),
pending_abilities: Default::default(),
constrained: Default::default(),
param_patterns: Default::default(),
typechecked: Default::default(),
checked: Default::default(),
found_specializations: Default::default(),

View file

@ -27,10 +27,11 @@ use roc_module::symbol::{Interns, ModuleId};
use roc_packaging::cache::RocCacheDir;
use roc_problem::can::Problem;
use roc_region::all::LineInfo;
use roc_reporting::report::RocDocAllocator;
use roc_reporting::report::{can_problem, DEFAULT_PALETTE};
use roc_reporting::report::{strip_colors, RenderTarget};
use roc_reporting::report::{type_problem, RocDocAllocator};
use roc_solve::FunctionKind;
use roc_solve_problem::TypeError;
use roc_target::Target;
use roc_test_utils_dir::TmpDir;
use roc_types::pretty_print::name_and_print_var;
@ -107,6 +108,33 @@ fn format_can_problems(
buf
}
fn format_type_problems(
problems: Vec<TypeError>,
home: ModuleId,
interns: &Interns,
filename: PathBuf,
src: &str,
) -> String {
use ven_pretty::DocAllocator;
let src_lines: Vec<&str> = src.split('\n').collect();
let lines = LineInfo::new(src);
let alloc = RocDocAllocator::new(&src_lines, home, interns);
let reports = problems
.into_iter()
.flat_map(|problem| type_problem(&alloc, &lines, filename.clone(), problem))
.map(|report| report.pretty(&alloc));
let mut buf = String::new();
alloc
.stack(reports)
.append(alloc.line())
.1
.render_raw(70, &mut roc_reporting::report::CiWrite::new(&mut buf))
.unwrap();
buf
}
fn multiple_modules(subdir: &str, files: Vec<(&str, &str)>) -> Result<LoadedModule, String> {
let arena = Bump::new();
let arena = &arena;
@ -130,11 +158,19 @@ fn multiple_modules(subdir: &str, files: Vec<(&str, &str)>) -> Result<LoadedModu
));
}
assert!(loaded_module
let type_problems = loaded_module
.type_problems
.remove(&home)
.unwrap_or_default()
.is_empty(),);
.unwrap_or_default();
if !type_problems.is_empty() {
return Err(format_type_problems(
type_problems,
home,
&loaded_module.interns,
filepath.clone(),
src,
));
}
Ok(loaded_module)
}
@ -279,6 +315,13 @@ fn expect_types(mut loaded_module: LoadedModule, mut expected_types: HashMap<&st
match declarations.declarations[index] {
Value | Function(_) | Recursive(_) | TailRecursive(_) => {
let body = declarations.expressions[index].clone();
if let roc_can::expr::Expr::ImportParams(_, _, None) = body.value {
// Skip import defs without params
continue;
}
let symbol = declarations.symbols[index].value;
let expr_var = declarations.variables[index];
@ -407,7 +450,13 @@ fn module_with_deps() {
match declarations.declarations[index] {
Value | Function(_) | Recursive(_) | TailRecursive(_) => {
def_count += 1;
let body = declarations.expressions[index].clone();
if let roc_can::expr::Expr::ImportParams(_, _, None) = body.value {
// Skip import defs without params
} else {
def_count += 1;
}
}
Destructure(_) => {
def_count += 1;
@ -1563,6 +1612,325 @@ fn cannot_use_original_name_if_imported_with_alias() {
multiple_modules("cannot_use_original_name_if_imported_with_alias", modules).unwrap_err();
}
#[test]
fn module_params_checks() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: "abcdef" }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_checks", modules);
assert!(result.is_ok());
}
#[test]
fn module_params_optional() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key, exp ? "default" } -> [url]
url = "example.com/$(key)?exp=$(exp)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: "abcdef" }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_optional", modules);
assert!(result.is_ok())
}
#[test]
fn module_params_typecheck_fail() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: 123 }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_typecheck_fail", modules).unwrap_err();
assert_eq!(
result,
indoc!(
r#"
MODULE PARAMS MISMATCH in tmp/module_params_typecheck_fail/Main.roc
Something is off with the params provided by this import:
3 import Api { key: 123 }
^^^^^^^^^^^^
This is the type I inferred:
{ key : Num * }
However, Api expects:
{ key : Str }
"#
)
);
}
#[test]
fn module_params_missing_fields() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api {}
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_missing_fields", modules).unwrap_err();
assert_eq!(
result,
indoc!(
r#"
MODULE PARAMS MISMATCH in tmp/module_params_missing_fields/Main.roc
Something is off with the params provided by this import:
3 import Api {}
^^
This is the type I inferred:
{}
However, Api expects:
{ key : Str }
Tip: Looks like the key field is missing.
"#
)
);
}
#[test]
fn module_params_extra_fields() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key } -> [url]
url = "example.com/$(key)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: "123", doesNotExist: Bool.true }
example = Api.url
"#
),
),
];
let result = multiple_modules("module_params_extra_fields", modules).unwrap_err();
assert_eq!(
result,
indoc!(
r#"
MODULE PARAMS MISMATCH in tmp/module_params_extra_fields/Main.roc
Something is off with the params provided by this import:
3 import Api { key: "123", doesNotExist: Bool.true }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the type I inferred:
{ doesNotExist : Bool, }
However, Api expects:
{ }
"#
)
);
}
#[test]
fn module_params_unexpected() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module [url]
url = "example.com"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api { key: 123 }
example = Api.url
"#
),
),
];
let err = multiple_modules("module_params_unexpected", modules).unwrap_err();
assert_eq!(
err,
indoc!(
r#"
UNEXPECTED MODULE PARAMS in tmp/module_params_unexpected/Main.roc
This import specifies module params:
3 import Api { key: 123 }
^^^^^^^^^^^^
However, Api does not expect any. Did you intend to import a different
module?
"#
)
)
}
#[test]
fn module_params_missing() {
let modules = vec![
(
"Api.roc",
indoc!(
r#"
module { key, exp } -> [url]
url = "example.com/$(key)?exp=$(Num.toStr exp)"
"#
),
),
(
"Main.roc",
indoc!(
r#"
module [example]
import Api
example = Api.url
"#
),
),
];
let err = multiple_modules("module_params_missing", modules).unwrap_err();
assert_eq!(
err,
indoc!(
r#"
MISSING MODULE PARAMS in tmp/module_params_missing/Main.roc
This import specifies no module params:
3 import Api
^^^^^^^^^^
However, Api expects the following to be provided:
{
exp : Num *,
key : Str,
}
You can provide params after the module name, like:
import Menu { echo, read }
"#
)
)
}
#[test]
fn issue_2863_module_type_does_not_exist() {
let modules = vec![

View file

@ -14,7 +14,6 @@ roc_ident = { path = "../ident" }
roc_region = { path = "../region" }
bumpalo.workspace = true
snafu.workspace = true
static_assertions.workspace = true
[features]

View file

@ -95,6 +95,10 @@ pub enum CalledVia {
/// This call is the result of desugaring a Task.await from `!` syntax
/// e.g. Stdout.line! "Hello" becomes Task.await (Stdout.line "Hello") \{} -> ...
BangSuffix,
/// This call is the result of desugaring a Result.try from `?` syntax
/// e.g. Dict.get? items "key" becomes Result.try (Dict.get items "key") \item -> ...
QuestionSuffix,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@ -114,6 +118,23 @@ impl std::fmt::Display for UnaryOp {
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Suffix {
/// (!), e.g. (Stdin.line!)
Bang,
/// (?), e.g. (parseData? data)
Question,
}
impl std::fmt::Display for Suffix {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Suffix::Bang => write!(f, "!"),
Suffix::Question => write!(f, "?"),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BinOp {
// highest precedence

View file

@ -1,30 +1,45 @@
use snafu::{Backtrace, Snafu};
use crate::symbol::IdentId;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
#[derive(Debug)]
pub enum ModuleError {
#[snafu(display(
"ModuleIdNotFound: I could not find the ModuleId {} in Interns.all_ident_ids: {}.",
module_id,
all_ident_ids
))]
ModuleIdNotFound {
module_id: String,
all_ident_ids: String,
backtrace: Backtrace,
},
#[snafu(display(
"IdentIdNotFound: I could not find IdentId {:?} in ident_ids {:?}.",
ident_id,
ident_ids_str
))]
IdentIdNotFound {
ident_id: IdentId,
ident_ids_str: String,
backtrace: Backtrace,
},
}
impl std::fmt::Display for ModuleError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::ModuleIdNotFound {
module_id,
all_ident_ids,
} => {
write!(
f,
"ModuleIdNotFound: I could not find the ModuleId {} in Interns.all_ident_ids: {}.",
module_id,
all_ident_ids
)
}
Self::IdentIdNotFound {
ident_id,
ident_ids_str,
} => {
write!(
f,
"IdentIdNotFound: I could not find IdentId {:?} in ident_ids {:?}.",
ident_id, ident_ids_str
)
}
}
}
}
impl std::error::Error for ModuleError {}
pub type ModuleResult<T, E = ModuleError> = std::result::Result<T, E>;

View file

@ -1,10 +1,9 @@
use crate::ident::{Ident, Lowercase, ModuleName};
use crate::module_err::{IdentIdNotFoundSnafu, ModuleIdNotFoundSnafu, ModuleResult};
use crate::module_err::{ModuleError, ModuleResult};
use roc_collections::{SmallStringInterner, VecMap};
use roc_error_macros::internal_error;
use roc_ident::IdentStr;
use roc_region::all::Region;
use snafu::OptionExt;
use std::num::NonZeroU32;
use std::{fmt, u32};
@ -324,7 +323,7 @@ pub fn get_module_ident_ids<'a>(
) -> ModuleResult<&'a IdentIds> {
all_ident_ids
.get(module_id)
.with_context(|| ModuleIdNotFoundSnafu {
.ok_or_else(|| ModuleError::ModuleIdNotFound {
module_id: format!("{module_id:?}"),
all_ident_ids: format!("{all_ident_ids:?}"),
})
@ -336,9 +335,10 @@ pub fn get_module_ident_ids_mut<'a>(
) -> ModuleResult<&'a mut IdentIds> {
all_ident_ids
.get_mut(module_id)
.with_context(|| ModuleIdNotFoundSnafu {
.ok_or_else(|| ModuleError::ModuleIdNotFound {
module_id: format!("{module_id:?}"),
all_ident_ids: "I could not return all_ident_ids here because of borrowing issues.",
all_ident_ids: "I could not return all_ident_ids here because of borrowing issues."
.into(),
})
}
@ -627,67 +627,12 @@ impl ModuleIds {
pub fn available_modules(&self) -> impl Iterator<Item = &ModuleName> {
self.by_id.iter()
}
}
#[derive(Debug, Clone)]
pub struct ScopeModules {
modules: VecMap<ModuleName, ModuleId>,
sources: VecMap<ModuleId, ScopeModuleSource>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScopeModuleSource {
Builtin,
Current,
Import(Region),
}
impl ScopeModules {
pub fn get_id(&self, module_name: &ModuleName) -> Option<ModuleId> {
self.modules.get(module_name).copied()
}
pub fn has_id(&self, module_id: ModuleId) -> bool {
self.sources.contains_key(&module_id)
}
pub fn available_names(&self) -> impl Iterator<Item = &ModuleName> {
self.modules.keys()
}
pub fn insert(
&mut self,
module_name: ModuleName,
module_id: ModuleId,
region: Region,
) -> Result<(), ScopeModuleSource> {
if let Some(existing_module_id) = self.modules.get(&module_name) {
if *existing_module_id == module_id {
return Ok(());
}
return Err(*self.sources.get(existing_module_id).unwrap());
}
self.modules.insert(module_name, module_id);
self.sources
.insert(module_id, ScopeModuleSource::Import(region));
Ok(())
}
pub fn len(&self) -> usize {
debug_assert_eq!(self.modules.len(), self.sources.len());
self.modules.len()
}
pub fn is_empty(&self) -> bool {
debug_assert_eq!(self.modules.is_empty(), self.sources.is_empty());
self.modules.is_empty()
}
pub fn truncate(&mut self, len: usize) {
self.modules.truncate(len);
self.sources.truncate(len);
pub fn iter(&self) -> impl ExactSizeIterator<Item = (ModuleId, &ModuleName)> {
self.by_id
.iter()
.enumerate()
.map(|(index, name)| (ModuleId::from_zero_indexed(index), name))
}
}
@ -782,7 +727,7 @@ impl IdentIds {
pub fn get_name_str_res(&self, ident_id: IdentId) -> ModuleResult<&str> {
self.get_name(ident_id)
.with_context(|| IdentIdNotFoundSnafu {
.ok_or_else(|| ModuleError::IdentIdNotFound {
ident_id,
ident_ids_str: format!("{self:?}"),
})
@ -1031,32 +976,6 @@ macro_rules! define_builtins {
}
}
impl ScopeModules {
pub fn new(home_id: ModuleId, home_name: ModuleName) -> Self {
// +1 because the user will be compiling at least 1 non-builtin module!
let capacity = $total + 1;
let mut modules = VecMap::with_capacity(capacity);
let mut sources = VecMap::with_capacity(capacity);
modules.insert(home_name, home_id);
sources.insert(home_id, ScopeModuleSource::Current);
let mut insert_both = |id: ModuleId, name_str: &'static str| {
let name: ModuleName = name_str.into();
modules.insert(name, id);
sources.insert(id, ScopeModuleSource::Builtin);
};
$(
insert_both(ModuleId::$module_const, $module_name);
)+
ScopeModules { modules, sources }
}
}
impl<'a> Default for PackageModuleIds<'a> {
fn default() -> Self {
// +1 because the user will be compiling at least 1 non-builtin module!
@ -1556,6 +1475,8 @@ define_builtins! {
5 RESULT_WITH_DEFAULT: "withDefault"
6 RESULT_TRY: "try"
7 RESULT_IS_OK: "isOk"
8 RESULT_MAP_BOTH: "mapBoth"
9 RESULT_MAP_TWO: "map2"
}
8 DICT: "Dict" => {
0 DICT_DICT: "Dict" exposed_type=true // the Dict.Dict type alias

View file

@ -4443,6 +4443,15 @@ pub fn with_hole<'a>(
specialize_naked_symbol(env, variable, procs, layout_cache, assigned, hole, symbol)
}
ParamsVar { .. } => {
unimplemented!("module params code generation")
}
ImportParams(_, _, Some((_, value))) => {
with_hole(env, *value, variable, procs, layout_cache, assigned, hole)
}
ImportParams(_, _, None) => {
internal_error!("Missing module params should've been dropped by now");
}
AbilityMember(member, specialization_id, specialization_var) => {
let specialization_symbol = late_resolve_ability_specialization(
env,

View file

@ -392,6 +392,15 @@ pub enum StrLiteral<'a> {
Block(&'a [&'a [StrSegment<'a>]]),
}
/// Values that can be tried, extracting success values or "returning early" on failure
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TryTarget {
/// Tasks suffixed with ! are `Task.await`ed
Task,
/// Results suffixed with ? are `Result.try`ed
Result,
}
/// A parsed expression. This uses lifetimes extensively for two reasons:
///
/// 1. It uses Bump::alloc for all allocations, which returns a reference.
@ -423,11 +432,17 @@ pub enum Expr<'a> {
/// e.g. `.foo` or `.0`
AccessorFunction(Accessor<'a>),
/// Update the value of a field in a record, e.g. `&foo`
RecordUpdater(&'a str),
/// Look up exactly one field on a tuple, e.g. `(x, y).1`.
TupleAccess(&'a Expr<'a>, &'a str),
/// Task await bang - i.e. the ! in `File.readUtf8! path`
TaskAwaitBang(&'a Expr<'a>),
/// Early return on failures - e.g. the ! in `File.readUtf8! path`
TrySuffix {
target: TryTarget,
expr: &'a Expr<'a>,
},
// Collection Literals
List(Collection<'a, &'a Loc<Expr<'a>>>),
@ -555,9 +570,9 @@ pub fn split_loc_exprs_around<'a>(
/// Checks if the bang suffix is applied only at the top level of expression
pub fn is_top_level_suffixed(expr: &Expr) -> bool {
// TODO: should we check BinOps with pizza where the last expression is TaskAwaitBang?
// TODO: should we check BinOps with pizza where the last expression is TrySuffix?
match expr {
Expr::TaskAwaitBang(..) => true,
Expr::TrySuffix { .. } => true,
Expr::Apply(a, _, _) => is_top_level_suffixed(&a.value),
Expr::SpaceBefore(a, _) => is_top_level_suffixed(a),
Expr::SpaceAfter(a, _) => is_top_level_suffixed(a),
@ -571,7 +586,7 @@ pub fn is_expr_suffixed(expr: &Expr) -> bool {
// expression without arguments, `read!`
Expr::Var { .. } => false,
Expr::TaskAwaitBang(..) => true,
Expr::TrySuffix { .. } => true,
// expression with arguments, `line! "Foo"`
Expr::Apply(sub_loc_expr, apply_args, _) => {
@ -624,6 +639,7 @@ pub fn is_expr_suffixed(expr: &Expr) -> bool {
Expr::SingleQuote(_) => false,
Expr::RecordAccess(a, _) => is_expr_suffixed(a),
Expr::AccessorFunction(_) => false,
Expr::RecordUpdater(_) => false,
Expr::TupleAccess(a, _) => is_expr_suffixed(a),
Expr::List(items) => items.iter().any(|x| is_expr_suffixed(&x.value)),
Expr::RecordUpdate { update, fields } => {
@ -995,7 +1011,7 @@ impl<'a, 'b> RecursiveValueDefIter<'a, 'b> {
}
RecordAccess(expr, _)
| TupleAccess(expr, _)
| TaskAwaitBang(expr)
| TrySuffix { expr, .. }
| SpaceBefore(expr, _)
| SpaceAfter(expr, _)
| ParensAround(expr) => expr_stack.push(expr),
@ -1012,6 +1028,7 @@ impl<'a, 'b> RecursiveValueDefIter<'a, 'b> {
| Str(_)
| SingleQuote(_)
| AccessorFunction(_)
| RecordUpdater(_)
| Var { .. }
| Underscore(_)
| Crash
@ -1068,7 +1085,7 @@ impl<'a, 'b> Iterator for RecursiveValueDefIter<'a, 'b> {
params,
}) => {
if let Some(ModuleImportParams { before: _, params }) = params {
for loc_assigned_field in params.items {
for loc_assigned_field in params.value.items {
if let Some(expr) = loc_assigned_field.value.value() {
self.push_pending_from_expr(&expr.value);
}
@ -1116,7 +1133,7 @@ pub struct ModuleImport<'a> {
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ModuleImportParams<'a> {
pub before: &'a [CommentOrNewline<'a>],
pub params: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>,
pub params: Loc<Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
@ -2475,6 +2492,7 @@ impl<'a> Malformed for Expr<'a> {
Num(_) |
NonBase10Int { .. } |
AccessorFunction(_) |
RecordUpdater(_) |
Var { .. } |
Underscore(_) |
Tag(_) |
@ -2486,7 +2504,7 @@ impl<'a> Malformed for Expr<'a> {
RecordAccess(inner, _) |
TupleAccess(inner, _) |
TaskAwaitBang(inner) => inner.is_malformed(),
TrySuffix { expr: inner, .. } => inner.is_malformed(),
List(items) => items.is_malformed(),

View file

@ -3,7 +3,7 @@ use crate::ast::{
Implements, ImplementsAbilities, ImportAlias, ImportAsKeyword, ImportExposingKeyword,
ImportedModuleName, IngestedFileAnnotation, IngestedFileImport, ModuleImport,
ModuleImportParams, OldRecordBuilderField, Pattern, Spaceable, Spaced, Spaces, SpacesBefore,
TypeAnnotation, TypeDef, TypeHeader, ValueDef,
TryTarget, TypeAnnotation, TypeDef, TypeHeader, ValueDef,
};
use crate::blankspace::{
loc_space0_e, require_newline_or_eof, space0_after_e, space0_around_ee, space0_before_e,
@ -169,7 +169,12 @@ fn record_field_access_chain<'a>() -> impl Parser<'a, Vec<'a, Suffix<'a>>, EExpr
)
)
),
map(byte(b'!', EExpr::Access), |_| Suffix::TaskAwaitBang),
map(byte(b'!', EExpr::Access), |_| Suffix::TrySuffix(
TryTarget::Task
)),
map(byte(b'?', EExpr::Access), |_| Suffix::TrySuffix(
TryTarget::Result
)),
))
}
@ -892,10 +897,10 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams<
then(
and(
backtrackable(space0_e(EImportParams::Indent)),
specialize_err(EImportParams::Record, record_help()),
specialize_err(EImportParams::Record, loc(record_help())),
),
|arena, state, _, (before, record): (_, RecordHelp<'a>)| {
if let Some(prefix) = record.prefix {
|arena, state, _, (before, loc_record): (_, Loc<RecordHelp<'a>>)| {
if let Some(prefix) = loc_record.value.prefix {
match prefix {
(update, RecordHelpPrefix::Update) => {
return Err((
@ -912,21 +917,27 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams<
}
}
let params = record.fields.map_items_result(arena, |loc_field| {
match loc_field.value.to_assigned_field(arena) {
Ok(AssignedField::IgnoredValue(_, _, _)) => Err((
MadeProgress,
EImportParams::RecordIgnoredFieldFound(loc_field.region),
)),
Ok(field) => Ok(Loc::at(loc_field.region, field)),
Err(FoundApplyValue) => Err((
MadeProgress,
EImportParams::RecordApplyFound(loc_field.region),
)),
}
})?;
let params = loc_record
.value
.fields
.map_items_result(arena, |loc_field| {
match loc_field.value.to_assigned_field(arena) {
Ok(AssignedField::IgnoredValue(_, _, _)) => Err((
MadeProgress,
EImportParams::RecordIgnoredFieldFound(loc_field.region),
)),
Ok(field) => Ok(Loc::at(loc_field.region, field)),
Err(FoundApplyValue) => Err((
MadeProgress,
EImportParams::RecordApplyFound(loc_field.region),
)),
}
})?;
let import_params = ModuleImportParams { before, params };
let import_params = ModuleImportParams {
before,
params: Loc::at(loc_record.region, params),
};
Ok((MadeProgress, import_params, state))
},
@ -2170,8 +2181,9 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
| Expr::SingleFieldRecordBuilder(_)
| Expr::OptionalFieldInRecordBuilder(_, _)
| Expr::RecordUpdate { .. }
| Expr::RecordUpdater(_)
| Expr::UnaryOp(_, _)
| Expr::TaskAwaitBang(..)
| Expr::TrySuffix { .. }
| Expr::Crash
| Expr::OldRecordBuilder(..)
| Expr::RecordBuilder { .. } => return Err(()),
@ -3240,7 +3252,7 @@ pub fn join_alias_to_body<'a>(
/// 2. The beginning of a function call (e.g. `foo bar baz`)
/// 3. The beginning of a definition (e.g. `foo =`)
/// 4. The beginning of a type annotation (e.g. `foo :`)
/// 5. A reserved keyword (e.g. `if ` or `case `), meaning we should do something else.
/// 5. A reserved keyword (e.g. `if ` or `when `), meaning we should do something else.
fn assign_or_destructure_identifier<'a>() -> impl Parser<'a, Ident<'a>, EExpr<'a>> {
parse_ident
@ -3302,6 +3314,7 @@ fn ident_to_expr<'a>(arena: &'a Bump, src: Ident<'a>) -> Expr<'a> {
answer
}
Ident::AccessorFunction(string) => Expr::AccessorFunction(string),
Ident::RecordUpdaterFunction(string) => Expr::RecordUpdater(string),
Ident::Malformed(string, problem) => Expr::MalformedIdent(string, problem),
}
}
@ -3743,7 +3756,10 @@ fn apply_expr_access_chain<'a>(
Suffix::Accessor(Accessor::TupleIndex(field)) => {
Expr::TupleAccess(arena.alloc(value), field)
}
Suffix::TaskAwaitBang => Expr::TaskAwaitBang(arena.alloc(value)),
Suffix::TrySuffix(target) => Expr::TrySuffix {
target,
expr: arena.alloc(value),
},
})
}

View file

@ -123,7 +123,7 @@ fn module_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> {
fn module_params<'a>() -> impl Parser<'a, ModuleParams<'a>, EParams<'a>> {
record!(ModuleParams {
params: specialize_err(EParams::Pattern, record_pattern_fields()),
pattern: specialize_err(EParams::Pattern, loc(record_pattern_fields())),
before_arrow: skip_second(
space0_e(EParams::BeforeArrow),
loc(two_bytes(b'-', b'>', EParams::Arrow))
@ -943,6 +943,7 @@ pub enum HeaderType<'a> {
Builtin {
name: ModuleName<'a>,
exposes: &'a [Loc<ExposedName<'a>>],
opt_params: Option<ModuleParams<'a>>,
},
Package {
/// usually something other than `pf`
@ -966,6 +967,7 @@ pub enum HeaderType<'a> {
Module {
name: ModuleName<'a>,
exposes: &'a [Loc<ExposedName<'a>>],
opt_params: Option<ModuleParams<'a>>,
},
}
@ -990,11 +992,54 @@ impl<'a> HeaderType<'a> {
}
}
pub fn get_params(&self) -> &Option<ModuleParams<'a>> {
match self {
Self::Module {
opt_params,
name: _,
exposes: _,
}
| Self::Builtin {
opt_params,
name: _,
exposes: _,
} => opt_params,
Self::App {
provides: _,
to_platform: _,
}
| Self::Package {
config_shorthand: _,
exposes: _,
exposes_ids: _,
}
| Self::Hosted {
name: _,
exposes: _,
}
| Self::Platform {
opt_app_module_id: _,
provides: _,
requires: _,
requires_types: _,
exposes: _,
exposes_ids: _,
config_shorthand: _,
} => &None,
}
}
pub fn to_maybe_builtin(self, module_id: ModuleId) -> Self {
match self {
HeaderType::Module { name, exposes } if module_id.is_builtin() => {
HeaderType::Builtin { name, exposes }
}
HeaderType::Module {
name,
exposes,
opt_params,
} if module_id.is_builtin() => HeaderType::Builtin {
name,
exposes,
opt_params,
},
_ => self,
}
}
@ -1139,7 +1184,7 @@ pub struct ModuleHeader<'a> {
#[derive(Clone, Debug, PartialEq)]
pub struct ModuleParams<'a> {
pub params: Collection<'a, Loc<Pattern<'a>>>,
pub pattern: Loc<Collection<'a, Loc<Pattern<'a>>>>,
pub before_arrow: &'a [CommentOrNewline<'a>],
pub after_arrow: &'a [CommentOrNewline<'a>],
}

View file

@ -1,3 +1,4 @@
use crate::ast::TryTarget;
use crate::parser::Progress::{self, *};
use crate::parser::{BadInputError, EExpr, ParseResult, Parser};
use crate::state::State;
@ -45,42 +46,12 @@ pub enum Ident<'a> {
},
/// `.foo { foo: 42 }` or `.1 (1, 2, 3)`
AccessorFunction(Accessor<'a>),
/// `&foo { foo: 42 } 3`
RecordUpdaterFunction(&'a str),
/// .Foo or foo. or something like foo.Bar
Malformed(&'a str, BadIdent),
}
impl<'a> Ident<'a> {
pub fn len(&self) -> usize {
use self::Ident::*;
match self {
Tag(string) | OpaqueRef(string) => string.len(),
Access {
module_name, parts, ..
} => {
let mut len = if module_name.is_empty() {
0
} else {
module_name.len() + 1
// +1 for the dot
};
for part in parts.iter() {
len += part.len() + 1 // +1 for the dot
}
len - 1
}
AccessorFunction(string) => string.len(),
Malformed(string, _) => string.len(),
}
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
}
/// This could be:
///
/// * A record field, e.g. "email" in `.email` or in `email:`
@ -271,6 +242,7 @@ pub enum BadIdent {
WeirdDotAccess(Position),
WeirdDotQualified(Position),
StrayDot(Position),
StrayAmpersand(Position),
BadOpaqueRef(Position),
QualifiedTupleAccessor(Position),
}
@ -377,7 +349,7 @@ impl<'a> Accessor<'a> {
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Suffix<'a> {
Accessor(Accessor<'a>),
TaskAwaitBang,
TrySuffix(TryTarget),
}
/// a `.foo` or `.1` accessor function
@ -415,6 +387,18 @@ fn chomp_accessor(buffer: &[u8], pos: Position) -> Result<Accessor, BadIdent> {
}
}
/// a `&foo` record updater function
fn chomp_record_updater(buffer: &[u8], pos: Position) -> Result<&str, BadIdent> {
// assumes the leading `&` has been chomped already
match chomp_lowercase_part(buffer) {
Ok(name) => Ok(name),
Err(_) => {
// we've already made progress with the initial `&`
Err(BadIdent::StrayAmpersand(pos.bump_column(1)))
}
}
}
/// a `@Token` opaque
fn chomp_opaque_ref(buffer: &[u8], pos: Position) -> Result<&str, BadIdent> {
// assumes the leading `@` has NOT been chomped already
@ -457,6 +441,14 @@ fn chomp_identifier_chain<'a>(
}
Err(fail) => return Err((1, fail)),
},
'&' => match chomp_record_updater(&buffer[1..], pos) {
Ok(updater) => {
let bytes_parsed = 1 + updater.len();
return Ok((bytes_parsed as u32, Ident::RecordUpdaterFunction(updater)));
}
// return 0 bytes consumed on failure to allow parsing &&
Err(fail) => return Err((0, fail)),
},
'@' => match chomp_opaque_ref(buffer, pos) {
Ok(tagname) => {
let bytes_parsed = tagname.len();

View file

@ -13,10 +13,10 @@ pub mod header;
pub mod highlight;
pub mod ident;
pub mod keyword;
pub mod normalize;
pub mod number_literal;
pub mod pattern;
pub mod problems;
pub mod remove_spaces;
pub mod src64;
pub mod state;
pub mod string_literal;

View file

@ -577,6 +577,7 @@ pub enum EPattern<'a> {
AsIndentStart(Position),
AccessorFunction(Position),
RecordUpdaterFunction(Position),
}
#[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -25,6 +25,7 @@ pub enum PatternType {
DefExpr,
FunctionArg,
WhenBranch,
ModuleParams,
}
pub fn closure_param<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>> {
@ -435,6 +436,10 @@ fn loc_ident_pattern_help<'a>(
MadeProgress,
EPattern::AccessorFunction(loc_ident.region.start()),
)),
Ident::RecordUpdaterFunction(_string) => Err((
MadeProgress,
EPattern::RecordUpdaterFunction(loc_ident.region.start()),
)),
Ident::Malformed(malformed, problem) => {
debug_assert!(!malformed.is_empty());

View file

@ -4,7 +4,7 @@ use std::path::PathBuf;
use roc_collections::all::MutSet;
use roc_module::called_via::BinOp;
use roc_module::ident::{Ident, Lowercase, ModuleName, TagName};
use roc_module::symbol::{ModuleId, ScopeModuleSource, Symbol};
use roc_module::symbol::{ModuleId, Symbol};
use roc_parse::ast::Base;
use roc_parse::pattern::PatternType;
use roc_region::all::{Loc, Region};
@ -53,6 +53,7 @@ pub enum Problem {
new_symbol: Symbol,
existing_symbol_region: Region,
},
DeprecatedBackpassing(Region),
/// First symbol is the name of the closure with that argument
/// Bool is whether the closure is anonymous
/// Second symbol is the name of the argument that is unused
@ -237,6 +238,13 @@ pub enum Problem {
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScopeModuleSource {
Builtin,
Current,
Import(Region),
}
impl Problem {
pub fn severity(&self) -> Severity {
use Severity::{Fatal, RuntimeError, Warning};
@ -249,6 +257,7 @@ impl Problem {
Problem::ExplicitBuiltinImport(_, _) => Warning,
Problem::ExplicitBuiltinTypeImport(_, _) => Warning,
Problem::ImportShadowsSymbol { .. } => RuntimeError,
Problem::DeprecatedBackpassing(_) => Warning,
Problem::ExposedButNotDefined(_) => RuntimeError,
Problem::UnusedArgument(_, _, _, _) => Warning,
Problem::UnusedBranchDef(_, _) => Warning,
@ -331,6 +340,7 @@ impl Problem {
| Problem::ExplicitBuiltinImport(_, region)
| Problem::ExplicitBuiltinTypeImport(_, region)
| Problem::ImportShadowsSymbol { region, .. }
| Problem::DeprecatedBackpassing(region)
| Problem::UnusedArgument(_, _, _, region)
| Problem::UnusedBranchDef(_, region)
| Problem::PrecedenceProblem(PrecedenceProblem::BothNonAssociative(region, _, _))

View file

@ -80,6 +80,10 @@ pub struct SolveConfig<'a> {
#[cfg(debug_assertions)]
/// The checkmate collector for this module.
pub checkmate: Option<roc_checkmate::Collector>,
/// Module params
pub params_pattern: Option<roc_can::pattern::Pattern>,
pub module_params_vars: VecMap<ModuleId, Variable>,
}
pub struct SolveOutput {
@ -144,6 +148,7 @@ pub fn exposed_types_storage_subs(
home: ModuleId,
solved_subs: &mut Solved<Subs>,
exposed_vars_by_symbol: &[(Symbol, Variable)],
params_var: Option<Variable>,
solved_implementations: &ResolvedImplementations,
abilities_store: &AbilitiesStore,
) -> ExposedTypesStorageSubs {
@ -156,6 +161,9 @@ pub fn exposed_types_storage_subs(
stored_vars_by_symbol.insert(*symbol, new_var);
}
let stored_params_var =
params_var.map(|params_var| storage_subs.import_variable_from(subs, params_var).variable);
let mut stored_specialization_lambda_set_vars =
VecMap::with_capacity(solved_implementations.len());
@ -213,6 +221,7 @@ pub fn exposed_types_storage_subs(
stored_vars_by_symbol,
stored_specialization_lambda_set_vars,
stored_ability_member_vars,
stored_params_var,
}
}

View file

@ -16,11 +16,12 @@ use roc_can::abilities::{AbilitiesStore, MemberSpecializationInfo};
use roc_can::constraint::Constraint::{self, *};
use roc_can::constraint::{Cycle, LetConstraint, OpportunisticResolve};
use roc_can::expected::{Expected, PExpected};
use roc_collections::VecMap;
use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)]
use roc_debug_flags::ROC_VERIFY_RIGID_LET_GENERALIZED;
use roc_error_macros::internal_error;
use roc_module::symbol::Symbol;
use roc_module::symbol::{ModuleId, Symbol};
use roc_problem::can::CycleEntry;
use roc_region::all::Loc;
use roc_solve_problem::TypeError;
@ -129,15 +130,13 @@ fn run_help(
exposed_by_module,
derived_module,
function_kind,
params_pattern,
module_params_vars,
..
} = config;
let mut pools = Pools::default();
let state = State {
scope: Scope::default(),
mark: Mark::NONE.next(),
};
let rank = Rank::toplevel();
let arena = Bump::new();
@ -178,7 +177,6 @@ fn run_help(
let state = solve(
&mut env,
types,
state,
rank,
problems,
aliases,
@ -186,6 +184,8 @@ fn run_help(
abilities_store,
&mut obligation_cache,
&mut awaiting_specializations,
params_pattern,
module_params_vars,
);
RunSolveOutput {
@ -236,7 +236,6 @@ enum Work<'a> {
fn solve(
env: &mut InferenceEnv,
mut can_types: Types,
mut state: State,
rank: Rank,
problems: &mut Vec<TypeError>,
aliases: &mut Aliases,
@ -244,15 +243,24 @@ fn solve(
abilities_store: &mut AbilitiesStore,
obligation_cache: &mut ObligationCache,
awaiting_specializations: &mut AwaitingSpecializations,
params_pattern: Option<roc_can::pattern::Pattern>,
module_params_vars: VecMap<ModuleId, Variable>,
) -> State {
let scope = Scope::new(params_pattern);
let initial = Work::Constraint {
scope: &Scope::default(),
scope: &scope.clone(),
rank,
constraint,
};
let mut stack = vec![initial];
let mut state = State {
scope,
mark: Mark::NONE.next(),
};
while let Some(work_item) = stack.pop() {
let (scope, rank, constraint) = match work_item {
Work::Constraint {
@ -1392,6 +1400,86 @@ fn solve(
}
}
}
ImportParams(opt_provided, module_id, region) => {
match (module_params_vars.get(module_id), opt_provided) {
(Some(expected), Some(provided)) => {
let actual = either_type_index_to_var(
env,
rank,
problems,
abilities_store,
obligation_cache,
&mut can_types,
aliases,
*provided,
);
match unify(
&mut env.uenv(),
actual,
*expected,
UnificationMode::EQ,
Polarity::OF_VALUE,
) {
Success {
vars,
must_implement_ability,
lambda_sets_to_specialize,
extra_metadata: _,
} => {
env.introduce(rank, &vars);
problems.extend(obligation_cache.check_obligations(
env.subs,
abilities_store,
must_implement_ability,
AbilityImplError::DoesNotImplement,
));
compact_lambdas_and_check_obligations(
env,
problems,
abilities_store,
obligation_cache,
awaiting_specializations,
lambda_sets_to_specialize,
);
state
}
Failure(vars, actual_type, expected_type, _) => {
env.introduce(rank, &vars);
problems.push(TypeError::ModuleParamsMismatch(
*region,
*module_id,
actual_type,
expected_type,
));
state
}
}
}
(Some(expected), None) => {
let expected_type = env.uenv().var_to_error_type(*expected, Polarity::Neg);
problems.push(TypeError::MissingModuleParams(
*region,
*module_id,
expected_type,
));
state
}
(None, Some(_)) => {
problems.push(TypeError::UnexpectedModuleParams(*region, *module_id));
state
}
(None, None) => state,
}
}
};
}

View file

@ -2,13 +2,43 @@ use roc_module::symbol::Symbol;
use roc_types::subs::Variable;
/// The scope of the solver, as symbols are introduced.
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct Scope {
symbols: Vec<Symbol>,
variables: Vec<Variable>,
}
impl Scope {
pub fn new(params_pattern: Option<roc_can::pattern::Pattern>) -> Self {
match params_pattern {
Some(params_pattern) => match params_pattern {
roc_can::pattern::Pattern::RecordDestructure {
whole_var: _,
ext_var: _,
destructs,
} => {
let mut symbols = Vec::with_capacity(destructs.len());
let mut variables = Vec::with_capacity(destructs.len());
for destruct in destructs {
symbols.push(destruct.value.symbol);
variables.push(destruct.value.var);
}
Self { symbols, variables }
}
_ => unreachable!(
"other pattern types should have parsed: {:?}",
params_pattern
),
},
None => Self {
symbols: Vec::default(),
variables: Vec::default(),
},
}
}
pub fn vars_by_symbol(&self) -> impl Iterator<Item = (Symbol, Variable)> + '_ {
let it1 = self.symbols.iter().copied();
let it2 = self.variables.iter().copied();

View file

@ -2,7 +2,10 @@
use std::{path::PathBuf, str::Utf8Error};
use roc_can::expected::{Expected, PExpected};
use roc_module::{ident::Lowercase, symbol::Symbol};
use roc_module::{
ident::Lowercase,
symbol::{ModuleId, Symbol},
};
use roc_problem::{can::CycleEntry, Severity};
use roc_region::all::Region;
@ -33,6 +36,9 @@ pub enum TypeError {
},
IngestedFileBadUtf8(Box<PathBuf>, Utf8Error),
IngestedFileUnsupportedType(Box<PathBuf>, ErrorType),
UnexpectedModuleParams(Region, ModuleId),
MissingModuleParams(Region, ModuleId, ErrorType),
ModuleParamsMismatch(Region, ModuleId, ErrorType, ErrorType),
}
impl TypeError {
@ -52,6 +58,9 @@ impl TypeError {
TypeError::Exhaustive(exhtv) => exhtv.severity(),
TypeError::StructuralSpecialization { .. } => RuntimeError,
TypeError::WrongSpecialization { .. } => RuntimeError,
TypeError::UnexpectedModuleParams(..) => Warning,
TypeError::MissingModuleParams(..) => RuntimeError,
TypeError::ModuleParamsMismatch(..) => RuntimeError,
TypeError::IngestedFileBadUtf8(..) => Fatal,
TypeError::IngestedFileUnsupportedType(..) => Fatal,
}
@ -66,7 +75,10 @@ impl TypeError {
| TypeError::BadExprMissingAbility(region, ..)
| TypeError::StructuralSpecialization { region, .. }
| TypeError::WrongSpecialization { region, .. }
| TypeError::BadPatternMissingAbility(region, ..) => Some(*region),
| TypeError::BadPatternMissingAbility(region, ..)
| TypeError::UnexpectedModuleParams(region, ..)
| TypeError::MissingModuleParams(region, ..)
| TypeError::ModuleParamsMismatch(region, ..) => Some(*region),
TypeError::UnfulfilledAbility(ab, ..) => ab.region(),
TypeError::Exhaustive(e) => Some(e.region()),
TypeError::CircularDef(c) => c.first().map(|ce| ce.symbol_region),

View file

@ -405,7 +405,7 @@ fn check_derived_typechecks_and_golden(
let mut def_types = Default::default();
let mut rigid_vars = Default::default();
let mut flex_vars = Default::default();
let (import_variables, abilities_store) = add_imports(
let (import_variables, imported_param_vars, abilities_store) = add_imports(
test_module,
&mut constraints,
&mut test_subs,
@ -438,6 +438,8 @@ fn check_derived_typechecks_and_golden(
pending_derives: Default::default(),
exposed_by_module: &exposed_for_module.exposed_by_module,
derived_module: Default::default(),
params_pattern: None,
module_params_vars: imported_param_vars,
#[cfg(debug_assertions)]
checkmate: None,

View file

@ -2479,39 +2479,6 @@ fn expanded_result() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn backpassing_result() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
a : Result I64 Str
a = Ok 1
f = \x -> Ok (x + 1)
g = \y -> Ok (y * 2)
main : I64
main =
helper =
x <- Result.try a
y <- Result.try (f x)
z <- Result.try (g y)
Ok z
helper
|> Result.withDefault 0
"#
),
4,
i64
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[should_panic(expected = "Shadowing { original_region: @55-56, shadow: @72-73 Ident")]

View file

@ -885,6 +885,38 @@ fn update_single_element_record() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn update_record_shorthand() {
assert_evals_to!(
indoc!(
r"
rec = { foo: 42, bar: 2.46f64 }
rec |> &foo (rec.foo + 1)
"
),
(2.46, 43),
(f64, i64)
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
fn update_single_element_record_shorthand() {
assert_evals_to!(
indoc!(
r"
rec = { foo: 42}
&foo rec (rec.foo + 1)
"
),
43,
i64
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn booleans_in_record() {

View file

@ -354,3 +354,85 @@ fn roc_result_after_err() {
RocResult<RocStr, i64>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn roc_result_map_both() {
assert_evals_to!(
indoc!(
r#"
result : Result I64 I64
result = Ok 42
result |> Result.mapBoth Num.toStr Num.toStr
"#
),
RocResult::ok(RocStr::from("42")),
RocResult<RocStr, RocStr>
);
assert_evals_to!(
indoc!(
r#"
result : Result I64 I64
result = Err 24
result |> Result.mapBoth Num.toStr Num.toStr
"#
),
RocResult::err(RocStr::from("24")),
RocResult<RocStr, RocStr>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn roc_result_map_two() {
assert_evals_to!(
indoc!(
r#"
first : Result I64 Str
first = Ok 24
second : Result I64 Str
second = Ok -10
Result.map2 first second \a, b -> a + b
"#
),
RocResult::ok(14i64),
RocResult<i64, RocStr>
);
assert_evals_to!(
indoc!(
r#"
first : Result I64 Str
first = Err "foo"
second : Result I64 Str
second = Err "bar"
Result.map2 first second \a, b -> a + b
"#
),
RocResult::err(RocStr::from("foo")),
RocResult<i64, RocStr>
);
assert_evals_to!(
indoc!(
r#"
first : Result I64 Str
first = Ok 42
second : Result I64 Str
second = Err "bar"
Result.map2 first second \a, b -> a + b
"#
),
RocResult::err(RocStr::from("bar")),
RocResult<i64, RocStr>
);
}

View file

@ -2,93 +2,93 @@ procedure Bool.11 (#Attr.2, #Attr.3):
let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3;
ret Bool.23;
procedure List.107 (List.536, List.537, List.538):
let List.640 : U64 = 0i64;
let List.641 : U64 = CallByName List.6 List.536;
let List.639 : [C U64, C U64] = CallByName List.80 List.536 List.537 List.538 List.640 List.641;
ret List.639;
procedure List.110 (List.539, List.540, List.541):
let List.643 : U64 = 0i64;
let List.644 : U64 = CallByName List.6 List.539;
let List.642 : [C U64, C U64] = CallByName List.80 List.539 List.540 List.541 List.643 List.644;
ret List.642;
procedure List.26 (List.204, List.205, List.206):
let List.633 : [C U64, C U64] = CallByName List.107 List.204 List.205 List.206;
let List.636 : U8 = 1i64;
let List.637 : U8 = GetTagId List.633;
let List.638 : Int1 = lowlevel Eq List.636 List.637;
if List.638 then
let List.207 : U64 = UnionAtIndex (Id 1) (Index 0) List.633;
ret List.207;
procedure List.26 (List.207, List.208, List.209):
let List.636 : [C U64, C U64] = CallByName List.110 List.207 List.208 List.209;
let List.639 : U8 = 1i64;
let List.640 : U8 = GetTagId List.636;
let List.641 : Int1 = lowlevel Eq List.639 List.640;
if List.641 then
let List.210 : U64 = UnionAtIndex (Id 1) (Index 0) List.636;
ret List.210;
else
let List.208 : U64 = UnionAtIndex (Id 0) (Index 0) List.633;
ret List.208;
let List.211 : U64 = UnionAtIndex (Id 0) (Index 0) List.636;
ret List.211;
procedure List.38 (List.392, List.393):
let List.632 : U64 = CallByName List.6 List.392;
let List.394 : U64 = CallByName Num.77 List.632 List.393;
let List.622 : List U8 = CallByName List.43 List.392 List.394;
ret List.622;
procedure List.43 (List.390, List.391):
let List.630 : U64 = CallByName List.6 List.390;
let List.629 : U64 = CallByName Num.77 List.630 List.391;
let List.624 : {U64, U64} = Struct {List.391, List.629};
let List.623 : List U8 = CallByName List.49 List.390 List.624;
ret List.623;
procedure List.49 (List.468, List.469):
let List.626 : U64 = StructAtIndex 1 List.469;
let List.627 : U64 = StructAtIndex 0 List.469;
let List.625 : List U8 = CallByName List.72 List.468 List.626 List.627;
procedure List.38 (List.395, List.396):
let List.635 : U64 = CallByName List.6 List.395;
let List.397 : U64 = CallByName Num.77 List.635 List.396;
let List.625 : List U8 = CallByName List.43 List.395 List.397;
ret List.625;
procedure List.6 (#Attr.2):
let List.631 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.631;
procedure List.43 (List.393, List.394):
let List.633 : U64 = CallByName List.6 List.393;
let List.632 : U64 = CallByName Num.77 List.633 List.394;
let List.627 : {U64, U64} = Struct {List.394, List.632};
let List.626 : List U8 = CallByName List.49 List.393 List.627;
ret List.626;
procedure List.66 (#Attr.2, #Attr.3):
let List.654 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.654;
procedure List.72 (#Attr.2, #Attr.3, #Attr.4):
let List.628 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4;
procedure List.49 (List.471, List.472):
let List.629 : U64 = StructAtIndex 1 List.472;
let List.630 : U64 = StructAtIndex 0 List.472;
let List.628 : List U8 = CallByName List.72 List.471 List.629 List.630;
ret List.628;
procedure List.6 (#Attr.2):
let List.634 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.634;
procedure List.66 (#Attr.2, #Attr.3):
let List.657 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.657;
procedure List.72 (#Attr.2, #Attr.3, #Attr.4):
let List.631 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4;
ret List.631;
procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4):
joinpoint List.642 List.539 List.540 List.541 List.542 List.543:
let List.644 : Int1 = CallByName Num.22 List.542 List.543;
if List.644 then
let List.653 : U8 = CallByName List.66 List.539 List.542;
let List.645 : [C U64, C U64] = CallByName Test.4 List.540 List.653;
let List.650 : U8 = 1i64;
let List.651 : U8 = GetTagId List.645;
let List.652 : Int1 = lowlevel Eq List.650 List.651;
if List.652 then
let List.544 : U64 = UnionAtIndex (Id 1) (Index 0) List.645;
let List.648 : U64 = 1i64;
let List.647 : U64 = CallByName Num.51 List.542 List.648;
jump List.642 List.539 List.544 List.541 List.647 List.543;
joinpoint List.645 List.542 List.543 List.544 List.545 List.546:
let List.647 : Int1 = CallByName Num.22 List.545 List.546;
if List.647 then
let List.656 : U8 = CallByName List.66 List.542 List.545;
let List.648 : [C U64, C U64] = CallByName Test.4 List.543 List.656;
let List.653 : U8 = 1i64;
let List.654 : U8 = GetTagId List.648;
let List.655 : Int1 = lowlevel Eq List.653 List.654;
if List.655 then
let List.547 : U64 = UnionAtIndex (Id 1) (Index 0) List.648;
let List.651 : U64 = 1i64;
let List.650 : U64 = CallByName Num.51 List.545 List.651;
jump List.645 List.542 List.547 List.544 List.650 List.546;
else
dec List.539;
let List.545 : U64 = UnionAtIndex (Id 0) (Index 0) List.645;
let List.649 : [C U64, C U64] = TagId(0) List.545;
ret List.649;
dec List.542;
let List.548 : U64 = UnionAtIndex (Id 0) (Index 0) List.648;
let List.652 : [C U64, C U64] = TagId(0) List.548;
ret List.652;
else
dec List.539;
let List.643 : [C U64, C U64] = TagId(1) List.540;
ret List.643;
dec List.542;
let List.646 : [C U64, C U64] = TagId(1) List.543;
ret List.646;
in
inc #Derived_gen.0;
jump List.642 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4;
jump List.645 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282;
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.283;
procedure Num.77 (#Attr.2, #Attr.3):
let Num.280 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3;
ret Num.282;
procedure Test.1 (Test.2):
let Test.13 : U64 = 0i64;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.281;
procedure Test.4 (Test.27):
let Test.39 : [<rnu>C [<rnu><null>, C *self *self] *self, <null>] = TagId(0) ;

View file

@ -1,59 +1,59 @@
procedure List.18 (List.163, List.164, List.165):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.163;
let List.625 : List {} = CallByName List.92 List.163 List.164 List.165 List.626 List.627;
ret List.625;
procedure List.18 (List.166, List.167, List.168):
let List.629 : U64 = 0i64;
let List.630 : U64 = CallByName List.6 List.166;
let List.628 : List {} = CallByName List.95 List.166 List.167 List.168 List.629 List.630;
ret List.628;
procedure List.275 (List.276, List.277, List.273):
let List.639 : {} = CallByName Test.2 List.277;
let List.638 : List {} = CallByName List.71 List.276 List.639;
ret List.638;
procedure List.5 (List.272, List.273):
let List.274 : U64 = CallByName List.6 List.272;
let List.623 : List {} = CallByName List.68 List.274;
let List.622 : List {} = CallByName List.18 List.272 List.623 List.273;
ret List.622;
procedure List.6 (#Attr.2):
let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.636;
procedure List.66 (#Attr.2, #Attr.3):
let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.68 (#Attr.2):
let List.641 : List {} = lowlevel ListWithCapacity #Attr.2;
procedure List.278 (List.279, List.280, List.276):
let List.642 : {} = CallByName Test.2 List.280;
let List.641 : List {} = CallByName List.71 List.279 List.642;
ret List.641;
procedure List.71 (#Attr.2, #Attr.3):
let List.640 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.640;
procedure List.5 (List.275, List.276):
let List.277 : U64 = CallByName List.6 List.275;
let List.626 : List {} = CallByName List.68 List.277;
let List.625 : List {} = CallByName List.18 List.275 List.626 List.276;
ret List.625;
procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7):
joinpoint List.628 List.166 List.167 List.168 List.169 List.170:
let List.630 : Int1 = CallByName Num.22 List.169 List.170;
if List.630 then
let List.634 : [] = CallByName List.66 List.166 List.169;
let List.171 : List {} = CallByName List.275 List.167 List.634 List.168;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.169 List.633;
jump List.628 List.166 List.171 List.168 List.632 List.170;
procedure List.6 (#Attr.2):
let List.639 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.639;
procedure List.66 (#Attr.2, #Attr.3):
let List.638 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.638;
procedure List.68 (#Attr.2):
let List.644 : List {} = lowlevel ListWithCapacity #Attr.2;
ret List.644;
procedure List.71 (#Attr.2, #Attr.3):
let List.643 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.643;
procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4):
joinpoint List.631 List.169 List.170 List.171 List.172 List.173:
let List.633 : Int1 = CallByName Num.22 List.172 List.173;
if List.633 then
let List.637 : [] = CallByName List.66 List.169 List.172;
let List.174 : List {} = CallByName List.278 List.170 List.637 List.171;
let List.636 : U64 = 1i64;
let List.635 : U64 = CallByName Num.51 List.172 List.636;
jump List.631 List.169 List.174 List.171 List.635 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.3;
jump List.628 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7;
inc #Derived_gen.0;
jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
procedure Test.2 (Test.3):
let Test.7 : {} = Struct {};

View file

@ -1,59 +1,59 @@
procedure List.18 (List.163, List.164, List.165):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.163;
let List.625 : List [] = CallByName List.92 List.163 List.164 List.165 List.626 List.627;
ret List.625;
procedure List.18 (List.166, List.167, List.168):
let List.629 : U64 = 0i64;
let List.630 : U64 = CallByName List.6 List.166;
let List.628 : List [] = CallByName List.95 List.166 List.167 List.168 List.629 List.630;
ret List.628;
procedure List.275 (List.276, List.277, List.273):
let List.639 : [] = CallByName Test.2 List.277;
let List.638 : List [] = CallByName List.71 List.276 List.639;
ret List.638;
procedure List.5 (List.272, List.273):
let List.274 : U64 = CallByName List.6 List.272;
let List.623 : List [] = CallByName List.68 List.274;
let List.622 : List [] = CallByName List.18 List.272 List.623 List.273;
ret List.622;
procedure List.6 (#Attr.2):
let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.636;
procedure List.66 (#Attr.2, #Attr.3):
let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.68 (#Attr.2):
let List.641 : List [] = lowlevel ListWithCapacity #Attr.2;
procedure List.278 (List.279, List.280, List.276):
let List.642 : [] = CallByName Test.2 List.280;
let List.641 : List [] = CallByName List.71 List.279 List.642;
ret List.641;
procedure List.71 (#Attr.2, #Attr.3):
let List.640 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.640;
procedure List.5 (List.275, List.276):
let List.277 : U64 = CallByName List.6 List.275;
let List.626 : List [] = CallByName List.68 List.277;
let List.625 : List [] = CallByName List.18 List.275 List.626 List.276;
ret List.625;
procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7):
joinpoint List.628 List.166 List.167 List.168 List.169 List.170:
let List.630 : Int1 = CallByName Num.22 List.169 List.170;
if List.630 then
let List.634 : [] = CallByName List.66 List.166 List.169;
let List.171 : List [] = CallByName List.275 List.167 List.634 List.168;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.169 List.633;
jump List.628 List.166 List.171 List.168 List.632 List.170;
procedure List.6 (#Attr.2):
let List.639 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.639;
procedure List.66 (#Attr.2, #Attr.3):
let List.638 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.638;
procedure List.68 (#Attr.2):
let List.644 : List [] = lowlevel ListWithCapacity #Attr.2;
ret List.644;
procedure List.71 (#Attr.2, #Attr.3):
let List.643 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.643;
procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4):
joinpoint List.631 List.169 List.170 List.171 List.172 List.173:
let List.633 : Int1 = CallByName Num.22 List.172 List.173;
if List.633 then
let List.637 : [] = CallByName List.66 List.169 List.172;
let List.174 : List [] = CallByName List.278 List.170 List.637 List.171;
let List.636 : U64 = 1i64;
let List.635 : U64 = CallByName Num.51 List.172 List.636;
jump List.631 List.169 List.174 List.171 List.635 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.3;
jump List.628 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7;
inc #Derived_gen.0;
jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
procedure Test.2 (Test.3):
let Test.7 : {} = Struct {};

View file

@ -1,40 +1,40 @@
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : [<r>C {}, C *self {{}, []}] = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : [<r>C {}, C *self {{}, []}] = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633;
let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.636;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.92 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : [] = CallByName List.66 List.166 List.169;
let List.171 : [<r>C {}, C *self {{}, []}] = CallByName Test.29 List.167 List.631 List.168;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : [] = CallByName List.66 List.169 List.172;
let List.174 : [<r>C {}, C *self {{}, []}] = CallByName Test.29 List.170 List.634 List.171;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.11;
jump List.625 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15;
inc #Derived_gen.13;
jump List.628 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
procedure Test.10 (Test.69, #Attr.12):
let Test.72 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12;

View file

@ -2,112 +2,112 @@ procedure Bool.1 ():
let Bool.24 : Int1 = false;
ret Bool.24;
procedure List.18 (List.163, List.164, List.165):
let List.642 : U64 = 0i64;
let List.643 : U64 = CallByName List.6 List.163;
let List.641 : List Str = CallByName List.92 List.163 List.164 List.165 List.642 List.643;
ret List.641;
procedure List.18 (List.166, List.167, List.168):
let List.645 : U64 = 0i64;
let List.646 : U64 = CallByName List.6 List.166;
let List.644 : List Str = CallByName List.95 List.166 List.167 List.168 List.645 List.646;
ret List.644;
procedure List.2 (List.111, List.112):
let List.636 : U64 = CallByName List.6 List.111;
let List.632 : Int1 = CallByName Num.22 List.112 List.636;
if List.632 then
let List.634 : Str = CallByName List.66 List.111 List.112;
inc List.634;
let List.633 : [C {}, C Str] = TagId(1) List.634;
ret List.633;
procedure List.2 (List.114, List.115):
let List.639 : U64 = CallByName List.6 List.114;
let List.635 : Int1 = CallByName Num.22 List.115 List.639;
if List.635 then
let List.637 : Str = CallByName List.66 List.114 List.115;
inc List.637;
let List.636 : [C {}, C Str] = TagId(1) List.637;
ret List.636;
else
let List.631 : {} = Struct {};
let List.630 : [C {}, C Str] = TagId(0) List.631;
ret List.630;
let List.634 : {} = Struct {};
let List.633 : [C {}, C Str] = TagId(0) List.634;
ret List.633;
procedure List.275 (List.276, List.277, List.273):
let List.655 : Str = CallByName Test.10 List.277;
let List.654 : List Str = CallByName List.71 List.276 List.655;
ret List.654;
procedure List.5 (List.272, List.273):
let List.274 : U64 = CallByName List.6 List.272;
let List.639 : List Str = CallByName List.68 List.274;
let List.638 : List Str = CallByName List.18 List.272 List.639 List.273;
ret List.638;
procedure List.6 (#Attr.2):
let List.637 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.637;
procedure List.6 (#Attr.2):
let List.652 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.652;
procedure List.66 (#Attr.2, #Attr.3):
let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.66 (#Attr.2, #Attr.3):
let List.651 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.651;
procedure List.68 (#Attr.2):
let List.657 : List Str = lowlevel ListWithCapacity #Attr.2;
procedure List.278 (List.279, List.280, List.276):
let List.658 : Str = CallByName Test.10 List.280;
let List.657 : List Str = CallByName List.71 List.279 List.658;
ret List.657;
procedure List.5 (List.275, List.276):
let List.277 : U64 = CallByName List.6 List.275;
let List.642 : List Str = CallByName List.68 List.277;
let List.641 : List Str = CallByName List.18 List.275 List.642 List.276;
ret List.641;
procedure List.6 (#Attr.2):
let List.640 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.640;
procedure List.6 (#Attr.2):
let List.655 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.655;
procedure List.66 (#Attr.2, #Attr.3):
let List.638 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.638;
procedure List.66 (#Attr.2, #Attr.3):
let List.654 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.654;
procedure List.68 (#Attr.2):
let List.660 : List Str = lowlevel ListWithCapacity #Attr.2;
ret List.660;
procedure List.71 (#Attr.2, #Attr.3):
let List.656 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.656;
let List.659 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.659;
procedure List.9 (List.383):
let List.629 : U64 = 0i64;
let List.622 : [C {}, C Str] = CallByName List.2 List.383 List.629;
let List.626 : U8 = 1i64;
let List.627 : U8 = GetTagId List.622;
let List.628 : Int1 = lowlevel Eq List.626 List.627;
if List.628 then
let List.384 : Str = UnionAtIndex (Id 1) (Index 0) List.622;
let List.623 : [C {}, C Str] = TagId(1) List.384;
ret List.623;
procedure List.9 (List.386):
let List.632 : U64 = 0i64;
let List.625 : [C {}, C Str] = CallByName List.2 List.386 List.632;
let List.629 : U8 = 1i64;
let List.630 : U8 = GetTagId List.625;
let List.631 : Int1 = lowlevel Eq List.629 List.630;
if List.631 then
let List.387 : Str = UnionAtIndex (Id 1) (Index 0) List.625;
let List.626 : [C {}, C Str] = TagId(1) List.387;
ret List.626;
else
dec List.622;
let List.625 : {} = Struct {};
let List.624 : [C {}, C Str] = TagId(0) List.625;
ret List.624;
dec List.625;
let List.628 : {} = Struct {};
let List.627 : [C {}, C Str] = TagId(0) List.628;
ret List.627;
procedure List.92 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8):
joinpoint List.644 List.166 List.167 List.168 List.169 List.170:
let List.646 : Int1 = CallByName Num.22 List.169 List.170;
if List.646 then
let List.650 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = CallByName List.66 List.166 List.169;
inc List.650;
let List.171 : List Str = CallByName List.275 List.167 List.650 List.168;
let List.649 : U64 = 1i64;
let List.648 : U64 = CallByName Num.51 List.169 List.649;
jump List.644 List.166 List.171 List.168 List.648 List.170;
procedure List.95 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8):
joinpoint List.647 List.169 List.170 List.171 List.172 List.173:
let List.649 : Int1 = CallByName Num.22 List.172 List.173;
if List.649 then
let List.653 : [<r>C List [<r>C List *self, C *self], C [<r>C List *self, C *self]] = CallByName List.66 List.169 List.172;
inc List.653;
let List.174 : List Str = CallByName List.278 List.170 List.653 List.171;
let List.652 : U64 = 1i64;
let List.651 : U64 = CallByName Num.51 List.172 List.652;
jump List.647 List.169 List.174 List.171 List.651 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.4;
jump List.644 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8;
jump List.647 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.283;
procedure Result.5 (Result.10, Result.11):
let Result.37 : U8 = 1i64;
let Result.38 : U8 = GetTagId Result.10;
let Result.39 : Int1 = lowlevel Eq Result.37 Result.38;
if Result.39 then
dec Result.11;
let Result.12 : Str = UnionAtIndex (Id 1) (Index 0) Result.10;
ret Result.12;
procedure Result.5 (Result.13, Result.14):
let Result.57 : U8 = 1i64;
let Result.58 : U8 = GetTagId Result.13;
let Result.59 : Int1 = lowlevel Eq Result.57 Result.58;
if Result.59 then
dec Result.14;
let Result.15 : Str = UnionAtIndex (Id 1) (Index 0) Result.13;
ret Result.15;
else
dec Result.10;
ret Result.11;
dec Result.13;
ret Result.14;
procedure Test.10 (Test.11):
let Test.12 : Str = CallByName Test.2 Test.11;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.280 : I128 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : I128 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.282;
procedure Test.0 ():
let Test.6 : I128 = 18446744073709551616i64;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : U128 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : U128 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.281;
procedure Test.0 ():
let Test.2 : U128 = 170141183460469231731687303715884105728u128;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : U64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.281;
procedure Test.0 ():
let Test.2 : U64 = 9999999999999999999i64;

View file

@ -1,6 +1,6 @@
procedure List.6 (#Attr.2):
let List.622 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.622;
let List.625 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.625;
procedure Test.1 (Test.5):
let Test.2 : I64 = 41i64;

View file

@ -2,47 +2,47 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true;
ret Bool.23;
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633;
let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.636;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.92 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : Int1 = CallByName List.66 List.166 List.169;
let List.171 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName Test.6 List.167 List.631 List.168;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : Int1 = CallByName List.66 List.169 List.172;
let List.174 : [<rnw><null>, C *self Int1, C *self Int1] = CallByName Test.6 List.170 List.634 List.171;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.5;
jump List.625 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9;
jump List.628 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.282;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
procedure Str.3 (#Attr.2, #Attr.3):
let Str.234 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.234;
let Str.238 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.238;
procedure Test.1 (Test.5):
ret Test.5;

View file

@ -2,50 +2,50 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true;
ret Bool.23;
procedure Inspect.246 (Inspect.247, Inspect.245):
procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.323 : Str = "\"";
let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323;
dec Inspect.323;
let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249;
let Inspect.319 : Str = "\"";
let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319;
let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319;
dec Inspect.319;
let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245;
let Inspect.315 : Str = "\"";
let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315;
dec Inspect.315;
ret Inspect.313;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.43 (Inspect.245):
let Inspect.309 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.309;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName Inspect.43 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308;
dec Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.317;
procedure Inspect.60 (Inspect.298):
ret Inspect.298;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.47 (Inspect.249):
let Inspect.313 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.313;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName Inspect.47 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312;
dec Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.321;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232;
let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.236;
procedure Test.1 ():
let Test.4 : Str = "";

View file

@ -1,47 +1,47 @@
procedure Inspect.246 (Inspect.247, Inspect.245):
procedure Inspect.250 (Inspect.251, Inspect.249):
let Inspect.323 : Str = "\"";
let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323;
dec Inspect.323;
let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249;
let Inspect.319 : Str = "\"";
let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319;
let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319;
dec Inspect.319;
let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245;
let Inspect.315 : Str = "\"";
let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315;
dec Inspect.315;
ret Inspect.313;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.43 (Inspect.245):
let Inspect.309 : Str = CallByName Inspect.30 Inspect.245;
ret Inspect.309;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : Str = CallByName Inspect.43 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308;
dec Inspect.308;
ret Inspect.303;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292;
ret Inspect.317;
procedure Inspect.60 (Inspect.298):
ret Inspect.298;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.47 (Inspect.249):
let Inspect.313 : Str = CallByName Inspect.30 Inspect.249;
ret Inspect.313;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : Str = CallByName Inspect.47 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312;
dec Inspect.312;
ret Inspect.307;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.321;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232;
let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.236;
procedure Test.0 ():
let Test.3 : Str = "";

View file

@ -1,37 +1,37 @@
procedure Dict.1 (Dict.723):
let Dict.732 : List {U32, U32} = Array [];
let Dict.733 : List {[], []} = Array [];
let Dict.734 : U64 = 0i64;
let Dict.44 : Float32 = CallByName Dict.44;
let Dict.45 : U8 = CallByName Dict.45;
let Dict.731 : {List {U32, U32}, List {[], []}, U64, Float32, U8} = Struct {Dict.732, Dict.733, Dict.734, Dict.44, Dict.45};
ret Dict.731;
procedure Dict.4 (Dict.729):
let Dict.156 : List {[], []} = StructAtIndex 1 Dict.729;
let #Derived_gen.0 : List {U32, U32} = StructAtIndex 0 Dict.729;
dec #Derived_gen.0;
let Dict.730 : U64 = CallByName List.6 Dict.156;
dec Dict.156;
ret Dict.730;
procedure Dict.44 ():
let Dict.738 : Float32 = 0.8f64;
procedure Dict.1 (Dict.730):
let Dict.739 : List {U32, U32} = Array [];
let Dict.740 : List {[], []} = Array [];
let Dict.741 : U64 = 0i64;
let Dict.51 : Float32 = CallByName Dict.51;
let Dict.52 : U8 = CallByName Dict.52;
let Dict.738 : {List {U32, U32}, List {[], []}, U64, Float32, U8} = Struct {Dict.739, Dict.740, Dict.741, Dict.51, Dict.52};
ret Dict.738;
procedure Dict.45 ():
let Dict.736 : U8 = 64i64;
let Dict.737 : U8 = 3i64;
let Dict.735 : U8 = CallByName Num.75 Dict.736 Dict.737;
ret Dict.735;
procedure Dict.4 (Dict.736):
let Dict.163 : List {[], []} = StructAtIndex 1 Dict.736;
let #Derived_gen.0 : List {U32, U32} = StructAtIndex 0 Dict.736;
dec #Derived_gen.0;
let Dict.737 : U64 = CallByName List.6 Dict.163;
dec Dict.163;
ret Dict.737;
procedure Dict.51 ():
let Dict.745 : Float32 = 0.8f64;
ret Dict.745;
procedure Dict.52 ():
let Dict.743 : U8 = 64i64;
let Dict.744 : U8 = 3i64;
let Dict.742 : U8 = CallByName Num.75 Dict.743 Dict.744;
ret Dict.742;
procedure List.6 (#Attr.2):
let List.622 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.622;
let List.625 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.625;
procedure Num.75 (#Attr.2, #Attr.3):
let Num.279 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3;
ret Num.281;
procedure Test.0 ():
let Test.3 : {} = Struct {};

View file

@ -2,29 +2,29 @@ procedure Bool.1 ():
let Bool.23 : Int1 = false;
ret Bool.23;
procedure List.2 (List.111, List.112):
let List.628 : U64 = CallByName List.6 List.111;
let List.624 : Int1 = CallByName Num.22 List.112 List.628;
if List.624 then
let List.626 : {} = CallByName List.66 List.111 List.112;
let List.625 : [C {}, C {}] = TagId(1) List.626;
ret List.625;
procedure List.2 (List.114, List.115):
let List.631 : U64 = CallByName List.6 List.114;
let List.627 : Int1 = CallByName Num.22 List.115 List.631;
if List.627 then
let List.629 : {} = CallByName List.66 List.114 List.115;
let List.628 : [C {}, C {}] = TagId(1) List.629;
ret List.628;
else
let List.623 : {} = Struct {};
let List.622 : [C {}, C {}] = TagId(0) List.623;
ret List.622;
let List.626 : {} = Struct {};
let List.625 : [C {}, C {}] = TagId(0) List.626;
ret List.625;
procedure List.6 (#Attr.2):
let List.629 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.629;
let List.632 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.632;
procedure List.66 (#Attr.2, #Attr.3):
let List.627 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.627;
let List.630 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.630;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.281;
procedure Test.2 (Test.5):
let Test.17 : Str = "bar";

View file

@ -1,16 +1,16 @@
procedure List.4 (List.127, List.128):
let List.625 : U64 = 1i64;
let List.623 : List U8 = CallByName List.70 List.127 List.625;
let List.622 : List U8 = CallByName List.71 List.623 List.128;
ret List.622;
procedure List.4 (List.130, List.131):
let List.628 : U64 = 1i64;
let List.626 : List U8 = CallByName List.70 List.130 List.628;
let List.625 : List U8 = CallByName List.71 List.626 List.131;
ret List.625;
procedure List.70 (#Attr.2, #Attr.3):
let List.626 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.626;
let List.629 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.629;
procedure List.71 (#Attr.2, #Attr.3):
let List.624 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.624;
let List.627 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.627;
procedure Test.23 (Test.24, Test.35, Test.22):
let Test.37 : List U8 = CallByName List.4 Test.24 Test.22;

View file

@ -7,7 +7,7 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1):
let #Derived_gen.8 : Str = CallByName #Derived.5 #Derived.1;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6];
let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5;
let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4;
dec #Derived_gen.4;
ret #Derived_gen.3;
@ -18,263 +18,263 @@ procedure #Derived.5 (#Derived.6):
procedure #Derived.7 (#Derived.8, #Derived.9, #Derived.6):
let #Derived_gen.17 : Str = "b";
let #Derived_gen.18 : Str = CallByName Test.19 #Derived.6;
let #Derived_gen.18 : Str = CallByName Test.20 #Derived.6;
let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18};
let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16];
let #Derived_gen.14 : List {Str, Str} = CallByName Test.21 #Derived_gen.15;
let #Derived_gen.14 : List {Str, Str} = CallByName Test.22 #Derived_gen.15;
let #Derived_gen.13 : List U8 = CallByName Encode.24 #Derived.8 #Derived_gen.14 #Derived.9;
dec #Derived_gen.14;
ret #Derived_gen.13;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109;
ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.116 : List U8 = CallByName #Derived.7 Encode.99 Encode.101 Encode.107;
ret Encode.116;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.115;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.119 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107;
ret Encode.119;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.118 : List U8 = CallByName #Derived.7 Encode.101 Encode.103 Encode.109;
ret Encode.118;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.124 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107;
ret Encode.124;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.121 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.121;
procedure Encode.26 (Encode.105, Encode.106):
let Encode.109 : List U8 = Array [];
let Encode.110 : Str = CallByName #Derived.0 Encode.105;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.126 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
ret Encode.126;
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : Str = CallByName #Derived.0 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.18 (List.163, List.164, List.165):
let List.649 : U64 = 0i64;
let List.650 : U64 = CallByName List.6 List.163;
let List.648 : List U8 = CallByName List.92 List.163 List.164 List.165 List.649 List.650;
ret List.648;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.4 (List.127, List.128):
let List.670 : U64 = 1i64;
let List.669 : List U8 = CallByName List.70 List.127 List.670;
let List.668 : List U8 = CallByName List.71 List.669 List.128;
ret List.668;
procedure List.18 (List.166, List.167, List.168):
let List.652 : U64 = 0i64;
let List.653 : U64 = CallByName List.6 List.166;
let List.651 : List U8 = CallByName List.95 List.166 List.167 List.168 List.652 List.653;
ret List.651;
procedure List.4 (List.130, List.131):
let List.673 : U64 = 1i64;
let List.672 : List U8 = CallByName List.70 List.130 List.673;
let List.671 : List U8 = CallByName List.71 List.672 List.131;
ret List.671;
procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647;
let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.650;
procedure List.6 (#Attr.2):
let List.673 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.673;
let List.676 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.676;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.66 (#Attr.2, #Attr.3):
let List.658 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.658;
let List.661 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.661;
procedure List.70 (#Attr.2, #Attr.3):
let List.664 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.664;
let List.667 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.667;
procedure List.71 (#Attr.2, #Attr.3):
let List.662 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.662;
let List.665 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.665;
procedure List.8 (#Attr.2, #Attr.3):
let List.672 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.672;
let List.675 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.675;
procedure List.92 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33):
joinpoint List.651 List.166 List.167 List.168 List.169 List.170:
let List.653 : Int1 = CallByName Num.22 List.169 List.170;
if List.653 then
let List.657 : {Str, Str} = CallByName List.66 List.166 List.169;
inc List.657;
let List.171 : List U8 = CallByName Test.70 List.167 List.657;
let List.656 : U64 = 1i64;
let List.655 : U64 = CallByName Num.51 List.169 List.656;
jump List.651 List.166 List.171 List.168 List.655 List.170;
procedure List.95 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.634;
let List.174 : List U8 = CallByName Test.71 List.170 List.634;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.29;
jump List.651 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33;
inc #Derived_gen.26;
jump List.628 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30;
procedure List.92 (#Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169;
inc List.631;
let List.171 : List U8 = CallByName Test.70 List.167 List.631;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.40, #Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44):
joinpoint List.654 List.169 List.170 List.171 List.172 List.173:
let List.656 : Int1 = CallByName Num.22 List.172 List.173;
if List.656 then
let List.660 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.660;
let List.174 : List U8 = CallByName Test.71 List.170 List.660;
let List.659 : U64 = 1i64;
let List.658 : U64 = CallByName Num.51 List.172 List.659;
jump List.654 List.169 List.174 List.171 List.658 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.37;
jump List.625 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41;
inc #Derived_gen.40;
jump List.654 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44;
procedure Num.127 (#Attr.2):
let Num.284 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.284;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
let Num.286 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.286;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.288 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.288;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.285 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.285;
let Num.287 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.287;
procedure Num.96 (#Attr.2):
let Num.283 : Str = lowlevel NumToStr #Attr.2;
ret Num.283;
let Num.285 : Str = lowlevel NumToStr #Attr.2;
ret Num.285;
procedure Str.12 (#Attr.2):
let Str.244 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.244;
let Str.248 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.248;
procedure Str.36 (#Attr.2):
let Str.245 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.245;
let Str.249 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.249;
procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239;
let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.243;
procedure Str.9 (Str.67):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67;
let Str.236 : Int1 = StructAtIndex 2 Str.68;
if Str.236 then
let Str.238 : Str = StructAtIndex 1 Str.68;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238;
ret Str.237;
procedure Str.9 (Str.71):
let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.240 then
let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.241;
else
let Str.234 : U8 = StructAtIndex 3 Str.68;
let Str.235 : U64 = StructAtIndex 0 Str.68;
let #Derived_gen.45 : Str = StructAtIndex 1 Str.68;
let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.45 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.45;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233;
ret Str.232;
let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.236;
procedure Test.19 (Test.55):
let Test.324 : Str = CallByName Encode.23 Test.55;
ret Test.324;
procedure Test.20 (Test.56):
let Test.325 : Str = CallByName Encode.23 Test.56;
ret Test.325;
procedure Test.2 ():
let Test.257 : {} = Struct {};
ret Test.257;
procedure Test.22 (Test.67):
let Test.261 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.261;
procedure Test.21 (Test.66):
let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66;
ret Test.260;
procedure Test.22 (Test.67):
let Test.293 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.293;
procedure Test.21 (Test.66):
let Test.292 : List {Str, Str} = CallByName Encode.23 Test.66;
ret Test.292;
procedure Test.3 ():
let Test.258 : {} = Struct {};
ret Test.258;
procedure Test.3 (Test.48, Test.49, Test.50):
let Test.321 : U8 = CallByName Num.127 Test.49;
let Test.318 : List U8 = CallByName List.4 Test.48 Test.321;
let Test.320 : Str = CallByName Num.96 Test.50;
let Test.319 : List U8 = CallByName Str.12 Test.320;
let Test.316 : List U8 = CallByName List.8 Test.318 Test.319;
let Test.317 : U8 = 32i64;
let Test.315 : List U8 = CallByName List.4 Test.316 Test.317;
ret Test.315;
procedure Test.4 (Test.49, Test.50, Test.51):
let Test.322 : U8 = CallByName Num.127 Test.50;
let Test.319 : List U8 = CallByName List.4 Test.49 Test.322;
let Test.321 : Str = CallByName Num.96 Test.51;
let Test.320 : List U8 = CallByName Str.12 Test.321;
let Test.317 : List U8 = CallByName List.8 Test.319 Test.320;
let Test.318 : U8 = 32i64;
let Test.316 : List U8 = CallByName List.4 Test.317 Test.318;
ret Test.316;
procedure Test.56 (Test.57, Test.274, Test.55):
let Test.313 : I64 = 115i64;
let Test.314 : U64 = CallByName Str.36 Test.55;
let Test.311 : List U8 = CallByName Test.3 Test.57 Test.313 Test.314;
let Test.312 : List U8 = CallByName Str.12 Test.55;
let Test.309 : List U8 = CallByName List.8 Test.311 Test.312;
let Test.310 : U8 = 32i64;
let Test.308 : List U8 = CallByName List.4 Test.309 Test.310;
ret Test.308;
procedure Test.57 (Test.58, Test.275, Test.56):
let Test.314 : I64 = 115i64;
let Test.315 : U64 = CallByName Str.36 Test.56;
let Test.312 : List U8 = CallByName Test.4 Test.58 Test.314 Test.315;
let Test.313 : List U8 = CallByName Str.12 Test.56;
let Test.310 : List U8 = CallByName List.8 Test.312 Test.313;
let Test.311 : U8 = 32i64;
let Test.309 : List U8 = CallByName List.4 Test.310 Test.311;
ret Test.309;
procedure Test.67 (Test.68, Test.262, Test.66):
let Test.290 : I64 = 114i64;
let Test.291 : U64 = CallByName List.6 Test.66;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291;
let Test.265 : {} = Struct {};
let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265;
ret Test.264;
procedure Test.68 (Test.69, Test.263, Test.67):
let Test.291 : I64 = 114i64;
let Test.292 : U64 = CallByName List.6 Test.67;
let Test.70 : List U8 = CallByName Test.4 Test.69 Test.291 Test.292;
let Test.266 : {} = Struct {};
let Test.265 : List U8 = CallByName List.18 Test.67 Test.70 Test.266;
ret Test.265;
procedure Test.67 (Test.68, Test.262, Test.66):
let Test.322 : I64 = 114i64;
let Test.323 : U64 = CallByName List.6 Test.66;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.322 Test.323;
let Test.297 : {} = Struct {};
let Test.296 : List U8 = CallByName List.18 Test.66 Test.69 Test.297;
ret Test.296;
procedure Test.68 (Test.69, Test.263, Test.67):
let Test.323 : I64 = 114i64;
let Test.324 : U64 = CallByName List.6 Test.67;
let Test.70 : List U8 = CallByName Test.4 Test.69 Test.323 Test.324;
let Test.298 : {} = Struct {};
let Test.297 : List U8 = CallByName List.18 Test.67 Test.70 Test.298;
ret Test.297;
procedure Test.70 (Test.71, Test.266):
let Test.72 : Str = StructAtIndex 0 Test.266;
let Test.73 : Str = StructAtIndex 1 Test.266;
let Test.270 : Str = CallByName Test.19 Test.72;
let Test.271 : {} = Struct {};
let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271;
let Test.269 : {} = Struct {};
let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269;
ret Test.267;
procedure Test.71 (Test.72, Test.267):
let Test.73 : Str = StructAtIndex 0 Test.267;
let Test.74 : Str = StructAtIndex 1 Test.267;
let Test.271 : Str = CallByName Test.20 Test.73;
let Test.272 : {} = Struct {};
let Test.269 : List U8 = CallByName Encode.24 Test.72 Test.271 Test.272;
let Test.270 : {} = Struct {};
let Test.268 : List U8 = CallByName Encode.24 Test.269 Test.74 Test.270;
ret Test.268;
procedure Test.70 (Test.71, Test.266):
let Test.72 : Str = StructAtIndex 0 Test.266;
let Test.73 : Str = StructAtIndex 1 Test.266;
let Test.302 : Str = CallByName Test.19 Test.72;
let Test.303 : {} = Struct {};
let Test.300 : List U8 = CallByName Encode.24 Test.71 Test.302 Test.303;
let Test.301 : {} = Struct {};
let Test.299 : List U8 = CallByName Encode.24 Test.300 Test.73 Test.301;
ret Test.299;
procedure Test.71 (Test.72, Test.267):
let Test.73 : Str = StructAtIndex 0 Test.267;
let Test.74 : Str = StructAtIndex 1 Test.267;
let Test.303 : Str = CallByName Test.20 Test.73;
let Test.304 : {} = Struct {};
let Test.301 : List U8 = CallByName Encode.24 Test.72 Test.303 Test.304;
let Test.302 : {} = Struct {};
let Test.300 : List U8 = CallByName Encode.24 Test.301 Test.74 Test.302;
ret Test.300;
procedure Test.0 ():
let Test.259 : Str = "bar";
let Test.256 : {} = CallByName Test.2;
let Test.254 : List U8 = CallByName Encode.26 Test.259 Test.256;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254;
let Test.251 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252;
if Test.253 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209;
ret Test.210;
let Test.260 : Str = "bar";
let Test.257 : {} = CallByName Test.3;
let Test.255 : List U8 = CallByName Encode.26 Test.260 Test.257;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.252 : U8 = 1i64;
let Test.253 : U8 = GetTagId Test.210;
let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.254 then
let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.211;
else
dec Test.209;
let Test.250 : Str = "<bad>";
ret Test.250;
dec Test.210;
let Test.251 : Str = "<bad>";
ret Test.251;

View file

@ -4,196 +4,196 @@ procedure #Derived.0 (#Derived.1):
procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1):
let #Derived_gen.7 : Str = "a";
let #Derived_gen.8 : Str = CallByName Test.19 #Derived.1;
let #Derived_gen.8 : Str = CallByName Test.20 #Derived.1;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6];
let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5;
let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4;
dec #Derived_gen.4;
ret #Derived_gen.3;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109;
ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107;
ret Encode.118;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106):
let Encode.109 : List U8 = Array [];
let Encode.110 : Str = CallByName #Derived.0 Encode.105;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.120 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
ret Encode.120;
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : Str = CallByName #Derived.0 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.4 (List.127, List.128):
let List.644 : U64 = 1i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644;
let List.642 : List U8 = CallByName List.71 List.643 List.128;
ret List.642;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.4 (List.130, List.131):
let List.647 : U64 = 1i64;
let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.645;
procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647;
let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.650;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638;
let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.641;
procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636;
let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.639;
procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646;
let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.649;
procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169;
inc List.631;
let List.171 : List U8 = CallByName Test.70 List.167 List.631;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.634;
let List.174 : List U8 = CallByName Test.71 List.170 List.634;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.13;
jump List.625 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17;
jump List.628 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17;
procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.283;
procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2;
ret Num.279;
let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.281;
procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241;
let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.245;
procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242;
let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.246;
procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239;
let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.243;
procedure Str.9 (Str.67):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67;
let Str.236 : Int1 = StructAtIndex 2 Str.68;
if Str.236 then
let Str.238 : Str = StructAtIndex 1 Str.68;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238;
ret Str.237;
procedure Str.9 (Str.71):
let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.240 then
let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.241;
else
let Str.234 : U8 = StructAtIndex 3 Str.68;
let Str.235 : U64 = StructAtIndex 0 Str.68;
let #Derived_gen.24 : Str = StructAtIndex 1 Str.68;
let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.24 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.24;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233;
ret Str.232;
let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.236;
procedure Test.19 (Test.55):
let Test.291 : Str = CallByName Encode.23 Test.55;
ret Test.291;
procedure Test.20 (Test.56):
let Test.292 : Str = CallByName Encode.23 Test.56;
ret Test.292;
procedure Test.2 ():
let Test.257 : {} = Struct {};
ret Test.257;
procedure Test.22 (Test.67):
let Test.260 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.260;
procedure Test.21 (Test.66):
let Test.259 : List {Str, Str} = CallByName Encode.23 Test.66;
ret Test.259;
procedure Test.3 ():
let Test.258 : {} = Struct {};
ret Test.258;
procedure Test.3 (Test.48, Test.49, Test.50):
let Test.288 : U8 = CallByName Num.127 Test.49;
let Test.285 : List U8 = CallByName List.4 Test.48 Test.288;
let Test.287 : Str = CallByName Num.96 Test.50;
let Test.286 : List U8 = CallByName Str.12 Test.287;
let Test.283 : List U8 = CallByName List.8 Test.285 Test.286;
let Test.284 : U8 = 32i64;
let Test.282 : List U8 = CallByName List.4 Test.283 Test.284;
ret Test.282;
procedure Test.4 (Test.49, Test.50, Test.51):
let Test.289 : U8 = CallByName Num.127 Test.50;
let Test.286 : List U8 = CallByName List.4 Test.49 Test.289;
let Test.288 : Str = CallByName Num.96 Test.51;
let Test.287 : List U8 = CallByName Str.12 Test.288;
let Test.284 : List U8 = CallByName List.8 Test.286 Test.287;
let Test.285 : U8 = 32i64;
let Test.283 : List U8 = CallByName List.4 Test.284 Test.285;
ret Test.283;
procedure Test.56 (Test.57, Test.273, Test.55):
let Test.280 : I64 = 115i64;
let Test.281 : U64 = CallByName Str.36 Test.55;
let Test.278 : List U8 = CallByName Test.3 Test.57 Test.280 Test.281;
let Test.279 : List U8 = CallByName Str.12 Test.55;
let Test.276 : List U8 = CallByName List.8 Test.278 Test.279;
let Test.277 : U8 = 32i64;
let Test.275 : List U8 = CallByName List.4 Test.276 Test.277;
ret Test.275;
procedure Test.57 (Test.58, Test.274, Test.56):
let Test.281 : I64 = 115i64;
let Test.282 : U64 = CallByName Str.36 Test.56;
let Test.279 : List U8 = CallByName Test.4 Test.58 Test.281 Test.282;
let Test.280 : List U8 = CallByName Str.12 Test.56;
let Test.277 : List U8 = CallByName List.8 Test.279 Test.280;
let Test.278 : U8 = 32i64;
let Test.276 : List U8 = CallByName List.4 Test.277 Test.278;
ret Test.276;
procedure Test.67 (Test.68, Test.261, Test.66):
let Test.289 : I64 = 114i64;
let Test.290 : U64 = CallByName List.6 Test.66;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.289 Test.290;
let Test.264 : {} = Struct {};
let Test.263 : List U8 = CallByName List.18 Test.66 Test.69 Test.264;
ret Test.263;
procedure Test.68 (Test.69, Test.262, Test.67):
let Test.290 : I64 = 114i64;
let Test.291 : U64 = CallByName List.6 Test.67;
let Test.70 : List U8 = CallByName Test.4 Test.69 Test.290 Test.291;
let Test.265 : {} = Struct {};
let Test.264 : List U8 = CallByName List.18 Test.67 Test.70 Test.265;
ret Test.264;
procedure Test.70 (Test.71, Test.265):
let Test.72 : Str = StructAtIndex 0 Test.265;
let Test.73 : Str = StructAtIndex 1 Test.265;
let Test.269 : Str = CallByName Test.19 Test.72;
let Test.270 : {} = Struct {};
let Test.267 : List U8 = CallByName Encode.24 Test.71 Test.269 Test.270;
let Test.268 : {} = Struct {};
let Test.266 : List U8 = CallByName Encode.24 Test.267 Test.73 Test.268;
ret Test.266;
procedure Test.71 (Test.72, Test.266):
let Test.73 : Str = StructAtIndex 0 Test.266;
let Test.74 : Str = StructAtIndex 1 Test.266;
let Test.270 : Str = CallByName Test.20 Test.73;
let Test.271 : {} = Struct {};
let Test.268 : List U8 = CallByName Encode.24 Test.72 Test.270 Test.271;
let Test.269 : {} = Struct {};
let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.74 Test.269;
ret Test.267;
procedure Test.0 ():
let Test.258 : Str = "foo";
let Test.256 : {} = CallByName Test.2;
let Test.254 : List U8 = CallByName Encode.26 Test.258 Test.256;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254;
let Test.251 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252;
if Test.253 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209;
ret Test.210;
let Test.259 : Str = "foo";
let Test.257 : {} = CallByName Test.3;
let Test.255 : List U8 = CallByName Encode.26 Test.259 Test.257;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.252 : U8 = 1i64;
let Test.253 : U8 = GetTagId Test.210;
let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.254 then
let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.211;
else
dec Test.209;
let Test.250 : Str = "<bad>";
ret Test.250;
dec Test.210;
let Test.251 : Str = "<bad>";
ret Test.251;

View file

@ -6,203 +6,203 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1):
let #Derived_gen.11 : Str = "a";
let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1;
inc #Derived_gen.13;
let #Derived_gen.12 : Str = CallByName Test.19 #Derived_gen.13;
let #Derived_gen.12 : Str = CallByName Test.20 #Derived_gen.13;
let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12};
let #Derived_gen.8 : Str = "b";
let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1;
dec #Derived_gen.13;
let #Derived_gen.9 : Str = CallByName Test.19 #Derived_gen.10;
let #Derived_gen.9 : Str = CallByName Test.20 #Derived_gen.10;
let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9};
let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7];
let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5;
let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5;
let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4;
dec #Derived_gen.4;
ret #Derived_gen.3;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109;
ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.119 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107;
ret Encode.119;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109;
ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106):
let Encode.109 : List U8 = Array [];
let Encode.110 : {Str, Str} = CallByName #Derived.0 Encode.105;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.121 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
ret Encode.121;
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : {Str, Str} = CallByName #Derived.0 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.4 (List.127, List.128):
let List.644 : U64 = 1i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644;
let List.642 : List U8 = CallByName List.71 List.643 List.128;
ret List.642;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.4 (List.130, List.131):
let List.647 : U64 = 1i64;
let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.645;
procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647;
let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.650;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638;
let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.641;
procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636;
let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.639;
procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646;
let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.649;
procedure List.92 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : {Str, Str} = CallByName List.66 List.166 List.169;
inc List.631;
let List.171 : List U8 = CallByName Test.70 List.167 List.631;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : {Str, Str} = CallByName List.66 List.169 List.172;
inc List.634;
let List.174 : List U8 = CallByName Test.71 List.170 List.634;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.17;
jump List.625 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21;
jump List.628 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21;
procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.283;
procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2;
ret Num.279;
let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.281;
procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241;
let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.245;
procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242;
let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.246;
procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239;
let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.243;
procedure Str.9 (Str.67):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67;
let Str.236 : Int1 = StructAtIndex 2 Str.68;
if Str.236 then
let Str.238 : Str = StructAtIndex 1 Str.68;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238;
ret Str.237;
procedure Str.9 (Str.71):
let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.240 then
let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.241;
else
let Str.234 : U8 = StructAtIndex 3 Str.68;
let Str.235 : U64 = StructAtIndex 0 Str.68;
let #Derived_gen.28 : Str = StructAtIndex 1 Str.68;
let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.28 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.28;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233;
ret Str.232;
let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.236;
procedure Test.19 (Test.55):
let Test.295 : Str = CallByName Encode.23 Test.55;
ret Test.295;
procedure Test.20 (Test.56):
let Test.296 : Str = CallByName Encode.23 Test.56;
ret Test.296;
procedure Test.2 ():
let Test.257 : {} = Struct {};
ret Test.257;
procedure Test.22 (Test.67):
let Test.261 : List {Str, Str} = CallByName Encode.23 Test.67;
ret Test.261;
procedure Test.21 (Test.66):
let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66;
ret Test.260;
procedure Test.3 ():
let Test.258 : {} = Struct {};
ret Test.258;
procedure Test.3 (Test.48, Test.49, Test.50):
let Test.289 : U8 = CallByName Num.127 Test.49;
let Test.286 : List U8 = CallByName List.4 Test.48 Test.289;
let Test.288 : Str = CallByName Num.96 Test.50;
let Test.287 : List U8 = CallByName Str.12 Test.288;
let Test.284 : List U8 = CallByName List.8 Test.286 Test.287;
let Test.285 : U8 = 32i64;
let Test.283 : List U8 = CallByName List.4 Test.284 Test.285;
ret Test.283;
procedure Test.4 (Test.49, Test.50, Test.51):
let Test.290 : U8 = CallByName Num.127 Test.50;
let Test.287 : List U8 = CallByName List.4 Test.49 Test.290;
let Test.289 : Str = CallByName Num.96 Test.51;
let Test.288 : List U8 = CallByName Str.12 Test.289;
let Test.285 : List U8 = CallByName List.8 Test.287 Test.288;
let Test.286 : U8 = 32i64;
let Test.284 : List U8 = CallByName List.4 Test.285 Test.286;
ret Test.284;
procedure Test.56 (Test.57, Test.274, Test.55):
let Test.281 : I64 = 115i64;
let Test.282 : U64 = CallByName Str.36 Test.55;
let Test.279 : List U8 = CallByName Test.3 Test.57 Test.281 Test.282;
let Test.280 : List U8 = CallByName Str.12 Test.55;
let Test.277 : List U8 = CallByName List.8 Test.279 Test.280;
let Test.278 : U8 = 32i64;
let Test.276 : List U8 = CallByName List.4 Test.277 Test.278;
ret Test.276;
procedure Test.57 (Test.58, Test.275, Test.56):
let Test.282 : I64 = 115i64;
let Test.283 : U64 = CallByName Str.36 Test.56;
let Test.280 : List U8 = CallByName Test.4 Test.58 Test.282 Test.283;
let Test.281 : List U8 = CallByName Str.12 Test.56;
let Test.278 : List U8 = CallByName List.8 Test.280 Test.281;
let Test.279 : U8 = 32i64;
let Test.277 : List U8 = CallByName List.4 Test.278 Test.279;
ret Test.277;
procedure Test.67 (Test.68, Test.262, Test.66):
let Test.290 : I64 = 114i64;
let Test.291 : U64 = CallByName List.6 Test.66;
let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291;
let Test.265 : {} = Struct {};
let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265;
ret Test.264;
procedure Test.68 (Test.69, Test.263, Test.67):
let Test.291 : I64 = 114i64;
let Test.292 : U64 = CallByName List.6 Test.67;
let Test.70 : List U8 = CallByName Test.4 Test.69 Test.291 Test.292;
let Test.266 : {} = Struct {};
let Test.265 : List U8 = CallByName List.18 Test.67 Test.70 Test.266;
ret Test.265;
procedure Test.70 (Test.71, Test.266):
let Test.72 : Str = StructAtIndex 0 Test.266;
let Test.73 : Str = StructAtIndex 1 Test.266;
let Test.270 : Str = CallByName Test.19 Test.72;
let Test.271 : {} = Struct {};
let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271;
let Test.269 : {} = Struct {};
let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269;
ret Test.267;
procedure Test.71 (Test.72, Test.267):
let Test.73 : Str = StructAtIndex 0 Test.267;
let Test.74 : Str = StructAtIndex 1 Test.267;
let Test.271 : Str = CallByName Test.20 Test.73;
let Test.272 : {} = Struct {};
let Test.269 : List U8 = CallByName Encode.24 Test.72 Test.271 Test.272;
let Test.270 : {} = Struct {};
let Test.268 : List U8 = CallByName Encode.24 Test.269 Test.74 Test.270;
ret Test.268;
procedure Test.0 ():
let Test.258 : Str = "foo";
let Test.259 : Str = "bar";
let Test.255 : {Str, Str} = Struct {Test.258, Test.259};
let Test.256 : {} = CallByName Test.2;
let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254;
let Test.251 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252;
if Test.253 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209;
ret Test.210;
let Test.259 : Str = "foo";
let Test.260 : Str = "bar";
let Test.256 : {Str, Str} = Struct {Test.259, Test.260};
let Test.257 : {} = CallByName Test.3;
let Test.255 : List U8 = CallByName Encode.26 Test.256 Test.257;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.252 : U8 = 1i64;
let Test.253 : U8 = GetTagId Test.210;
let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.254 then
let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.211;
else
dec Test.209;
let Test.250 : Str = "<bad>";
ret Test.250;
dec Test.210;
let Test.251 : Str = "<bad>";
ret Test.251;

View file

@ -1,110 +1,110 @@
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.111 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107;
ret Encode.111;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.113 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
ret Encode.113;
procedure Encode.26 (Encode.105, Encode.106):
let Encode.109 : List U8 = Array [];
let Encode.110 : Str = CallByName Test.19 Encode.105;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : Str = CallByName Test.20 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.4 (List.127, List.128):
let List.632 : U64 = 1i64;
let List.631 : List U8 = CallByName List.70 List.127 List.632;
let List.630 : List U8 = CallByName List.71 List.631 List.128;
ret List.630;
procedure List.4 (List.130, List.131):
let List.635 : U64 = 1i64;
let List.634 : List U8 = CallByName List.70 List.130 List.635;
let List.633 : List U8 = CallByName List.71 List.634 List.131;
ret List.633;
procedure List.70 (#Attr.2, #Attr.3):
let List.626 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.626;
let List.629 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.629;
procedure List.71 (#Attr.2, #Attr.3):
let List.624 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.624;
let List.627 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.627;
procedure List.8 (#Attr.2, #Attr.3):
let List.634 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.634;
let List.637 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.637;
procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.282;
procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2;
ret Num.279;
let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.281;
procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241;
let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.245;
procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242;
let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.246;
procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239;
let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.243;
procedure Str.9 (Str.67):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67;
let Str.236 : Int1 = StructAtIndex 2 Str.68;
if Str.236 then
let Str.238 : Str = StructAtIndex 1 Str.68;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238;
ret Str.237;
procedure Str.9 (Str.71):
let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.240 then
let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.241;
else
let Str.234 : U8 = StructAtIndex 3 Str.68;
let Str.235 : U64 = StructAtIndex 0 Str.68;
let #Derived_gen.3 : Str = StructAtIndex 1 Str.68;
let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.3 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.3;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233;
ret Str.232;
let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.236;
procedure Test.19 (Test.55):
let Test.258 : Str = CallByName Encode.23 Test.55;
procedure Test.20 (Test.56):
let Test.259 : Str = CallByName Encode.23 Test.56;
ret Test.259;
procedure Test.3 ():
let Test.258 : {} = Struct {};
ret Test.258;
procedure Test.2 ():
let Test.257 : {} = Struct {};
ret Test.257;
procedure Test.4 (Test.49, Test.50, Test.51):
let Test.276 : U8 = CallByName Num.127 Test.50;
let Test.273 : List U8 = CallByName List.4 Test.49 Test.276;
let Test.275 : Str = CallByName Num.96 Test.51;
let Test.274 : List U8 = CallByName Str.12 Test.275;
let Test.271 : List U8 = CallByName List.8 Test.273 Test.274;
let Test.272 : U8 = 32i64;
let Test.270 : List U8 = CallByName List.4 Test.271 Test.272;
ret Test.270;
procedure Test.3 (Test.48, Test.49, Test.50):
let Test.275 : U8 = CallByName Num.127 Test.49;
let Test.272 : List U8 = CallByName List.4 Test.48 Test.275;
let Test.274 : Str = CallByName Num.96 Test.50;
let Test.273 : List U8 = CallByName Str.12 Test.274;
let Test.270 : List U8 = CallByName List.8 Test.272 Test.273;
let Test.271 : U8 = 32i64;
let Test.269 : List U8 = CallByName List.4 Test.270 Test.271;
ret Test.269;
procedure Test.56 (Test.57, Test.260, Test.55):
let Test.267 : I64 = 115i64;
let Test.268 : U64 = CallByName Str.36 Test.55;
let Test.265 : List U8 = CallByName Test.3 Test.57 Test.267 Test.268;
let Test.266 : List U8 = CallByName Str.12 Test.55;
let Test.263 : List U8 = CallByName List.8 Test.265 Test.266;
let Test.264 : U8 = 32i64;
let Test.262 : List U8 = CallByName List.4 Test.263 Test.264;
ret Test.262;
procedure Test.57 (Test.58, Test.261, Test.56):
let Test.268 : I64 = 115i64;
let Test.269 : U64 = CallByName Str.36 Test.56;
let Test.266 : List U8 = CallByName Test.4 Test.58 Test.268 Test.269;
let Test.267 : List U8 = CallByName Str.12 Test.56;
let Test.264 : List U8 = CallByName List.8 Test.266 Test.267;
let Test.265 : U8 = 32i64;
let Test.263 : List U8 = CallByName List.4 Test.264 Test.265;
ret Test.263;
procedure Test.0 ():
let Test.255 : Str = "abc";
let Test.256 : {} = CallByName Test.2;
let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256;
let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254;
let Test.251 : U8 = 1i64;
let Test.252 : U8 = GetTagId Test.209;
let Test.253 : Int1 = lowlevel Eq Test.251 Test.252;
if Test.253 then
let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209;
ret Test.210;
let Test.256 : Str = "abc";
let Test.257 : {} = CallByName Test.3;
let Test.255 : List U8 = CallByName Encode.26 Test.256 Test.257;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255;
let Test.252 : U8 = 1i64;
let Test.253 : U8 = GetTagId Test.210;
let Test.254 : Int1 = lowlevel Eq Test.252 Test.253;
if Test.254 then
let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.211;
else
dec Test.209;
let Test.250 : Str = "<bad>";
ret Test.250;
dec Test.210;
let Test.251 : Str = "<bad>";
ret Test.251;

View file

@ -8,212 +8,212 @@ procedure #Derived.3 (#Derived.4, #Derived.5, #Derived.1):
ret #Derived_gen.3;
in
let #Derived_gen.7 : Str = "A";
let #Derived_gen.9 : Str = CallByName Test.19 #Derived.1;
let #Derived_gen.9 : Str = CallByName Test.20 #Derived.1;
let #Derived_gen.8 : List Str = Array [#Derived_gen.9];
let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8;
let #Derived_gen.6 : {List Str, {}} = CallByName Test.24 #Derived_gen.7 #Derived_gen.8;
jump #Derived_gen.5 #Derived_gen.6;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.111 : List U8 = CallByName #Derived.3 Encode.99 Encode.101 Encode.107;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.113 : List U8 = CallByName #Derived.3 Encode.101 Encode.103 Encode.109;
ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.117 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107;
ret Encode.117;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.115 : List U8 = CallByName Test.61 Encode.101 Encode.103 Encode.109;
ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106):
let Encode.109 : List U8 = Array [];
let Encode.110 : Str = CallByName #Derived.0 Encode.105;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.119 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
ret Encode.119;
procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : Str = CallByName #Derived.0 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.13 (#Attr.2, #Attr.3):
let List.648 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3;
ret List.648;
let List.651 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3;
ret List.651;
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.4 (List.127, List.128):
let List.644 : U64 = 1i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644;
let List.642 : List U8 = CallByName List.71 List.643 List.128;
ret List.642;
procedure List.4 (List.130, List.131):
let List.647 : U64 = 1i64;
let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.645;
procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647;
let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.650;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638;
let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.641;
procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636;
let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.639;
procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646;
let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.649;
procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : Str = CallByName List.66 List.166 List.169;
inc List.631;
let List.171 : List U8 = CallByName Test.63 List.167 List.631 List.168;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : Str = CallByName List.66 List.169 List.172;
inc List.634;
let List.174 : List U8 = CallByName Test.64 List.170 List.634 List.171;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.13;
jump List.625 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17;
inc #Derived_gen.10;
jump List.628 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14;
procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.283;
procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2;
ret Num.279;
let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.281;
procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241;
let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.245;
procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242;
let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.246;
procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239;
let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.243;
procedure Str.9 (Str.67):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67;
let Str.236 : Int1 = StructAtIndex 2 Str.68;
if Str.236 then
let Str.238 : Str = StructAtIndex 1 Str.68;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238;
ret Str.237;
procedure Str.9 (Str.71):
let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.240 then
let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.241;
else
let Str.234 : U8 = StructAtIndex 3 Str.68;
let Str.235 : U64 = StructAtIndex 0 Str.68;
let #Derived_gen.27 : Str = StructAtIndex 1 Str.68;
let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.27 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.27;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233;
ret Str.232;
let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.236;
procedure Test.19 (Test.55):
let Test.296 : Str = CallByName Encode.23 Test.55;
ret Test.296;
procedure Test.20 (Test.56):
let Test.297 : Str = CallByName Encode.23 Test.56;
ret Test.297;
procedure Test.2 ():
let Test.258 : {} = Struct {};
ret Test.258;
procedure Test.21 (Test.59, Test.60):
inc Test.59;
let Test.266 : {List Str, {}} = Struct {Test.59, Test.60};
let Test.265 : {List Str, {}} = CallByName Encode.23 Test.266;
ret Test.265;
procedure Test.20 (Test.58, Test.59):
inc Test.58;
let Test.265 : {List Str, {}} = Struct {Test.58, Test.59};
let Test.264 : {List Str, {}} = CallByName Encode.23 Test.265;
ret Test.264;
procedure Test.23 (Test.75):
let Test.264 : {} = Struct {};
let Test.263 : {List Str, {}} = CallByName Test.21 Test.75 Test.264;
ret Test.263;
procedure Test.22 (Test.74):
let Test.263 : {} = Struct {};
let Test.262 : {List Str, {}} = CallByName Test.20 Test.74 Test.263;
ret Test.262;
procedure Test.24 (Test.78, Test.79):
let Test.285 : Str = CallByName Test.20 Test.78;
let Test.262 : List Str = CallByName List.13 Test.79 Test.285;
let Test.261 : {List Str, {}} = CallByName Test.23 Test.262;
dec Test.262;
ret Test.261;
procedure Test.23 (Test.77, Test.78):
let Test.284 : Str = CallByName Test.19 Test.77;
let Test.261 : List Str = CallByName List.13 Test.78 Test.284;
let Test.260 : {List Str, {}} = CallByName Test.22 Test.261;
dec Test.261;
ret Test.260;
procedure Test.3 ():
let Test.259 : {} = Struct {};
ret Test.259;
procedure Test.3 (Test.48, Test.49, Test.50):
let Test.282 : U8 = CallByName Num.127 Test.49;
let Test.279 : List U8 = CallByName List.4 Test.48 Test.282;
let Test.281 : Str = CallByName Num.96 Test.50;
let Test.280 : List U8 = CallByName Str.12 Test.281;
let Test.277 : List U8 = CallByName List.8 Test.279 Test.280;
let Test.278 : U8 = 32i64;
let Test.276 : List U8 = CallByName List.4 Test.277 Test.278;
ret Test.276;
procedure Test.4 (Test.49, Test.50, Test.51):
let Test.283 : U8 = CallByName Num.127 Test.50;
let Test.280 : List U8 = CallByName List.4 Test.49 Test.283;
let Test.282 : Str = CallByName Num.96 Test.51;
let Test.281 : List U8 = CallByName Str.12 Test.282;
let Test.278 : List U8 = CallByName List.8 Test.280 Test.281;
let Test.279 : U8 = 32i64;
let Test.277 : List U8 = CallByName List.4 Test.278 Test.279;
ret Test.277;
procedure Test.56 (Test.57, Test.287, Test.55):
let Test.294 : I64 = 115i64;
let Test.295 : U64 = CallByName Str.36 Test.55;
let Test.292 : List U8 = CallByName Test.3 Test.57 Test.294 Test.295;
let Test.293 : List U8 = CallByName Str.12 Test.55;
let Test.290 : List U8 = CallByName List.8 Test.292 Test.293;
let Test.291 : U8 = 32i64;
let Test.289 : List U8 = CallByName List.4 Test.290 Test.291;
ret Test.289;
procedure Test.57 (Test.58, Test.288, Test.56):
let Test.295 : I64 = 115i64;
let Test.296 : U64 = CallByName Str.36 Test.56;
let Test.293 : List U8 = CallByName Test.4 Test.58 Test.295 Test.296;
let Test.294 : List U8 = CallByName Str.12 Test.56;
let Test.291 : List U8 = CallByName List.8 Test.293 Test.294;
let Test.292 : U8 = 32i64;
let Test.290 : List U8 = CallByName List.4 Test.291 Test.292;
ret Test.290;
procedure Test.60 (Test.61, Test.266, #Attr.12):
let Test.59 : {} = StructAtIndex 1 #Attr.12;
let Test.58 : List Str = StructAtIndex 0 #Attr.12;
let Test.274 : I64 = 108i64;
let Test.275 : U64 = CallByName List.6 Test.58;
let Test.62 : List U8 = CallByName Test.3 Test.61 Test.274 Test.275;
let Test.268 : List U8 = CallByName List.18 Test.58 Test.62 Test.59;
dec Test.58;
ret Test.268;
procedure Test.61 (Test.62, Test.267, #Attr.12):
let Test.60 : {} = StructAtIndex 1 #Attr.12;
let Test.59 : List Str = StructAtIndex 0 #Attr.12;
let Test.275 : I64 = 108i64;
let Test.276 : U64 = CallByName List.6 Test.59;
let Test.63 : List U8 = CallByName Test.4 Test.62 Test.275 Test.276;
let Test.269 : List U8 = CallByName List.18 Test.59 Test.63 Test.60;
dec Test.59;
ret Test.269;
procedure Test.63 (Test.64, Test.65, Test.59):
let Test.272 : Str = CallByName Test.75 Test.65;
let Test.273 : {} = Struct {};
let Test.271 : List U8 = CallByName Encode.24 Test.64 Test.272 Test.273;
ret Test.271;
procedure Test.64 (Test.65, Test.66, Test.60):
let Test.273 : Str = CallByName Test.76 Test.66;
let Test.274 : {} = Struct {};
let Test.272 : List U8 = CallByName Encode.24 Test.65 Test.273 Test.274;
ret Test.272;
procedure Test.75 (Test.76):
ret Test.76;
procedure Test.76 (Test.77):
ret Test.77;
procedure Test.0 ():
let Test.259 : Str = "foo";
let Test.257 : {} = CallByName Test.2;
let Test.256 : List U8 = CallByName Encode.26 Test.259 Test.257;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256;
let Test.253 : U8 = 1i64;
let Test.254 : U8 = GetTagId Test.210;
let Test.255 : Int1 = lowlevel Eq Test.253 Test.254;
if Test.255 then
let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.212;
let Test.260 : Str = "foo";
let Test.258 : {} = CallByName Test.3;
let Test.257 : List U8 = CallByName Encode.26 Test.260 Test.258;
let Test.211 : [C {U64, U8}, C Str] = CallByName Str.9 Test.257;
let Test.254 : U8 = 1i64;
let Test.255 : U8 = GetTagId Test.211;
let Test.256 : Int1 = lowlevel Eq Test.254 Test.255;
if Test.256 then
let Test.213 : Str = UnionAtIndex (Id 1) (Index 0) Test.211;
ret Test.213;
else
dec Test.210;
let Test.252 : Str = "<bad>";
ret Test.252;
dec Test.211;
let Test.253 : Str = "<bad>";
ret Test.253;

View file

@ -10,215 +10,215 @@ procedure #Derived.4 (#Derived.5, #Derived.6, #Derived.1):
let #Derived.2 : Str = StructAtIndex 0 #Derived.1;
let #Derived.3 : Str = StructAtIndex 1 #Derived.1;
let #Derived_gen.7 : Str = "A";
let #Derived_gen.9 : Str = CallByName Test.19 #Derived.2;
let #Derived_gen.10 : Str = CallByName Test.19 #Derived.3;
let #Derived_gen.9 : Str = CallByName Test.20 #Derived.2;
let #Derived_gen.10 : Str = CallByName Test.20 #Derived.3;
let #Derived_gen.8 : List Str = Array [#Derived_gen.9, #Derived_gen.10];
let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8;
let #Derived_gen.6 : {List Str, {}} = CallByName Test.24 #Derived_gen.7 #Derived_gen.8;
jump #Derived_gen.5 #Derived_gen.6;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.23 (Encode.98):
ret Encode.98;
procedure Encode.23 (Encode.100):
ret Encode.100;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.111 : List U8 = CallByName #Derived.4 Encode.99 Encode.101 Encode.107;
ret Encode.111;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.113 : List U8 = CallByName #Derived.4 Encode.101 Encode.103 Encode.109;
ret Encode.113;
procedure Encode.24 (Encode.99, Encode.107, Encode.101):
let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107;
ret Encode.118;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.115 : List U8 = CallByName Test.61 Encode.101 Encode.103 Encode.109;
ret Encode.115;
procedure Encode.26 (Encode.105, Encode.106):
let Encode.109 : List U8 = Array [];
let Encode.110 : {Str, Str} = CallByName #Derived.0 Encode.105;
let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106;
ret Encode.108;
procedure Encode.24 (Encode.101, Encode.109, Encode.103):
let Encode.120 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109;
ret Encode.120;
procedure Encode.26 (Encode.107, Encode.108):
let Encode.111 : List U8 = Array [];
let Encode.112 : {Str, Str} = CallByName #Derived.0 Encode.107;
let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108;
ret Encode.110;
procedure List.13 (#Attr.2, #Attr.3):
let List.648 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3;
ret List.648;
let List.651 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3;
ret List.651;
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.4 (List.127, List.128):
let List.644 : U64 = 1i64;
let List.643 : List U8 = CallByName List.70 List.127 List.644;
let List.642 : List U8 = CallByName List.71 List.643 List.128;
ret List.642;
procedure List.4 (List.130, List.131):
let List.647 : U64 = 1i64;
let List.646 : List U8 = CallByName List.70 List.130 List.647;
let List.645 : List U8 = CallByName List.71 List.646 List.131;
ret List.645;
procedure List.6 (#Attr.2):
let List.647 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.647;
let List.650 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.650;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.70 (#Attr.2, #Attr.3):
let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.638;
let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3;
ret List.641;
procedure List.71 (#Attr.2, #Attr.3):
let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.636;
let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3;
ret List.639;
procedure List.8 (#Attr.2, #Attr.3):
let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.646;
let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3;
ret List.649;
procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : Str = CallByName List.66 List.166 List.169;
inc List.631;
let List.171 : List U8 = CallByName Test.63 List.167 List.631 List.168;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : Str = CallByName List.66 List.169 List.172;
inc List.634;
let List.174 : List U8 = CallByName Test.64 List.170 List.634 List.171;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.14;
jump List.625 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18;
inc #Derived_gen.11;
jump List.628 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15;
procedure Num.127 (#Attr.2):
let Num.280 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.280;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
let Num.282 : U8 = lowlevel NumIntCast #Attr.2;
ret Num.282;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.284;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.283;
procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2;
ret Num.279;
let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.281;
procedure Str.12 (#Attr.2):
let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.241;
let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2;
ret Str.245;
procedure Str.36 (#Attr.2):
let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.242;
let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2;
ret Str.246;
procedure Str.43 (#Attr.2):
let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.239;
let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2;
ret Str.243;
procedure Str.9 (Str.67):
let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67;
let Str.236 : Int1 = StructAtIndex 2 Str.68;
if Str.236 then
let Str.238 : Str = StructAtIndex 1 Str.68;
let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238;
ret Str.237;
procedure Str.9 (Str.71):
let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71;
let Str.240 : Int1 = StructAtIndex 2 Str.72;
if Str.240 then
let Str.242 : Str = StructAtIndex 1 Str.72;
let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242;
ret Str.241;
else
let Str.234 : U8 = StructAtIndex 3 Str.68;
let Str.235 : U64 = StructAtIndex 0 Str.68;
let #Derived_gen.28 : Str = StructAtIndex 1 Str.68;
let Str.238 : U8 = StructAtIndex 3 Str.72;
let Str.239 : U64 = StructAtIndex 0 Str.72;
let #Derived_gen.28 : Str = StructAtIndex 1 Str.72;
dec #Derived_gen.28;
let Str.233 : {U64, U8} = Struct {Str.235, Str.234};
let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233;
ret Str.232;
let Str.237 : {U64, U8} = Struct {Str.239, Str.238};
let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237;
ret Str.236;
procedure Test.19 (Test.55):
let Test.300 : Str = CallByName Encode.23 Test.55;
ret Test.300;
procedure Test.20 (Test.56):
let Test.301 : Str = CallByName Encode.23 Test.56;
ret Test.301;
procedure Test.2 ():
let Test.258 : {} = Struct {};
ret Test.258;
procedure Test.21 (Test.59, Test.60):
inc Test.59;
let Test.267 : {List Str, {}} = Struct {Test.59, Test.60};
let Test.266 : {List Str, {}} = CallByName Encode.23 Test.267;
ret Test.266;
procedure Test.20 (Test.58, Test.59):
inc Test.58;
let Test.266 : {List Str, {}} = Struct {Test.58, Test.59};
let Test.265 : {List Str, {}} = CallByName Encode.23 Test.266;
ret Test.265;
procedure Test.23 (Test.75):
let Test.265 : {} = Struct {};
let Test.264 : {List Str, {}} = CallByName Test.21 Test.75 Test.265;
ret Test.264;
procedure Test.22 (Test.74):
let Test.264 : {} = Struct {};
let Test.263 : {List Str, {}} = CallByName Test.20 Test.74 Test.264;
ret Test.263;
procedure Test.24 (Test.78, Test.79):
let Test.286 : Str = CallByName Test.20 Test.78;
let Test.263 : List Str = CallByName List.13 Test.79 Test.286;
let Test.262 : {List Str, {}} = CallByName Test.23 Test.263;
dec Test.263;
ret Test.262;
procedure Test.23 (Test.77, Test.78):
let Test.285 : Str = CallByName Test.19 Test.77;
let Test.262 : List Str = CallByName List.13 Test.78 Test.285;
let Test.261 : {List Str, {}} = CallByName Test.22 Test.262;
dec Test.262;
ret Test.261;
procedure Test.3 ():
let Test.259 : {} = Struct {};
ret Test.259;
procedure Test.3 (Test.48, Test.49, Test.50):
let Test.283 : U8 = CallByName Num.127 Test.49;
let Test.280 : List U8 = CallByName List.4 Test.48 Test.283;
let Test.282 : Str = CallByName Num.96 Test.50;
let Test.281 : List U8 = CallByName Str.12 Test.282;
let Test.278 : List U8 = CallByName List.8 Test.280 Test.281;
let Test.279 : U8 = 32i64;
let Test.277 : List U8 = CallByName List.4 Test.278 Test.279;
ret Test.277;
procedure Test.4 (Test.49, Test.50, Test.51):
let Test.284 : U8 = CallByName Num.127 Test.50;
let Test.281 : List U8 = CallByName List.4 Test.49 Test.284;
let Test.283 : Str = CallByName Num.96 Test.51;
let Test.282 : List U8 = CallByName Str.12 Test.283;
let Test.279 : List U8 = CallByName List.8 Test.281 Test.282;
let Test.280 : U8 = 32i64;
let Test.278 : List U8 = CallByName List.4 Test.279 Test.280;
ret Test.278;
procedure Test.56 (Test.57, Test.288, Test.55):
let Test.295 : I64 = 115i64;
let Test.296 : U64 = CallByName Str.36 Test.55;
let Test.293 : List U8 = CallByName Test.3 Test.57 Test.295 Test.296;
let Test.294 : List U8 = CallByName Str.12 Test.55;
let Test.291 : List U8 = CallByName List.8 Test.293 Test.294;
let Test.292 : U8 = 32i64;
let Test.290 : List U8 = CallByName List.4 Test.291 Test.292;
ret Test.290;
procedure Test.57 (Test.58, Test.289, Test.56):
let Test.296 : I64 = 115i64;
let Test.297 : U64 = CallByName Str.36 Test.56;
let Test.294 : List U8 = CallByName Test.4 Test.58 Test.296 Test.297;
let Test.295 : List U8 = CallByName Str.12 Test.56;
let Test.292 : List U8 = CallByName List.8 Test.294 Test.295;
let Test.293 : U8 = 32i64;
let Test.291 : List U8 = CallByName List.4 Test.292 Test.293;
ret Test.291;
procedure Test.60 (Test.61, Test.267, #Attr.12):
let Test.59 : {} = StructAtIndex 1 #Attr.12;
let Test.58 : List Str = StructAtIndex 0 #Attr.12;
let Test.275 : I64 = 108i64;
let Test.276 : U64 = CallByName List.6 Test.58;
let Test.62 : List U8 = CallByName Test.3 Test.61 Test.275 Test.276;
let Test.269 : List U8 = CallByName List.18 Test.58 Test.62 Test.59;
dec Test.58;
ret Test.269;
procedure Test.61 (Test.62, Test.268, #Attr.12):
let Test.60 : {} = StructAtIndex 1 #Attr.12;
let Test.59 : List Str = StructAtIndex 0 #Attr.12;
let Test.276 : I64 = 108i64;
let Test.277 : U64 = CallByName List.6 Test.59;
let Test.63 : List U8 = CallByName Test.4 Test.62 Test.276 Test.277;
let Test.270 : List U8 = CallByName List.18 Test.59 Test.63 Test.60;
dec Test.59;
ret Test.270;
procedure Test.63 (Test.64, Test.65, Test.59):
let Test.273 : Str = CallByName Test.75 Test.65;
let Test.274 : {} = Struct {};
let Test.272 : List U8 = CallByName Encode.24 Test.64 Test.273 Test.274;
ret Test.272;
procedure Test.64 (Test.65, Test.66, Test.60):
let Test.274 : Str = CallByName Test.76 Test.66;
let Test.275 : {} = Struct {};
let Test.273 : List U8 = CallByName Encode.24 Test.65 Test.274 Test.275;
ret Test.273;
procedure Test.75 (Test.76):
ret Test.76;
procedure Test.76 (Test.77):
ret Test.77;
procedure Test.0 ():
let Test.261 : Str = "foo";
let Test.260 : Str = "foo";
let Test.259 : Str = "foo";
let Test.209 : {Str, Str} = Struct {Test.259, Test.260};
let Test.257 : {} = CallByName Test.2;
let Test.256 : List U8 = CallByName Encode.26 Test.209 Test.257;
let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256;
let Test.253 : U8 = 1i64;
let Test.254 : U8 = GetTagId Test.210;
let Test.255 : Int1 = lowlevel Eq Test.253 Test.254;
if Test.255 then
let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210;
ret Test.212;
let Test.210 : {Str, Str} = Struct {Test.260, Test.261};
let Test.258 : {} = CallByName Test.3;
let Test.257 : List U8 = CallByName Encode.26 Test.210 Test.258;
let Test.211 : [C {U64, U8}, C Str] = CallByName Str.9 Test.257;
let Test.254 : U8 = 1i64;
let Test.255 : U8 = GetTagId Test.211;
let Test.256 : Int1 = lowlevel Eq Test.254 Test.255;
if Test.256 then
let Test.213 : Str = UnionAtIndex (Id 1) (Index 0) Test.211;
ret Test.213;
else
dec Test.210;
let Test.252 : Str = "<bad>";
ret Test.252;
dec Test.211;
let Test.253 : Str = "<bad>";
ret Test.253;

View file

@ -1,10 +1,10 @@
procedure Num.20 (#Attr.2, #Attr.3):
let Num.280 : I64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : I64 = lowlevel NumSub #Attr.2 #Attr.3;
ret Num.282;
procedure Num.21 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumMul #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : I64 = lowlevel NumMul #Attr.2 #Attr.3;
ret Num.281;
procedure Test.1 (#Derived_gen.0, #Derived_gen.1):
joinpoint Test.7 Test.2 Test.3:

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.281;
procedure Test.1 (Test.8):
let Test.3 : I64 = 10i64;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.280 : U8 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : U8 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.282;
procedure Test.1 (Test.9):
let Test.4 : U8 = 10i64;

View file

@ -3,8 +3,8 @@ procedure Bool.1 ():
ret Bool.23;
procedure Num.19 (#Attr.2, #Attr.3):
let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.279;
let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.281;
procedure Test.3 (Test.4):
ret Test.4;

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.283;
procedure Test.2 (Test.3):
switch Test.3:

View file

@ -1,6 +1,6 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.280 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.282;
procedure Test.2 (Test.3, Test.1):
let Test.18 : Int1 = false;

File diff suppressed because it is too large Load diff

View file

@ -3,13 +3,13 @@ procedure #Derived.0 (#Derived.1):
ret #Derived_gen.0;
procedure #Derived.3 (#Derived.2):
let #Derived_gen.7 : I64 = CallByName Inspect.53 #Derived.2;
let #Derived_gen.7 : I64 = CallByName Inspect.57 #Derived.2;
ret #Derived_gen.7;
procedure #Derived.4 (#Derived.5, #Derived.1):
let #Derived_gen.5 : {} = Struct {};
let #Derived_gen.6 : {} = Struct {};
let #Derived_gen.4 : {List I64, {}, {}} = CallByName Inspect.36 #Derived.1 #Derived_gen.5 #Derived_gen.6;
let #Derived_gen.4 : {List I64, {}, {}} = CallByName Inspect.40 #Derived.1 #Derived_gen.5 #Derived_gen.6;
let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.5;
ret #Derived_gen.3;
@ -21,165 +21,165 @@ procedure Bool.2 ():
let Bool.23 : Int1 = true;
ret Bool.23;
procedure Inspect.152 (Inspect.153, #Attr.12):
let Inspect.151 : {} = StructAtIndex 2 #Attr.12;
let Inspect.150 : {} = StructAtIndex 1 #Attr.12;
let Inspect.149 : List I64 = StructAtIndex 0 #Attr.12;
let Inspect.343 : Str = "[";
let Inspect.324 : Str = CallByName Inspect.59 Inspect.153 Inspect.343;
dec Inspect.343;
let Inspect.325 : {List I64, {}, {}} = Struct {Inspect.149, Inspect.150, Inspect.151};
let Inspect.320 : {Str, Int1} = CallByName Inspect.154 Inspect.324 Inspect.325;
dec Inspect.324;
let Inspect.321 : {} = Struct {};
let Inspect.316 : Str = CallByName Inspect.163 Inspect.320;
let Inspect.317 : Str = "]";
let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317;
dec Inspect.317;
ret Inspect.315;
procedure Inspect.154 (Inspect.155, #Attr.12):
let Inspect.151 : {} = StructAtIndex 2 #Attr.12;
let Inspect.150 : {} = StructAtIndex 1 #Attr.12;
let Inspect.149 : List I64 = StructAtIndex 0 #Attr.12;
let Inspect.342 : Int1 = CallByName Bool.1;
inc Inspect.155;
let Inspect.328 : {Str, Int1} = Struct {Inspect.155, Inspect.342};
let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.149 Inspect.328 Inspect.151;
dec Inspect.149;
ret Inspect.327;
procedure Inspect.156 (Inspect.330, Inspect.159, Inspect.151):
let Inspect.157 : Str = StructAtIndex 0 Inspect.330;
let Inspect.158 : Int1 = StructAtIndex 1 Inspect.330;
joinpoint Inspect.340 Inspect.160:
let Inspect.337 : I64 = CallByName #Derived.3 Inspect.159;
let Inspect.333 : Str = CallByName Inspect.31 Inspect.337 Inspect.160;
let Inspect.334 : {} = Struct {};
let Inspect.332 : {Str, Int1} = CallByName Inspect.161 Inspect.333;
dec Inspect.333;
ret Inspect.332;
in
if Inspect.158 then
let Inspect.341 : Str = ", ";
let Inspect.339 : Str = CallByName Inspect.59 Inspect.157 Inspect.341;
dec Inspect.341;
jump Inspect.340 Inspect.339;
else
jump Inspect.340 Inspect.157;
procedure Inspect.161 (Inspect.162):
let Inspect.336 : Int1 = CallByName Bool.2;
inc Inspect.162;
let Inspect.335 : {Str, Int1} = Struct {Inspect.162, Inspect.336};
ret Inspect.335;
procedure Inspect.163 (Inspect.322):
let Inspect.323 : Str = StructAtIndex 0 Inspect.322;
ret Inspect.323;
procedure Inspect.274 (Inspect.275, Inspect.273):
let Inspect.349 : Str = CallByName Num.96 Inspect.273;
let Inspect.348 : Str = CallByName Inspect.59 Inspect.275 Inspect.349;
dec Inspect.349;
ret Inspect.348;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.30 (Inspect.143):
ret Inspect.143;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.310 : Str = CallByName Inspect.152 Inspect.145 Inspect.299;
ret Inspect.310;
procedure Inspect.31 (Inspect.299, Inspect.145):
let Inspect.338 : Str = CallByName Inspect.274 Inspect.145 Inspect.299;
ret Inspect.338;
procedure Inspect.33 (Inspect.148):
let Inspect.301 : Str = CallByName Inspect.5 Inspect.148;
let Inspect.300 : Str = CallByName Inspect.60 Inspect.301;
ret Inspect.300;
procedure Inspect.35 (Inspect.297):
let Inspect.307 : Str = "";
ret Inspect.307;
procedure Inspect.36 (Inspect.149, Inspect.150, Inspect.151):
inc Inspect.149;
let Inspect.312 : {List I64, {}, {}} = Struct {Inspect.149, Inspect.150, Inspect.151};
let Inspect.311 : {List I64, {}, {}} = CallByName Inspect.30 Inspect.312;
ret Inspect.311;
procedure Inspect.5 (Inspect.146):
let Inspect.308 : List I64 = CallByName #Derived.0 Inspect.146;
let Inspect.305 : {} = Struct {};
let Inspect.304 : Str = CallByName Inspect.35 Inspect.305;
let Inspect.303 : Str = CallByName #Derived.4 Inspect.304 Inspect.308;
dec Inspect.308;
ret Inspect.303;
procedure Inspect.53 (Inspect.273):
let Inspect.344 : I64 = CallByName Inspect.30 Inspect.273;
ret Inspect.344;
procedure Inspect.59 (Inspect.296, Inspect.292):
let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292;
procedure Inspect.156 (Inspect.157, #Attr.12):
let Inspect.155 : {} = StructAtIndex 2 #Attr.12;
let Inspect.154 : {} = StructAtIndex 1 #Attr.12;
let Inspect.153 : List I64 = StructAtIndex 0 #Attr.12;
let Inspect.347 : Str = "[";
let Inspect.328 : Str = CallByName Inspect.63 Inspect.157 Inspect.347;
dec Inspect.347;
let Inspect.329 : {List I64, {}, {}} = Struct {Inspect.153, Inspect.154, Inspect.155};
let Inspect.324 : {Str, Int1} = CallByName Inspect.158 Inspect.328 Inspect.329;
dec Inspect.328;
let Inspect.325 : {} = Struct {};
let Inspect.320 : Str = CallByName Inspect.167 Inspect.324;
let Inspect.321 : Str = "]";
let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321;
dec Inspect.321;
ret Inspect.319;
procedure Inspect.60 (Inspect.298):
ret Inspect.298;
procedure Inspect.158 (Inspect.159, #Attr.12):
let Inspect.155 : {} = StructAtIndex 2 #Attr.12;
let Inspect.154 : {} = StructAtIndex 1 #Attr.12;
let Inspect.153 : List I64 = StructAtIndex 0 #Attr.12;
let Inspect.346 : Int1 = CallByName Bool.1;
inc Inspect.159;
let Inspect.332 : {Str, Int1} = Struct {Inspect.159, Inspect.346};
let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.153 Inspect.332 Inspect.155;
dec Inspect.153;
ret Inspect.331;
procedure List.18 (List.163, List.164, List.165):
let List.623 : U64 = 0i64;
let List.624 : U64 = CallByName List.6 List.163;
let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624;
ret List.622;
procedure Inspect.160 (Inspect.334, Inspect.163, Inspect.155):
let Inspect.161 : Str = StructAtIndex 0 Inspect.334;
let Inspect.162 : Int1 = StructAtIndex 1 Inspect.334;
joinpoint Inspect.344 Inspect.164:
let Inspect.341 : I64 = CallByName #Derived.3 Inspect.163;
let Inspect.337 : Str = CallByName Inspect.31 Inspect.341 Inspect.164;
let Inspect.338 : {} = Struct {};
let Inspect.336 : {Str, Int1} = CallByName Inspect.165 Inspect.337;
dec Inspect.337;
ret Inspect.336;
in
if Inspect.162 then
let Inspect.345 : Str = ", ";
let Inspect.343 : Str = CallByName Inspect.63 Inspect.161 Inspect.345;
dec Inspect.345;
jump Inspect.344 Inspect.343;
else
jump Inspect.344 Inspect.161;
procedure Inspect.165 (Inspect.166):
let Inspect.340 : Int1 = CallByName Bool.2;
inc Inspect.166;
let Inspect.339 : {Str, Int1} = Struct {Inspect.166, Inspect.340};
ret Inspect.339;
procedure Inspect.167 (Inspect.326):
let Inspect.327 : Str = StructAtIndex 0 Inspect.326;
ret Inspect.327;
procedure Inspect.278 (Inspect.279, Inspect.277):
let Inspect.353 : Str = CallByName Num.96 Inspect.277;
let Inspect.352 : Str = CallByName Inspect.63 Inspect.279 Inspect.353;
dec Inspect.353;
ret Inspect.352;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.30 (Inspect.147):
ret Inspect.147;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.314 : Str = CallByName Inspect.156 Inspect.149 Inspect.303;
ret Inspect.314;
procedure Inspect.31 (Inspect.303, Inspect.149):
let Inspect.342 : Str = CallByName Inspect.278 Inspect.149 Inspect.303;
ret Inspect.342;
procedure Inspect.33 (Inspect.152):
let Inspect.305 : Str = CallByName Inspect.5 Inspect.152;
let Inspect.304 : Str = CallByName Inspect.64 Inspect.305;
ret Inspect.304;
procedure Inspect.39 (Inspect.301):
let Inspect.311 : Str = "";
ret Inspect.311;
procedure Inspect.40 (Inspect.153, Inspect.154, Inspect.155):
inc Inspect.153;
let Inspect.316 : {List I64, {}, {}} = Struct {Inspect.153, Inspect.154, Inspect.155};
let Inspect.315 : {List I64, {}, {}} = CallByName Inspect.30 Inspect.316;
ret Inspect.315;
procedure Inspect.5 (Inspect.150):
let Inspect.312 : List I64 = CallByName #Derived.0 Inspect.150;
let Inspect.309 : {} = Struct {};
let Inspect.308 : Str = CallByName Inspect.39 Inspect.309;
let Inspect.307 : Str = CallByName #Derived.4 Inspect.308 Inspect.312;
dec Inspect.312;
ret Inspect.307;
procedure Inspect.57 (Inspect.277):
let Inspect.348 : I64 = CallByName Inspect.30 Inspect.277;
ret Inspect.348;
procedure Inspect.63 (Inspect.300, Inspect.296):
let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296;
ret Inspect.323;
procedure Inspect.64 (Inspect.302):
ret Inspect.302;
procedure List.18 (List.166, List.167, List.168):
let List.626 : U64 = 0i64;
let List.627 : U64 = CallByName List.6 List.166;
let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627;
ret List.625;
procedure List.6 (#Attr.2):
let List.633 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.633;
let List.636 : U64 = lowlevel ListLenU64 #Attr.2;
ret List.636;
procedure List.66 (#Attr.2, #Attr.3):
let List.632 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.632;
let List.635 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3;
ret List.635;
procedure List.92 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23):
joinpoint List.625 List.166 List.167 List.168 List.169 List.170:
let List.627 : Int1 = CallByName Num.22 List.169 List.170;
if List.627 then
let List.631 : I64 = CallByName List.66 List.166 List.169;
let List.171 : {Str, Int1} = CallByName Inspect.156 List.167 List.631 List.168;
let List.630 : U64 = 1i64;
let List.629 : U64 = CallByName Num.51 List.169 List.630;
jump List.625 List.166 List.171 List.168 List.629 List.170;
procedure List.95 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23):
joinpoint List.628 List.169 List.170 List.171 List.172 List.173:
let List.630 : Int1 = CallByName Num.22 List.172 List.173;
if List.630 then
let List.634 : I64 = CallByName List.66 List.169 List.172;
let List.174 : {Str, Int1} = CallByName Inspect.160 List.170 List.634 List.171;
let List.633 : U64 = 1i64;
let List.632 : U64 = CallByName Num.51 List.172 List.633;
jump List.628 List.169 List.174 List.171 List.632 List.173;
else
dec List.166;
ret List.167;
dec List.169;
ret List.170;
in
inc #Derived_gen.19;
jump List.625 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23;
jump List.628 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23;
procedure Num.22 (#Attr.2, #Attr.3):
let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.281;
let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3;
ret Num.283;
procedure Num.51 (#Attr.2, #Attr.3):
let Num.280 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.280;
let Num.282 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3;
ret Num.282;
procedure Num.96 (#Attr.2):
let Num.279 : Str = lowlevel NumToStr #Attr.2;
ret Num.279;
let Num.281 : Str = lowlevel NumToStr #Attr.2;
ret Num.281;
procedure Str.3 (#Attr.2, #Attr.3):
let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.232;
let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
ret Str.236;
procedure Test.0 ():
let Test.2 : List I64 = Array [1i64, 2i64, 3i64];

Some files were not shown because too many files have changed in this diff Show more