Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed drop specialization for join point bodies #7556

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions crates/cli/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,21 @@ mod cli_tests {
#[test]
#[cfg_attr(windows, ignore)]
fn roc_check_markdown_docs() {
let cli_build = ExecCli::new(
let cli_check = ExecCli::new(
CMD_CHECK,
file_from_root("crates/cli/tests/markdown", "form.md"),
);

let expected_out =
"0 errors and 0 warnings found in <ignored for test> ms.\n\n0 errors and 0 warnings found in <ignored for test> ms.\n\n";

cli_build.run().assert_clean_stdout(expected_out);
cli_check.run().assert_clean_stdout(expected_out);
}

#[test]
#[cfg_attr(windows, ignore)]
fn import_in_expect() {
let cli_build = ExecCli::new(
let cli_test = ExecCli::new(
CMD_TEST,
file_from_root(
"crates/cli/tests/test-projects/module_params",
Expand All @@ -343,7 +343,23 @@ mod cli_tests {

let expected_out = "0 failed and 3 passed in <ignored for test> ms.\n";

cli_build.run().assert_clean_stdout(expected_out);
cli_test.run().assert_clean_stdout(expected_out);
}

#[test]
#[cfg_attr(windows, ignore)]
// https://github.com/roc-lang/roc/issues/7461
fn issue7461() {
let cli_test = ExecCli::new(
CMD_TEST,
file_from_root("crates/cli/tests/test-projects/", "issue7461.roc"),
);

let expected_out = "0 failed and 1 passed in <ignored for test> ms.\n";

cli_test
.run()
.assert_stdout_and_stderr_ends_with(expected_out);
}
}

Expand Down
65 changes: 65 additions & 0 deletions crates/cli/tests/test-projects/issue7461.roc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
module []

expect

_ =
when new_scatter { data : []} is
Ok asdf -> scatter_to_str asdf
Err _ -> crash ""

1 == 1


Trace x := {
data : List { x : x},
orientation : [Vertical],
name : Str,
marker : Marker,
}
implements [Inspect]

new_scatter :
{
data : List { x : x },
orientation ? [Vertical],
name ? Str,
}
-> Result (Trace x) _
new_scatter = \{ data, orientation ? Vertical, name ? ""} ->
Ok
(
@Trace {
data,
orientation,
name,
marker: new_marker? {},
}
)

# CHANING ANYHTING IN HERE SEEMS TO "FIX" IT
scatter_to_str : Trace x -> Str where x implements Inspect
scatter_to_str = \@Trace inner ->

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
data2 = List.walk inner.data ([]) \(xs), { x } -> (List.append xs x)

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
orientation_str = if inner.orientation == Vertical then "\"orientation\":\"v\"" else "\"orientation\":\"h\""

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
name_str = if Str.is_empty inner.name then "" else "\"name\":\"$(inner.name)\""

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
marker_str = marker_to_str inner.marker #"testtt"

""


Marker := {}
implements [Inspect]

new_marker : {} -> Result Marker _
new_marker = \{} -> Ok (@Marker {})

marker_to_str : Marker -> Str
marker_to_str = \_ -> ""
4 changes: 4 additions & 0 deletions crates/compiler/mono/src/drop_specialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@ fn specialize_drops_stmt<'a, 'i>(
// Meaning we can pass the incremented_symbols from the remainder to the body.
(Some(jump_info), None) if !jump_info.is_empty() => {
// Update body with incremented symbols from remainder
let mut body_environment = environment.clone();
for param in parameters.iter() {
body_environment.add_symbol_layout(param.symbol, param.layout);
}
body_environment.incremented_symbols = jump_info.clone();

let newer_body = specialize_drops_stmt(
Expand Down
Loading
Loading