roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.46k stars 313 forks source link

repl tests fail without `--release` #6946

Open Anton-4 opened 3 months ago

Anton-4 commented 3 months ago
failures:
    tests::identity_lambda
    tests::issue_2300
    tests::issue_2582_specialize_result_value
    tests::sum_lambda

All fail apparently in the same way:

---- tests::identity_lambda stdout ----
thread 'tests::identity_lambda' panicked at crates/repl_test/src/cli.rs:96:13:
repl exited unexpectedly before finishing evaluation. Exit status was ExitStatus(unix_wait_status(25856)) and stderr was ""
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Anton-4 commented 3 months ago

Analysis from @smores56:

The issue seems to be coming from returning a value in the REPL that is a lambda/function. When I debug print running \x -> x in the REPL, I get this:

[smores@smoresbook:~/dev/roc]$ cargo run --bin roc -- repl
    Finished dev [unoptimized + debuginfo] target(s) in 0.23s
     Running `target/debug/roc repl`

  The rockin' roc repl
────────────────────────

Enter an expression, or :help, or :q to quit.

» \x -> x
[crates/compiler/gen_dev/src/generic64/mod.rs:1085:9] (dst, &fn_name, &args, &arg_layouts) = (
    `#UserApp.setjmp`,
    "roc_setjmp",
    [
        `#UserApp.buffer`,
    ],
    [
        InLayout(U64),
    ],
)
[crates/compiler/gen_dev/src/generic64/mod.rs:1085:9] (dst, &fn_name, &args, &arg_layouts) = (
    `#UserApp.result`,
    "#UserApp_replOutput_13093313482219921989",
    [],
    [
        InLayout(VOID),
    ],
)
thread 'main' panicked at crates/compiler/gen_dev/src/generic64/mod.rs:1086:9:
assertion `left == right` failed
  left: 0
 right: 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Which shows that the result we try to store our REPL output into has zero args, but a single arg layout InLayout(VOID)

The above issue is not the case for functions that are called, like (\x -> x) 123, or values, like 123