mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Merge branch 'main' into specialize-exprs
This commit is contained in:
commit
2e96aca0fd
797 changed files with 17394 additions and 12632 deletions
|
@ -62,6 +62,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
|
|||
&dep_idents,
|
||||
&qualified_module_ids,
|
||||
None,
|
||||
roc_can::env::FxMode::PurityInference,
|
||||
);
|
||||
|
||||
// Desugar operators (convert them to Apply calls, taking into account
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-28,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -59,16 +60,16 @@ Defs {
|
|||
@15-22 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-25,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -43,16 +44,16 @@ Defs {
|
|||
@15-19 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-19,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-43,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -53,16 +54,16 @@ Defs {
|
|||
@15-33 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-33,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-45,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -53,16 +54,16 @@ Defs {
|
|||
@15-35 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-35,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-28,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -43,16 +44,16 @@ Defs {
|
|||
@15-22 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -24,25 +25,25 @@ Defs {
|
|||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@11-15 Apply(
|
||||
@11-15 Var {
|
||||
@11-14 Apply(
|
||||
@11-14 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-15 Defs(
|
||||
@11-14 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-15,
|
||||
@11-14,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -66,19 +67,19 @@ Defs {
|
|||
body_pattern: @11-15 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @11-15 Var {
|
||||
body_expr: @11-14 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-15 Var {
|
||||
@11-14 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
),
|
||||
@11-15 Closure(
|
||||
@11-14 Closure(
|
||||
[
|
||||
@11-15 Underscore(
|
||||
"#!stmt",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-42,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -43,16 +44,16 @@ Defs {
|
|||
@16-35 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@16-35,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-69,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,16 +28,16 @@ Defs {
|
|||
@11-69 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-57,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -51,25 +52,25 @@ Defs {
|
|||
ident: "msg",
|
||||
},
|
||||
],
|
||||
@31-42 Apply(
|
||||
@31-42 Var {
|
||||
@31-43 Apply(
|
||||
@31-43 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@31-42 Defs(
|
||||
@31-43 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@31-42,
|
||||
@31-43,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -93,8 +94,8 @@ Defs {
|
|||
body_pattern: @31-43 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @31-42 Apply(
|
||||
@31-42 Var {
|
||||
body_expr: @31-43 Apply(
|
||||
@31-43 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
|
@ -111,12 +112,12 @@ Defs {
|
|||
},
|
||||
],
|
||||
},
|
||||
@31-42 Var {
|
||||
@31-43 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
),
|
||||
@31-42 Closure(
|
||||
@31-43 Closure(
|
||||
[
|
||||
@31-43 Underscore(
|
||||
"#!stmt",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-114,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,16 +28,16 @@ Defs {
|
|||
@11-114 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@39-101,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -53,6 +54,7 @@ Defs {
|
|||
[],
|
||||
),
|
||||
],
|
||||
Pure,
|
||||
@22-30 Apply(
|
||||
"",
|
||||
"Task",
|
||||
|
@ -77,16 +79,16 @@ Defs {
|
|||
@56-91 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@82-91,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-143,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,16 +28,16 @@ Defs {
|
|||
@12-143 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@56-119,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -62,6 +63,7 @@ Defs {
|
|||
[],
|
||||
),
|
||||
],
|
||||
Pure,
|
||||
@34-45 Apply(
|
||||
"",
|
||||
"Task",
|
||||
|
@ -105,16 +107,16 @@ Defs {
|
|||
@76-83 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@76-83,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -174,16 +176,16 @@ Defs {
|
|||
@92-99 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@92-99,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
assertion_line: 463
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -28,16 +28,16 @@ Defs {
|
|||
@11-26 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -50,16 +50,16 @@ Defs {
|
|||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@20-25,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-49,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -24,17 +25,17 @@ Defs {
|
|||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@17-24 Apply(
|
||||
@17-24 Var {
|
||||
@17-23 Apply(
|
||||
@17-23 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@17-24 Var {
|
||||
@17-23 Var {
|
||||
module_name: "",
|
||||
ident: "getFoo",
|
||||
},
|
||||
@17-24 Closure(
|
||||
@17-23 Closure(
|
||||
[
|
||||
@11-14 Identifier {
|
||||
ident: "foo",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -30,28 +31,28 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@15-17 Var {
|
||||
@15-16 Var {
|
||||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
@11-17 Closure(
|
||||
[
|
||||
@15-17 Identifier {
|
||||
@15-16 Identifier {
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@11-17 LowLevelDbg(
|
||||
(
|
||||
"test.roc:2",
|
||||
"in",
|
||||
"i",
|
||||
),
|
||||
@15-17 Apply(
|
||||
@15-17 Var {
|
||||
@15-16 Apply(
|
||||
@15-16 Var {
|
||||
module_name: "Inspect",
|
||||
ident: "toStr",
|
||||
},
|
||||
[
|
||||
@15-17 Var {
|
||||
@15-16 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-99,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -48,7 +49,7 @@ Defs {
|
|||
"1",
|
||||
),
|
||||
],
|
||||
value: @97-99 Var {
|
||||
value: @97-98 Var {
|
||||
module_name: "",
|
||||
ident: "c",
|
||||
},
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
Index(2147483649),
|
||||
EitherIndex(2147483648),
|
||||
EitherIndex(2147483649),
|
||||
],
|
||||
regions: [
|
||||
@0-54,
|
||||
@56-98,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 2),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 2, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,16 +34,16 @@ Defs {
|
|||
@11-54 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-20,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -68,16 +69,16 @@ Defs {
|
|||
@25-39 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@25-39,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -128,7 +129,7 @@ Defs {
|
|||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@45-54 Var {
|
||||
@45-53 Var {
|
||||
module_name: "",
|
||||
ident: "printBar",
|
||||
},
|
||||
|
@ -145,16 +146,16 @@ Defs {
|
|||
@71-98 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@75-80,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-158,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -39,16 +40,16 @@ Defs {
|
|||
value: @46-130 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@50-52,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -70,13 +71,13 @@ Defs {
|
|||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
@92-94 Var {
|
||||
@92-93 Var {
|
||||
module_name: "",
|
||||
ident: "b",
|
||||
},
|
||||
),
|
||||
],
|
||||
final_else: @128-130 Var {
|
||||
final_else: @128-129 Var {
|
||||
module_name: "",
|
||||
ident: "c",
|
||||
},
|
||||
|
@ -91,7 +92,7 @@ Defs {
|
|||
"B",
|
||||
),
|
||||
],
|
||||
value: @156-158 Var {
|
||||
value: @156-157 Var {
|
||||
module_name: "",
|
||||
ident: "d",
|
||||
},
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-31,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,16 +28,16 @@ Defs {
|
|||
@11-31 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -63,7 +64,7 @@ Defs {
|
|||
},
|
||||
],
|
||||
},
|
||||
@29-31 Var {
|
||||
@29-30 Var {
|
||||
module_name: "",
|
||||
ident: "x",
|
||||
},
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-307,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,9 +28,9 @@ Defs {
|
|||
@11-307 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
Index(2147483649),
|
||||
Index(2147483650),
|
||||
EitherIndex(2147483648),
|
||||
EitherIndex(2147483649),
|
||||
EitherIndex(2147483650),
|
||||
],
|
||||
regions: [
|
||||
@20-37,
|
||||
|
@ -37,14 +38,14 @@ Defs {
|
|||
@109-298,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
Slice(start = 1, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 1 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 1, length = 0),
|
||||
Slice(start = 2, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 0 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -165,16 +166,16 @@ Defs {
|
|||
@140-152 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@140-152,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -287,16 +288,16 @@ Defs {
|
|||
@227-239 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@227-239,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-189,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,20 +28,20 @@ Defs {
|
|||
@11-189 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
Index(2147483649),
|
||||
EitherIndex(2147483648),
|
||||
EitherIndex(2147483649),
|
||||
],
|
||||
regions: [
|
||||
@20-37,
|
||||
@52-70,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 1, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -85,26 +86,26 @@ Defs {
|
|||
),
|
||||
],
|
||||
},
|
||||
@79-87 Apply(
|
||||
@79-87 Var {
|
||||
@79-86 Apply(
|
||||
@79-86 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@79-87 Var {
|
||||
@79-86 Var {
|
||||
module_name: "",
|
||||
ident: "isFalse",
|
||||
},
|
||||
@79-87 Closure(
|
||||
@79-86 Closure(
|
||||
[
|
||||
@79-87 Identifier {
|
||||
@79-86 Identifier {
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@76-189 If {
|
||||
if_thens: [
|
||||
(
|
||||
@79-87 Var {
|
||||
@79-86 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
|
@ -124,26 +125,26 @@ Defs {
|
|||
),
|
||||
),
|
||||
],
|
||||
final_else: @125-132 Apply(
|
||||
@125-132 Var {
|
||||
final_else: @125-131 Apply(
|
||||
@125-131 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@125-132 Var {
|
||||
@125-131 Var {
|
||||
module_name: "",
|
||||
ident: "isTrue",
|
||||
},
|
||||
@125-132 Closure(
|
||||
@125-131 Closure(
|
||||
[
|
||||
@125-132 Identifier {
|
||||
@125-131 Identifier {
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
],
|
||||
@76-189 If {
|
||||
if_thens: [
|
||||
(
|
||||
@125-132 Var {
|
||||
@125-131 Var {
|
||||
module_name: "",
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
|
|
|
@ -0,0 +1,290 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
EitherIndex(2147483649),
|
||||
EitherIndex(2147483650),
|
||||
],
|
||||
regions: [
|
||||
@0-80,
|
||||
@82-227,
|
||||
@229-266,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 2 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 4, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-3 Identifier {
|
||||
ident: "inc",
|
||||
},
|
||||
@6-80 Closure(
|
||||
[
|
||||
@7-8 Identifier {
|
||||
ident: "i",
|
||||
},
|
||||
],
|
||||
@16-80 If {
|
||||
if_thens: [
|
||||
(
|
||||
@19-24 Apply(
|
||||
@21-22 Var {
|
||||
module_name: "Num",
|
||||
ident: "isGt",
|
||||
},
|
||||
[
|
||||
@19-20 Var {
|
||||
module_name: "",
|
||||
ident: "i",
|
||||
},
|
||||
@23-24 Num(
|
||||
"2",
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
GreaterThan,
|
||||
),
|
||||
),
|
||||
@38-52 Apply(
|
||||
@38-41 Tag(
|
||||
"Err",
|
||||
),
|
||||
[
|
||||
@42-52 Tag(
|
||||
"MaxReached",
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
final_else: @70-80 Apply(
|
||||
@70-72 Tag(
|
||||
"Ok",
|
||||
),
|
||||
[
|
||||
@74-79 ParensAround(
|
||||
Apply(
|
||||
@76-77 Var {
|
||||
module_name: "Num",
|
||||
ident: "add",
|
||||
},
|
||||
[
|
||||
@74-75 Var {
|
||||
module_name: "",
|
||||
ident: "i",
|
||||
},
|
||||
@78-79 Num(
|
||||
"1",
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Plus,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
indented_else: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
Expect {
|
||||
condition: @93-227 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
EitherIndex(2147483649),
|
||||
],
|
||||
regions: [
|
||||
@99-189,
|
||||
@203-208,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@93-96 Identifier {
|
||||
ident: "run",
|
||||
},
|
||||
@99-189 Closure(
|
||||
[
|
||||
@100-101 Identifier {
|
||||
ident: "i",
|
||||
},
|
||||
],
|
||||
@132-172 Apply(
|
||||
@132-172 Var {
|
||||
module_name: "Result",
|
||||
ident: "try",
|
||||
},
|
||||
[
|
||||
@132-152 Apply(
|
||||
@132-152 Var {
|
||||
module_name: "",
|
||||
ident: "inc",
|
||||
},
|
||||
[
|
||||
@132-133 Var {
|
||||
module_name: "",
|
||||
ident: "i",
|
||||
},
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
@132-172 Closure(
|
||||
[
|
||||
@132-152 Identifier {
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@132-172 Apply(
|
||||
@132-172 Var {
|
||||
module_name: "Result",
|
||||
ident: "try",
|
||||
},
|
||||
[
|
||||
@132-172 Apply(
|
||||
@132-172 Var {
|
||||
module_name: "",
|
||||
ident: "inc",
|
||||
},
|
||||
[
|
||||
@132-152 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
@132-172 Closure(
|
||||
[
|
||||
@113-117 Identifier {
|
||||
ident: "newi",
|
||||
},
|
||||
],
|
||||
@182-189 Apply(
|
||||
@182-184 Tag(
|
||||
"Ok",
|
||||
),
|
||||
[
|
||||
@185-189 Var {
|
||||
module_name: "",
|
||||
ident: "newi",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
QuestionSuffix,
|
||||
),
|
||||
),
|
||||
],
|
||||
QuestionSuffix,
|
||||
),
|
||||
),
|
||||
),
|
||||
Body(
|
||||
@194-200 Identifier {
|
||||
ident: "result",
|
||||
},
|
||||
@203-208 Apply(
|
||||
@203-206 Var {
|
||||
module_name: "",
|
||||
ident: "run",
|
||||
},
|
||||
[
|
||||
@207-208 Num(
|
||||
"0",
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
@213-227 Apply(
|
||||
@220-222 Var {
|
||||
module_name: "Bool",
|
||||
ident: "isEq",
|
||||
},
|
||||
[
|
||||
@213-219 Var {
|
||||
module_name: "",
|
||||
ident: "result",
|
||||
},
|
||||
@223-227 Apply(
|
||||
@223-225 Tag(
|
||||
"Ok",
|
||||
),
|
||||
[
|
||||
@226-227 Num(
|
||||
"2",
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Equals,
|
||||
),
|
||||
),
|
||||
),
|
||||
preceding_comment: @82-82,
|
||||
},
|
||||
Body(
|
||||
@229-233 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@240-266 Apply(
|
||||
@240-266 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@253-266 Str(
|
||||
PlainLine(
|
||||
"Hello world",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
EitherIndex(2147483649),
|
||||
],
|
||||
regions: [
|
||||
@0-33,
|
||||
@35-45,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-3 Identifier {
|
||||
ident: "run",
|
||||
},
|
||||
ann_type: @6-15 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@11-13 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@14-15 Inferred,
|
||||
],
|
||||
),
|
||||
lines_between: [
|
||||
Newline,
|
||||
],
|
||||
body_pattern: @16-19 Identifier {
|
||||
ident: "run",
|
||||
},
|
||||
body_expr: @22-33 Apply(
|
||||
@22-33 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@28-33 Str(
|
||||
PlainLine(
|
||||
"foo",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
Body(
|
||||
@35-39 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@42-45 Var {
|
||||
module_name: "",
|
||||
ident: "run",
|
||||
},
|
||||
),
|
||||
],
|
||||
}
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,16 +28,16 @@ Defs {
|
|||
@11-26 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-17,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-33,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -24,25 +25,25 @@ Defs {
|
|||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@11-15 Apply(
|
||||
@11-15 Var {
|
||||
@11-14 Apply(
|
||||
@11-14 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-15 Defs(
|
||||
@11-14 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-15,
|
||||
@11-14,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -66,43 +67,43 @@ Defs {
|
|||
body_pattern: @11-15 Identifier {
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
body_expr: @11-15 Var {
|
||||
body_expr: @11-14 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-15 Var {
|
||||
@11-14 Var {
|
||||
module_name: "",
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
),
|
||||
@11-15 Closure(
|
||||
@11-14 Closure(
|
||||
[
|
||||
@11-15 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@20-24 Apply(
|
||||
@20-24 Var {
|
||||
@20-23 Apply(
|
||||
@20-23 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@20-24 Defs(
|
||||
@20-23 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@20-24,
|
||||
@20-23,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -126,25 +127,25 @@ Defs {
|
|||
body_pattern: @20-24 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
body_expr: @20-24 Var {
|
||||
body_expr: @20-23 Var {
|
||||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@20-24 Var {
|
||||
@20-23 Var {
|
||||
module_name: "",
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
),
|
||||
@20-24 Closure(
|
||||
@20-23 Closure(
|
||||
[
|
||||
@20-24 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@29-33 Var {
|
||||
@29-32 Var {
|
||||
module_name: "",
|
||||
ident: "baz",
|
||||
},
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-72,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,16 +34,16 @@ Defs {
|
|||
@11-23 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-23,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -94,14 +95,14 @@ Defs {
|
|||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@33-55 Apply(
|
||||
@33-55 Var {
|
||||
@33-56 Apply(
|
||||
@33-56 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@33-55 Apply(
|
||||
@33-55 Var {
|
||||
@33-56 Apply(
|
||||
@33-56 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
|
@ -116,7 +117,7 @@ Defs {
|
|||
Pizza,
|
||||
),
|
||||
),
|
||||
@33-55 Closure(
|
||||
@33-56 Closure(
|
||||
[
|
||||
@28-30 RecordDestructure(
|
||||
[],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-51,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,16 +28,16 @@ Defs {
|
|||
@11-51 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@17-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,16 +34,16 @@ Defs {
|
|||
@11-16 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-16,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-61,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-49,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -27,16 +28,16 @@ Defs {
|
|||
@11-49 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@23-42,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -45,17 +46,17 @@ Defs {
|
|||
@11-12 Identifier {
|
||||
ident: "x",
|
||||
},
|
||||
@27-29 Apply(
|
||||
@27-29 Var {
|
||||
@27-28 Apply(
|
||||
@27-28 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@27-29 Var {
|
||||
@27-28 Var {
|
||||
module_name: "",
|
||||
ident: "b",
|
||||
},
|
||||
@27-29 Closure(
|
||||
@27-28 Closure(
|
||||
[
|
||||
@23-24 Identifier {
|
||||
ident: "a",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
assertion_line: 473
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-51,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -28,16 +28,16 @@ Defs {
|
|||
@11-51 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-40,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -55,16 +55,16 @@ Defs {
|
|||
@11-23 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-12,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-73,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -24,25 +25,25 @@ Defs {
|
|||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@11-56 Apply(
|
||||
@11-56 Var {
|
||||
@11-57 Apply(
|
||||
@11-57 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-56 Defs(
|
||||
@11-57 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-56,
|
||||
@11-57,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -66,8 +67,8 @@ Defs {
|
|||
body_pattern: @11-57 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @11-56 Apply(
|
||||
@11-56 Var {
|
||||
body_expr: @11-57 Apply(
|
||||
@11-57 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
|
@ -101,12 +102,12 @@ Defs {
|
|||
},
|
||||
],
|
||||
},
|
||||
@11-56 Var {
|
||||
@11-57 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
),
|
||||
@11-56 Closure(
|
||||
@11-57 Closure(
|
||||
[
|
||||
@11-57 Underscore(
|
||||
"#!stmt",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-67,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -42,16 +43,16 @@ Defs {
|
|||
@19-30 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@19-30,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-154,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -24,17 +25,17 @@ Defs {
|
|||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@20-31 Apply(
|
||||
@20-31 Var {
|
||||
@20-30 Apply(
|
||||
@20-30 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@20-31 Var {
|
||||
@20-30 Var {
|
||||
module_name: "Stdin",
|
||||
ident: "line",
|
||||
},
|
||||
@20-31 Closure(
|
||||
@20-30 Closure(
|
||||
[
|
||||
@11-17 Identifier {
|
||||
ident: "result",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-44,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -30,25 +31,25 @@ Defs {
|
|||
ident: "x",
|
||||
},
|
||||
],
|
||||
@28-30 Apply(
|
||||
@28-30 Var {
|
||||
@28-29 Apply(
|
||||
@28-29 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@14-30 Defs(
|
||||
@14-29 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@28-30,
|
||||
@28-29,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -73,19 +74,19 @@ Defs {
|
|||
body_pattern: @24-25 Identifier {
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
body_expr: @28-30 Var {
|
||||
body_expr: @28-29 Var {
|
||||
module_name: "",
|
||||
ident: "x",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@28-30 Var {
|
||||
@28-29 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
),
|
||||
@28-30 Closure(
|
||||
@28-29 Closure(
|
||||
[
|
||||
@24-25 Identifier {
|
||||
ident: "r",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-45,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -24,24 +25,24 @@ Defs {
|
|||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@15-19 Apply(
|
||||
@15-19 Var {
|
||||
@15-18 Apply(
|
||||
@15-18 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@15-19 Var {
|
||||
@15-18 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
@15-19 Closure(
|
||||
@15-18 Closure(
|
||||
[
|
||||
@11-12 Identifier {
|
||||
ident: "a",
|
||||
},
|
||||
],
|
||||
@15-19 Apply(
|
||||
@15-19 Var {
|
||||
@15-18 Apply(
|
||||
@15-18 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
|
@ -50,7 +51,7 @@ Defs {
|
|||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
@15-19 Closure(
|
||||
@15-18 Closure(
|
||||
[
|
||||
@28-33 Identifier {
|
||||
ident: "#!0_arg",
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-120,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -30,18 +31,18 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@16-24 Var {
|
||||
@16-23 Var {
|
||||
module_name: "",
|
||||
ident: "getList",
|
||||
},
|
||||
@11-120 Closure(
|
||||
[
|
||||
@16-24 Identifier {
|
||||
@16-23 Identifier {
|
||||
ident: "#!2_arg",
|
||||
},
|
||||
],
|
||||
@11-120 When(
|
||||
@16-24 Var {
|
||||
@16-23 Var {
|
||||
module_name: "",
|
||||
ident: "#!2_arg",
|
||||
},
|
||||
|
@ -61,16 +62,16 @@ Defs {
|
|||
@54-65 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@54-65,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-74,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -30,18 +31,18 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@16-24 Var {
|
||||
@16-23 Var {
|
||||
module_name: "",
|
||||
ident: "getList",
|
||||
},
|
||||
@11-74 Closure(
|
||||
[
|
||||
@16-24 Identifier {
|
||||
@16-23 Identifier {
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@11-74 When(
|
||||
@16-24 Var {
|
||||
@16-23 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
|
|
|
@ -16,7 +16,7 @@ mod test_can {
|
|||
use bumpalo::Bump;
|
||||
use core::panic;
|
||||
use roc_can::expr::Expr::{self, *};
|
||||
use roc_can::expr::{ClosureData, IntValue, Recursive};
|
||||
use roc_can::expr::{ClosureData, IntValue, Recursive, WhenBranch};
|
||||
use roc_can::pattern::Pattern;
|
||||
use roc_module::called_via::CalledVia;
|
||||
use roc_problem::can::{CycleEntry, FloatErrorKind, IntErrorKind, Problem, RuntimeError};
|
||||
|
@ -415,7 +415,7 @@ mod test_can {
|
|||
let arena = Bump::new();
|
||||
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
|
||||
|
||||
assert_eq!(problems.len(), 2);
|
||||
assert_eq!(problems.len(), 1);
|
||||
println!("{problems:#?}");
|
||||
assert!(problems.iter().any(|problem| matches!(
|
||||
problem,
|
||||
|
@ -504,6 +504,7 @@ mod test_can {
|
|||
|
||||
assert_eq!(problems, Vec::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn correct_double_nested_body() {
|
||||
let src = indoc!(
|
||||
|
@ -801,6 +802,280 @@ mod test_can {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn try_desugar_plain_prefix() {
|
||||
let src = indoc!(
|
||||
r#"
|
||||
try Str.toU64 "123"
|
||||
"#
|
||||
);
|
||||
let arena = Bump::new();
|
||||
let out = can_expr_with(&arena, test_home(), src);
|
||||
|
||||
assert_eq!(out.problems, Vec::new());
|
||||
|
||||
// Assert that we desugar to:
|
||||
//
|
||||
// when Str.toU64 "123" is
|
||||
// Ok `0` -> `0`
|
||||
// Err `1` -> return Err `1`
|
||||
|
||||
let (cond_expr, branches) = assert_when(&out.loc_expr.value);
|
||||
let cond_args = assert_func_call(cond_expr, "toU64", CalledVia::Try, &out.interns);
|
||||
|
||||
assert_eq!(cond_args.len(), 1);
|
||||
assert_str_value(&cond_args[0].1.value, "123");
|
||||
|
||||
assert_eq!(branches.len(), 2);
|
||||
|
||||
assert_eq!(branches[0].patterns.len(), 1);
|
||||
assert!(!branches[0].patterns[0].degenerate);
|
||||
match &branches[0].patterns[0].pattern.value {
|
||||
Pattern::AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(tag_name.0.to_string(), "Ok");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_pattern_name(&arguments[0].1.value, "0", &out.interns);
|
||||
}
|
||||
other => panic!("First argument was not an applied tag: {:?}", other),
|
||||
}
|
||||
|
||||
assert!(&branches[0].guard.is_none());
|
||||
assert_var_usage(&branches[0].value.value, "0", &out.interns);
|
||||
|
||||
assert_eq!(branches[1].patterns.len(), 1);
|
||||
assert!(!branches[1].patterns[0].degenerate);
|
||||
match &branches[1].patterns[0].pattern.value {
|
||||
Pattern::AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(tag_name.0.to_string(), "Err");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_pattern_name(&arguments[0].1.value, "1", &out.interns);
|
||||
}
|
||||
other => panic!("First argument was not an applied tag: {:?}", other),
|
||||
}
|
||||
|
||||
match &branches[1].value.value {
|
||||
Expr::Return { return_value, .. } => match &return_value.value {
|
||||
Expr::Tag {
|
||||
name, arguments, ..
|
||||
} => {
|
||||
assert_eq!(name.0.to_string(), "Err");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_var_usage(&arguments[0].1.value, "1", &out.interns);
|
||||
}
|
||||
other_inner => panic!("Expr was not a Tag: {:?}", other_inner),
|
||||
},
|
||||
other_outer => panic!("Expr was not a Return: {:?}", other_outer),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn try_desugar_pipe_prefix() {
|
||||
let src = indoc!(
|
||||
r#"
|
||||
"123" |> try Str.toU64
|
||||
"#
|
||||
);
|
||||
let arena = Bump::new();
|
||||
let out = can_expr_with(&arena, test_home(), src);
|
||||
|
||||
assert_eq!(out.problems, Vec::new());
|
||||
|
||||
// Assert that we desugar to:
|
||||
//
|
||||
// when Str.toU64 "123" is
|
||||
// Ok `0` -> `0`
|
||||
// Err `1` -> return Err `1`
|
||||
|
||||
let (cond_expr, branches) = assert_when(&out.loc_expr.value);
|
||||
let cond_args = assert_func_call(cond_expr, "toU64", CalledVia::Try, &out.interns);
|
||||
|
||||
assert_eq!(cond_args.len(), 1);
|
||||
assert_str_value(&cond_args[0].1.value, "123");
|
||||
|
||||
assert_eq!(branches.len(), 2);
|
||||
|
||||
assert_eq!(branches[0].patterns.len(), 1);
|
||||
assert!(!branches[0].patterns[0].degenerate);
|
||||
match &branches[0].patterns[0].pattern.value {
|
||||
Pattern::AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(tag_name.0.to_string(), "Ok");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_pattern_name(&arguments[0].1.value, "0", &out.interns);
|
||||
}
|
||||
other => panic!("First argument was not an applied tag: {:?}", other),
|
||||
}
|
||||
|
||||
assert!(&branches[0].guard.is_none());
|
||||
assert_var_usage(&branches[0].value.value, "0", &out.interns);
|
||||
|
||||
assert_eq!(branches[1].patterns.len(), 1);
|
||||
assert!(!branches[1].patterns[0].degenerate);
|
||||
match &branches[1].patterns[0].pattern.value {
|
||||
Pattern::AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(tag_name.0.to_string(), "Err");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_pattern_name(&arguments[0].1.value, "1", &out.interns);
|
||||
}
|
||||
other => panic!("First argument was not an applied tag: {:?}", other),
|
||||
}
|
||||
|
||||
match &branches[1].value.value {
|
||||
Expr::Return { return_value, .. } => match &return_value.value {
|
||||
Expr::Tag {
|
||||
name, arguments, ..
|
||||
} => {
|
||||
assert_eq!(name.0.to_string(), "Err");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_var_usage(&arguments[0].1.value, "1", &out.interns);
|
||||
}
|
||||
other_inner => panic!("Expr was not a Tag: {:?}", other_inner),
|
||||
},
|
||||
other_outer => panic!("Expr was not a Return: {:?}", other_outer),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn try_desugar_pipe_suffix() {
|
||||
let src = indoc!(
|
||||
r#"
|
||||
Str.toU64 "123" |> try
|
||||
"#
|
||||
);
|
||||
let arena = Bump::new();
|
||||
let out = can_expr_with(&arena, test_home(), src);
|
||||
|
||||
assert_eq!(out.problems, Vec::new());
|
||||
|
||||
// Assert that we desugar to:
|
||||
//
|
||||
// when Str.toU64 "123" is
|
||||
// Ok `0` -> `0`
|
||||
// Err `1` -> return Err `1`
|
||||
|
||||
let (cond_expr, branches) = assert_when(&out.loc_expr.value);
|
||||
let cond_args = assert_func_call(cond_expr, "toU64", CalledVia::Space, &out.interns);
|
||||
|
||||
assert_eq!(cond_args.len(), 1);
|
||||
assert_str_value(&cond_args[0].1.value, "123");
|
||||
|
||||
assert_eq!(branches.len(), 2);
|
||||
|
||||
assert_eq!(branches[0].patterns.len(), 1);
|
||||
assert!(!branches[0].patterns[0].degenerate);
|
||||
match &branches[0].patterns[0].pattern.value {
|
||||
Pattern::AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(tag_name.0.to_string(), "Ok");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_pattern_name(&arguments[0].1.value, "0", &out.interns);
|
||||
}
|
||||
other => panic!("First argument was not an applied tag: {:?}", other),
|
||||
}
|
||||
|
||||
assert!(&branches[0].guard.is_none());
|
||||
assert_var_usage(&branches[0].value.value, "0", &out.interns);
|
||||
|
||||
assert_eq!(branches[1].patterns.len(), 1);
|
||||
assert!(!branches[1].patterns[0].degenerate);
|
||||
match &branches[1].patterns[0].pattern.value {
|
||||
Pattern::AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(tag_name.0.to_string(), "Err");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_pattern_name(&arguments[0].1.value, "1", &out.interns);
|
||||
}
|
||||
other => panic!("First argument was not an applied tag: {:?}", other),
|
||||
}
|
||||
|
||||
match &branches[1].value.value {
|
||||
Expr::Return { return_value, .. } => match &return_value.value {
|
||||
Expr::Tag {
|
||||
name, arguments, ..
|
||||
} => {
|
||||
assert_eq!(name.0.to_string(), "Err");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_var_usage(&arguments[0].1.value, "1", &out.interns);
|
||||
}
|
||||
other_inner => panic!("Expr was not a Tag: {:?}", other_inner),
|
||||
},
|
||||
other_outer => panic!("Expr was not a Return: {:?}", other_outer),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn try_desugar_works_elsewhere() {
|
||||
let src = indoc!(
|
||||
r#"
|
||||
when Foo 123 is
|
||||
Foo try -> try
|
||||
"#
|
||||
);
|
||||
let arena = Bump::new();
|
||||
let out = can_expr_with(&arena, test_home(), src);
|
||||
|
||||
assert_eq!(out.problems, Vec::new());
|
||||
|
||||
// Assert that we don't treat `try` as a keyword here
|
||||
// by desugaring to:
|
||||
//
|
||||
// when Foo 123 is
|
||||
// Foo try -> try
|
||||
|
||||
let (cond_expr, branches) = assert_when(&out.loc_expr.value);
|
||||
match cond_expr {
|
||||
Expr::Tag {
|
||||
name, arguments, ..
|
||||
} => {
|
||||
assert_eq!(name.0.to_string(), "Foo");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_num_value(&arguments[0].1.value, 123);
|
||||
}
|
||||
_ => panic!("cond_expr was not a Tag: {:?}", cond_expr),
|
||||
}
|
||||
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].patterns.len(), 1);
|
||||
assert!(!branches[0].patterns[0].degenerate);
|
||||
|
||||
match &branches[0].patterns[0].pattern.value {
|
||||
Pattern::AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(tag_name.0.to_string(), "Foo");
|
||||
assert_eq!(arguments.len(), 1);
|
||||
assert_pattern_name(&arguments[0].1.value, "try", &out.interns);
|
||||
}
|
||||
other => panic!("First argument was not an applied tag: {:?}", other),
|
||||
}
|
||||
|
||||
assert_var_usage(&branches[0].value.value, "try", &out.interns);
|
||||
assert!(&branches[0].guard.is_none());
|
||||
}
|
||||
|
||||
fn assert_num_value(expr: &Expr, num: usize) {
|
||||
match expr {
|
||||
Expr::Num(_, num_str, _, _) => {
|
||||
|
@ -810,6 +1085,15 @@ mod test_can {
|
|||
}
|
||||
}
|
||||
|
||||
fn assert_str_value(expr: &Expr, str_val: &str) {
|
||||
match expr {
|
||||
Expr::Str(str_expr) => {
|
||||
assert_eq!(&**str_expr, str_val)
|
||||
}
|
||||
_ => panic!("Expr wasn't a Str with value {str_val}: {:?}", expr),
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_var_usage(expr: &Expr, name: &str, interns: &roc_module::symbol::Interns) {
|
||||
match expr {
|
||||
Expr::Var(sym, _) => assert_eq!(sym.as_str(interns), name),
|
||||
|
@ -835,7 +1119,10 @@ mod test_can {
|
|||
|
||||
args.clone()
|
||||
}
|
||||
_ => panic!("Expr was not a RecordBuilder Call: {:?}", expr),
|
||||
_ => panic!(
|
||||
"Expr was not a Call with CalledVia={:?}: {:?}",
|
||||
called_via, expr
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -846,6 +1133,15 @@ mod test_can {
|
|||
}
|
||||
}
|
||||
|
||||
fn assert_when(expr: &Expr) -> (&Expr, &Vec<WhenBranch>) {
|
||||
match expr {
|
||||
Expr::When {
|
||||
loc_cond, branches, ..
|
||||
} => (&loc_cond.value, branches),
|
||||
_ => panic!("Expr was not a When: {:?}", expr),
|
||||
}
|
||||
}
|
||||
|
||||
// TAIL CALLS
|
||||
fn get_closure(expr: &Expr, i: usize) -> roc_can::expr::Recursive {
|
||||
match expr {
|
||||
|
|
|
@ -6,7 +6,7 @@ mod suffixed_tests {
|
|||
use bumpalo::Bump;
|
||||
use insta::assert_snapshot;
|
||||
use roc_can::desugar::desugar_defs_node_values;
|
||||
use roc_can::env::Env;
|
||||
use roc_can::env::{Env, FxMode};
|
||||
use roc_can::scope::Scope;
|
||||
use roc_module::symbol::{IdentIds, ModuleIds, PackageModuleIds};
|
||||
use roc_parse::test_helpers::parse_defs_with;
|
||||
|
@ -34,6 +34,7 @@ mod suffixed_tests {
|
|||
&dep_idents,
|
||||
&qualified_module_ids,
|
||||
None,
|
||||
FxMode::Task,
|
||||
);
|
||||
|
||||
let mut defs = parse_defs_with(arena, indoc!($src)).unwrap();
|
||||
|
@ -606,6 +607,44 @@ mod suffixed_tests {
|
|||
"##
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_7081() {
|
||||
run_test!(
|
||||
r##"
|
||||
inc = \i ->
|
||||
if i > 2 then
|
||||
Err MaxReached
|
||||
else
|
||||
Ok (i + 1)
|
||||
|
||||
expect
|
||||
run = \i ->
|
||||
newi =
|
||||
i
|
||||
|> inc?
|
||||
|> inc?
|
||||
Ok newi
|
||||
result = run 0
|
||||
result == Ok 2
|
||||
|
||||
main =
|
||||
Stdout.line! "Hello world"
|
||||
"##
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_7103() {
|
||||
run_test!(
|
||||
r##"
|
||||
run : Task {} _
|
||||
run = line! "foo"
|
||||
|
||||
main = run
|
||||
"##
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue