roc-lang / roc

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

`roc dev someFile.roc` does not forward exit code of Roc program #6797

Closed Anton-4 closed 4 months ago

Anton-4 commented 5 months ago

Example:

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

import pf.Task
import pf.Stdout

main =

    when checkInput 1 |> Task.result! is
        Ok checkedValue ->
            Stdout.line! "Received input $(Num.toStr checkedValue)."

        Err badValue ->
            # exit code 1 to indicate failure
            Task.err (Exit 1 "Received bad input $(Num.toStr badValue).")

# mock Task
checkInput = \input ->
    if input == 0 then
        Task.ok input
    else
        Task.err input
❯ ./target/release/roc examples/helloWorld.roc 
Received bad input 1.

roc on  main [!] is 📦 v0.0.1 via 🦀 v1.76.0 via ❄  impure (nix-shell-env) 
❯ echo $?
0

roc on  main [!] is 📦 v0.0.1 via 🦀 v1.76.0 via ❄  impure (nix-shell-env) 
❯ ./examples/helloWorld 
Received bad input 1.

roc on  main [!] is 📦 v0.0.1 via 🦀 v1.76.0 via ❄  impure (nix-shell-env) 
❯ echo $?
1