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

@ -62,12 +62,13 @@ Defs {
),
Stmt(
@97-111 Apply(
@97-108 TaskAwaitBang(
Var {
@97-108 TrySuffix {
target: Task,
expr: Var {
module_name: "Stdout",
ident: "line",
},
),
},
[
@110-111 Var {
module_name: "",
@ -80,12 +81,13 @@ Defs {
],
},
@141-150 SpaceBefore(
TaskAwaitBang(
Var {
TrySuffix {
target: Task,
expr: Var {
module_name: "",
ident: "printBar",
},
),
},
[
Newline,
Newline,

View file

@ -45,7 +45,7 @@ Defs {
params: Some(
ModuleImportParams {
before: [],
params: [
params: @15-29 [
@17-21 LabelOnly(
@17-21 "echo",
),
@ -71,7 +71,7 @@ Defs {
params: Some(
ModuleImportParams {
before: [],
params: [
params: @42-60 [
@44-48 LabelOnly(
@44-48 "echo",
),
@ -102,7 +102,7 @@ Defs {
params: Some(
ModuleImportParams {
before: [],
params: [
params: @73-91 [
@75-79 LabelOnly(
@75-79 "echo",
),
@ -144,7 +144,7 @@ Defs {
params: Some(
ModuleImportParams {
before: [],
params: [
params: @109-123 [
@111-115 LabelOnly(
@111-115 "echo",
),

View file

@ -5,7 +5,7 @@ SpacesBefore {
after_keyword: [],
params: Some(
ModuleParams {
params: [
pattern: @7-45 [
@8-12 Identifier {
ident: "echo",
},

View file

@ -5,7 +5,7 @@ SpacesBefore {
after_keyword: [],
params: Some(
ModuleParams {
params: [
pattern: @7-20 [
@9-10 Identifier {
ident: "x",
},

View file

@ -5,7 +5,7 @@ SpacesBefore {
after_keyword: [],
params: Some(
ModuleParams {
params: [
pattern: @7-20 [
@8-12 Identifier {
ident: "echo",
},

View file

@ -5,7 +5,7 @@ SpacesBefore {
after_keyword: [],
params: Some(
ModuleParams {
params: [
pattern: @7-20 [
@8-12 Identifier {
ident: "echo",
},

View file

@ -26,12 +26,13 @@ Defs {
(
@11-23 SpaceAfter(
Apply(
@11-19 TaskAwaitBang(
Var {
@11-19 TrySuffix {
target: Task,
expr: Var {
module_name: "Arg",
ident: "list",
},
),
},
[
@21-23 Record(
[],
@ -88,12 +89,13 @@ Defs {
),
(
@83-98 SpaceAfter(
TaskAwaitBang(
Var {
TrySuffix {
target: Task,
expr: Var {
module_name: "Task",
ident: "fromResult",
},
),
},
[
Newline,
],
@ -152,12 +154,13 @@ Defs {
@174-176 Pizza,
),
],
@177-188 TaskAwaitBang(
Var {
@177-188 TrySuffix {
target: Task,
expr: Var {
module_name: "Stdout",
ident: "line",
},
),
},
),
[
Newline,

View file

@ -0,0 +1,5 @@
data =
{ x: 5, y: 0 }
|> &y 3
data

View file

@ -0,0 +1,86 @@
SpaceAfter(
Defs(
Defs {
tags: [
Index(2147483648),
],
regions: [
@0-42,
],
space_before: [
Slice(start = 0, length = 0),
],
space_after: [
Slice(start = 0, length = 0),
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "data",
},
@11-42 SpaceBefore(
BinOps(
[
(
@11-25 SpaceAfter(
Record(
[
@13-17 RequiredValue(
@13-14 "x",
[],
@16-17 Num(
"5",
),
),
@19-23 RequiredValue(
@19-20 "y",
[],
@22-23 Num(
"0",
),
),
],
),
[
Newline,
],
),
@34-36 Pizza,
),
],
@37-42 Apply(
@37-39 RecordUpdater(
"y",
),
[
@41-42 Num(
"3",
),
],
Space,
),
),
[
Newline,
],
),
),
],
},
@44-48 SpaceBefore(
Var {
module_name: "",
ident: "data",
},
[
Newline,
Newline,
],
),
),
[
Newline,
],
)

View file

@ -0,0 +1,5 @@
data =
{ x: 5, y: 0 }
|> &y 3
data

View file

@ -0,0 +1,20 @@
SpaceAfter(
Apply(
@0-3 Var {
module_name: "",
ident: "foo",
},
[
@3-7 RecordUpdater(
"bar",
),
@9-10 Num(
"5",
),
],
Space,
),
[
Newline,
],
)

View file

@ -1,10 +0,0 @@
TaskAwaitBang(
TaskAwaitBang(
TaskAwaitBang(
Var {
module_name: "Stdout",
ident: "line",
},
),
),
)

View file

@ -0,0 +1,13 @@
TrySuffix {
target: Task,
expr: TrySuffix {
target: Task,
expr: TrySuffix {
target: Task,
expr: Var {
module_name: "Stdout",
ident: "line",
},
},
},
}

View file

@ -44,12 +44,13 @@ Defs {
value_defs: [
Stmt(
@12-21 Apply(
@12-13 TaskAwaitBang(
Var {
@12-13 TrySuffix {
target: Task,
expr: Var {
module_name: "",
ident: "a",
},
),
},
[
@16-21 Str(
PlainLine(
@ -65,12 +66,13 @@ Defs {
ident: "x",
},
@29-39 Apply(
@29-32 TaskAwaitBang(
Var {
@29-32 TrySuffix {
target: Task,
expr: Var {
module_name: "B",
ident: "b",
},
),
},
[
@34-39 Str(
PlainLine(
@ -85,12 +87,13 @@ Defs {
},
@45-49 SpaceBefore(
Apply(
@45-46 TaskAwaitBang(
Var {
@45-46 TrySuffix {
target: Task,
expr: Var {
module_name: "",
ident: "c",
},
),
},
[
@48-49 Var {
module_name: "",

View file

@ -1,19 +1,21 @@
Apply(
@0-3 TaskAwaitBang(
Var {
@0-3 TrySuffix {
target: Task,
expr: Var {
module_name: "",
ident: "foo",
},
),
},
[
@9-17 ParensAround(
Apply(
@9-12 TaskAwaitBang(
Var {
@9-12 TrySuffix {
target: Task,
expr: Var {
module_name: "",
ident: "bar",
},
),
},
[
@14-17 Var {
module_name: "",

View file

@ -123,12 +123,13 @@ Full(
@126-128 Pizza,
),
],
@129-132 TaskAwaitBang(
Var {
@129-132 TrySuffix {
target: Task,
expr: Var {
module_name: "A",
ident: "x",
},
),
},
),
),
Stmt(
@ -144,12 +145,13 @@ Full(
),
],
@171-205 Apply(
@171-174 TaskAwaitBang(
Var {
@171-174 TrySuffix {
target: Task,
expr: Var {
module_name: "B",
ident: "y",
},
),
},
[
@185-205 SpaceBefore(
Record(

View file

@ -108,12 +108,13 @@ Full(
),
],
@167-202 Apply(
@167-178 TaskAwaitBang(
Var {
@167-178 TrySuffix {
target: Task,
expr: Var {
module_name: "Task",
ident: "mapErr",
},
),
},
[
@180-202 Tag(
"UnableToCheckJQVersion",

View file

@ -0,0 +1,13 @@
TrySuffix {
target: Result,
expr: TrySuffix {
target: Result,
expr: TrySuffix {
target: Result,
expr: Var {
module_name: "Stdout",
ident: "line",
},
},
},
}

View file

@ -0,0 +1 @@
Stdout.line???

View file

@ -0,0 +1,5 @@
main =
a? "Bar"
x = B.b? "Foo"
c? x

View file

@ -0,0 +1,119 @@
Defs {
tags: [
Index(2147483648),
],
regions: [
@0-49,
],
space_before: [
Slice(start = 0, length = 0),
],
space_after: [
Slice(start = 0, length = 1),
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@12-49 SpaceBefore(
Defs(
Defs {
tags: [
Index(2147483648),
Index(2147483649),
],
regions: [
@12-21,
@26-39,
],
space_before: [
Slice(start = 0, length = 0),
Slice(start = 0, length = 1),
],
space_after: [
Slice(start = 0, length = 0),
Slice(start = 1, length = 0),
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Stmt(
@12-21 Apply(
@12-13 TrySuffix {
target: Result,
expr: Var {
module_name: "",
ident: "a",
},
},
[
@16-21 Str(
PlainLine(
"Bar",
),
),
],
Space,
),
),
Body(
@26-27 Identifier {
ident: "x",
},
@29-39 Apply(
@29-32 TrySuffix {
target: Result,
expr: Var {
module_name: "B",
ident: "b",
},
},
[
@34-39 Str(
PlainLine(
"Foo",
),
),
],
Space,
),
),
],
},
@45-49 SpaceBefore(
Apply(
@45-46 TrySuffix {
target: Result,
expr: Var {
module_name: "",
ident: "c",
},
},
[
@48-49 Var {
module_name: "",
ident: "x",
},
],
Space,
),
[
Newline,
Newline,
],
),
),
[
Newline,
],
),
),
],
}

View file

@ -0,0 +1,5 @@
main =
a? "Bar"
x= B.b? "Foo"
c? x

View file

@ -0,0 +1 @@
foo? (bar? baz) (blah stuff)

View file

@ -0,0 +1,45 @@
Apply(
@0-3 TrySuffix {
target: Result,
expr: Var {
module_name: "",
ident: "foo",
},
},
[
@9-17 ParensAround(
Apply(
@9-12 TrySuffix {
target: Result,
expr: Var {
module_name: "",
ident: "bar",
},
},
[
@14-17 Var {
module_name: "",
ident: "baz",
},
],
Space,
),
),
@22-32 ParensAround(
Apply(
@22-26 Var {
module_name: "",
ident: "blah",
},
[
@27-32 Var {
module_name: "",
ident: "stuff",
},
],
Space,
),
),
],
Space,
)

View file

@ -0,0 +1 @@
foo? ( bar? baz) ( blah stuff)

View file

@ -0,0 +1,17 @@
app [main] {
cli: "../basic-cli/platform/main.roc",
}
import cli.Stdout
main =
# is this a valid statement?
"Foo" |> A.x?
# what about this?
"Bar"
|> B.y?
{ config: "config" }
C.z "Bar"

View file

@ -0,0 +1,213 @@
Full(
FullAst {
header: SpacesBefore {
before: [],
item: App(
AppHeader {
before_provides: [],
provides: [
@5-9 ExposedName(
"main",
),
],
before_packages: [],
packages: @11-55 Collection {
items: [
@15-52 SpaceBefore(
PackageEntry {
shorthand: "cli",
spaces_after_shorthand: [],
platform_marker: None,
package_name: @20-52 PackageName(
"../basic-cli/platform/main.roc",
),
},
[
Newline,
],
),
],
final_comments: [
Newline,
],
},
old_imports: None,
old_provides_to_new_package: None,
},
),
},
defs: Defs {
tags: [
Index(2147483648),
Index(2147483649),
],
regions: [
@57-74,
@76-220,
],
space_before: [
Slice(start = 0, length = 2),
Slice(start = 2, length = 2),
],
space_after: [
Slice(start = 2, length = 0),
Slice(start = 4, length = 2),
],
spaces: [
Newline,
Newline,
Newline,
Newline,
Newline,
Newline,
],
type_defs: [],
value_defs: [
ModuleImport(
ModuleImport {
before_name: [],
name: @64-74 ImportedModuleName {
package: Some(
"cli",
),
name: ModuleName(
"Stdout",
),
},
params: None,
alias: None,
exposed: None,
},
),
Body(
@76-80 Identifier {
ident: "main",
},
@120-220 SpaceBefore(
Defs(
Defs {
tags: [
Index(2147483648),
Index(2147483649),
],
regions: [
@120-133,
@162-205,
],
space_before: [
Slice(start = 0, length = 0),
Slice(start = 0, length = 3),
],
space_after: [
Slice(start = 0, length = 0),
Slice(start = 3, length = 0),
],
spaces: [
Newline,
Newline,
LineComment(
" what about this?",
),
],
type_defs: [],
value_defs: [
Stmt(
@120-133 BinOps(
[
(
@120-125 Str(
PlainLine(
"Foo",
),
),
@126-128 Pizza,
),
],
@129-132 TrySuffix {
target: Result,
expr: Var {
module_name: "A",
ident: "x",
},
},
),
),
Stmt(
@162-205 BinOps(
[
(
@162-167 Str(
PlainLine(
"Bar",
),
),
@168-170 Pizza,
),
],
@171-205 Apply(
@171-174 TrySuffix {
target: Result,
expr: Var {
module_name: "B",
ident: "y",
},
},
[
@185-205 SpaceBefore(
Record(
[
@187-203 RequiredValue(
@187-193 "config",
[],
@195-203 Str(
PlainLine(
"config",
),
),
),
],
),
[
Newline,
],
),
],
Space,
),
),
),
],
},
@211-220 SpaceBefore(
Apply(
@211-214 Var {
module_name: "C",
ident: "z",
},
[
@215-220 Str(
PlainLine(
"Bar",
),
),
],
Space,
),
[
Newline,
Newline,
],
),
),
[
Newline,
LineComment(
" is this a valid statement?",
),
],
),
),
],
},
},
)

View file

@ -0,0 +1,16 @@
app [main] {
cli: "../basic-cli/platform/main.roc",
}
import cli.Stdout
main =
# is this a valid statement?
"Foo" |> A.x?
# what about this?
"Bar" |> B.y?
{ config: "config" }
C.z "Bar"

View file

@ -0,0 +1,9 @@
app [main] {
cli: platform "",
}
main =
"jq --version"
|> Cmd.new
|> Cmd.status
|> Result.mapErr? UnableToCheckJQVersion

View file

@ -0,0 +1,134 @@
Full(
FullAst {
header: SpacesBefore {
before: [],
item: App(
AppHeader {
before_provides: [
Newline,
],
provides: [
@74-78 ExposedName(
"main",
),
],
before_packages: [
Newline,
],
packages: @6-44 Collection {
items: [
@30-37 SpaceBefore(
PackageEntry {
shorthand: "cli",
spaces_after_shorthand: [],
platform_marker: Some(
[],
),
package_name: @35-37 PackageName(
"",
),
},
[
Newline,
],
),
],
final_comments: [
Newline,
],
},
old_imports: None,
old_provides_to_new_package: None,
},
),
},
defs: Defs {
tags: [
Index(2147483648),
],
regions: [
@88-204,
],
space_before: [
Slice(start = 0, length = 2),
],
space_after: [
Slice(start = 2, length = 1),
],
spaces: [
Newline,
Newline,
Newline,
],
type_defs: [],
value_defs: [
Body(
@88-92 Identifier {
ident: "main",
},
@100-204 SpaceBefore(
BinOps(
[
(
@100-114 SpaceAfter(
Str(
PlainLine(
"jq --version",
),
),
[
Newline,
],
),
@123-125 Pizza,
),
(
@126-133 SpaceAfter(
Var {
module_name: "Cmd",
ident: "new",
},
[
Newline,
],
),
@142-144 Pizza,
),
(
@145-155 SpaceAfter(
Var {
module_name: "Cmd",
ident: "status",
},
[
Newline,
],
),
@164-166 Pizza,
),
],
@167-204 Apply(
@167-180 TrySuffix {
target: Result,
expr: Var {
module_name: "Result",
ident: "mapErr",
},
},
[
@182-204 Tag(
"UnableToCheckJQVersion",
),
],
Space,
),
),
[
Newline,
],
),
),
],
},
},
)

View file

@ -0,0 +1,12 @@
app ""
packages {
cli: "",
}
imports []
provides [main] to cli
main =
"jq --version"
|> Cmd.new
|> Cmd.status
|> Result.mapErr? UnableToCheckJQVersion

View file

@ -63,7 +63,7 @@ mod test_fmt {
match header::parse_header(&arena, State::new(src.as_bytes())) {
Ok((actual, state)) => {
use roc_parse::remove_spaces::RemoveSpaces;
use roc_parse::normalize::Normalize;
let mut buf = Buf::new_in(&arena);
@ -77,8 +77,8 @@ mod test_fmt {
);
});
let ast_normalized = actual.remove_spaces(&arena);
let reparsed_ast_normalized = reparsed_ast.remove_spaces(&arena);
let ast_normalized = actual.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,
@ -6328,6 +6328,83 @@ mod test_fmt {
);
}
#[test]
fn keep_explicit_blank_chars() {
expr_formats_same(indoc!(
r#"
x = "a\u(200a)b\u(200b)c\u(200c)d\u(feff)e"
x
"#
));
}
#[test]
fn make_blank_chars_explicit() {
expr_formats_to(
indoc!(
"
x = \"a\u{200A}b\u{200B}c\u{200C}d\u{FEFF}e\"
x
"
),
indoc!(
r#"
x = "a\u(200a)b\u(200b)c\u(200c)d\u(feff)e"
x
"#
),
);
}
#[test]
fn make_blank_chars_explicit_when_interpolating() {
expr_formats_to(
indoc!(
"
x = \"foo:\u{200B} $(bar).\"
x
"
),
indoc!(
r#"
x = "foo:\u(200b) $(bar)."
x
"#
),
);
}
#[test]
fn make_blank_chars_explicit_in_multiline_string() {
expr_formats_to(
indoc!(
"
x =
\"\"\"
foo:\u{200B} $(bar).
\"\"\"
x
"
),
indoc!(
r#"
x =
"""
foo:\u(200b) $(bar).
"""
x
"#
),
);
}
#[test]
fn preserve_multiline_string_trailing_whitespace() {
expr_formats_same(indoc!(
"x =\n \"\"\"\n foo\n bar \n baz\n \"\"\"\nx"
));
}
// this is a parse error atm
// #[test]
// fn multiline_apply() {

View file

@ -455,6 +455,8 @@ mod test_snapshots {
pass/record_func_type_decl.expr,
pass/record_type_with_function.expr,
pass/record_update.expr,
pass/record_updater_literal_apply.expr,
pass/record_updater_var_apply.expr,
pass/record_with_if.expr,
pass/requires_type.header,
pass/separate_defs.moduledefs,
@ -469,11 +471,16 @@ mod test_snapshots {
pass/string_without_escape.expr,
pass/sub_var_with_spaces.expr,
pass/sub_with_spaces.expr,
pass/suffixed.expr,
pass/suffixed_multiple_defs.moduledefs,
pass/suffixed_nested.expr,
pass/suffixed_one_def.full,
pass/suffixed_optional_last.full,
pass/suffixed_bang.expr,
pass/suffixed_bang_multiple_defs.moduledefs,
pass/suffixed_bang_nested.expr,
pass/suffixed_bang_one_def.full,
pass/suffixed_bang_optional_last.full,
pass/suffixed_question.expr,
pass/suffixed_question_multiple_defs.moduledefs,
pass/suffixed_question_nested.expr,
pass/suffixed_question_one_def.full,
pass/suffixed_question_optional_last.full,
pass/tag_pattern.expr,
pass/ten_times_eleven.expr,
pass/three_arg_closure.expr,