Stream: bugs

Topic: Operator priority // vs %


view this post on Zulip Aurélien Geron (Jun 17 2026 at 12:15):

In the old roc 1 // 100 % 10 was equal to 0.
In the new roc it's equal to 1.
Is this intentional?

view this post on Zulip Anton (Jun 17 2026 at 12:42):

Hmm, in the new Roc repl it is 0 too

view this post on Zulip Anton (Jun 17 2026 at 12:44):

If I put it in a file I get 0.0 too, can you share your code?

view this post on Zulip Aurélien Geron (Jun 17 2026 at 19:59):

Oops, sorry about that, I copied the wrong expression. The one that changed is 1 % 10 // 100. Here's my code:

main! = |_args| {
    result1 = 1 % 10 // 100
    dbg result1
    result2 = (1 % 100) // 10
    dbg result2
    result3 = 1 // 100 % 10
    dbg result3
    result4 = (1 // 100) % 10
    dbg result4
    Ok({})
}

This outputs:

[dbg] 1.0
[dbg] 0.0
[dbg] 0.0
[dbg] 0.0

And here's the corresponding "Rust Roc" code:

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

main! = |_args|
    result1 = 1 % 100 // 10
    dbg result1
    result2 = (1 % 100) // 10
    dbg result2
    result3 = 1 // 100 % 10
    dbg result3
    result4 = (1 // 100) % 10
    dbg result4
    Ok({})

The output is:

[test36.roc:7] result1 = 0
[test36.roc:9] result2 = 0
[test36.roc:11] result3 = 0
[test36.roc:13] result4 = 0

view this post on Zulip Anton (Jun 19 2026 at 14:19):

Thanks @Aurélien Geron, I made #9712 for this.


Last updated: Jul 23 2026 at 13:15 UTC