roc-lang / roc-lang/basic-cli

`fold`ing Effectful `Path` crashes at runtime

Open
#481 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
121
Forks
45
Avg merge
18h 43m
Merged PRs (30d)
10

Description

This contrived code should check if a relative path is a directory. e.g. if I passed in ./repro ., there'd be no / and I'd just expect it to return Ok({}). Instead, it builds just fine but then crashes at runtime with: [ROC CRASHED] dispatch on a value that can never exist.

Full easy reproduction (AI genn'ed, but I tested) here

app [main!] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.22.0/F1JVZPYfWP71s8vk6tHcV1Qx1Ef6CZkwswGoCn8VHZmL.tar.zst",
}

import pf.OsStr
import pf.Path

require! = |root, relative| {
    path = relative.split_on("/").fold(root, Path.join)
    is_dir = Path.is_dir!(path)?
    if is_dir Ok({}) else Err(Missing(relative))
}

main! = |args|
    match args.drop_first(1).map(OsStr.display) {
        [text] => require!(Path.utf8(text), "")
        _ => Err(BadArgs)
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked BUG-006 reproduction with the Roc code shown in the issue, focusing on the effectful Path.join fold and the Path.is_dir! call. Trace the runtime dispatch that produces the crash. Done means the relative-path example completes without a runtime crash and returns the expected Ok({}) result.

Written by the indexing model from the issue text.

Assessment

Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.