Skip to content

folding Effectful Path crashes at runtime #481

Description

@thebrandonlucas

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)
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions