roc icon indicating copy to clipboard operation
roc copied to clipboard

division + List.map == segfault in repl

Open bburdette opened this issue 6 months ago • 1 comments

division fn ok, list.map ok, list.map of division not ok.

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

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

» (|a| a / 60) 50

0.833333333333333333 : Frac *
» List.map [10, 20, 30, 40, 50, 60] (|a| a + 60)

[70, 80, 90, 100, 110, 120] : List (Num *)
» List.map [10, 20, 30, 40, 50, 60] (|a| a / 60)
Segmentation fault (core dumped)

roc doesn't emit a version number for me ( "build from source") but here's my rev from flake.lock:

    "roc": {
      "inputs": {
        "flake-compat": "flake-compat",
        "flake-utils": "flake-utils",
        "nixpkgs": "nixpkgs_2",
        "rust-overlay": "rust-overlay"
      },
      "locked": {
        "lastModified": 1750527332,
        "narHash": "sha256-aZJUHf5uZ+tJ7ySw7p3vPqord2yjd+xN19546yZnu6M=",
        "owner": "roc-lang",
        "repo": "roc",
        "rev": "881642b850b7ed581c4179b784f5530b292159cc",
        "type": "github"
      },
      "original": {
        "owner": "roc-lang",
        "repo": "roc",
        "type": "github"
      }
    },

bburdette avatar Jun 22 '25 14:06 bburdette

Hi @bburdette,

This could be an issue with division with Dec in the repl and/or failure of the type unification. Current workaround is to force the F64 type:

❯ roc repl

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

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

» lst : List F64
… lst = [10, 20, 30, 40, 50, 60]

[10, 20, 30, 40, 50, 60] : List F64
» List.map lst (|a| a / 60)

[0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.8333333333333334, 1] : List F64
» 

With Dec for context:

temp on  main [?] took 1m34s 
❯ roc repl

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

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

» lst : List Dec
… lst = [10, 20, 30, 40, 50, 60]

[10, 20, 30, 40, 50, 60] : List Dec
» List.map lst (|a| a / 60)
Segmentation fault (core dumped)

We probably will not fix this issue in the old (current) compiler but I will leave this open to make sure this works in the repl of the new compiler.

Anton-4 avatar Jun 23 '25 14:06 Anton-4