roc-lang / basic-cli

A basic Command-Line Interface platform
Universal Permissive License v1.0
88 stars 30 forks source link

Expr::TaskAwaitBang expression was not completely removed in desugar_value_def_suffixed #234

Open lukewilliamboswell opened 3 months ago

lukewilliamboswell commented 3 months ago
$ roc broken.roc
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
a Expr::TaskAwaitBang expression was not completely removed in desugar_value_def_suffixed
Location: crates/compiler/can/src/expr.rs:1130:41
app [main] {
    cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.13.0/nW9yMRtZuCYf1Oa9vbE5XoirMwzLbtoSgv7NGhUlqYA.tar.br",
}

import cli.Stdout
import cli.Arg
import cli.Task exposing [Task]

main =
    Arg.list! {}
    |> List.dropFirst 1
    |> List.mapTry Str.toU8Checked
    |> Task.fromResult!
    |> List.sum
    |> \total -> "Sum of numbers: $(Num.toStr total)"
    |> Stdout.line!
Lubsch commented 3 months ago

Can also replicate with e.g.

app [main] {
    cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br"
}

import cli.Stdout
import cli.Cmd
import cli.Task exposing [Task]

main =
    Cmd.new "ls"
        |> Cmd.output
        |> Task.onErr! \CmdOutputError _ -> Task.err (Exit 1 "")
        |> .stdout
        |> Str.fromUtf8
        |> Task.fromResult!
        |> Stdout.write!