odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
7.05k stars 633 forks source link

Imprecise error when attempting to use `#reverse #unroll` with a numeric range #4435

Open Barinzaya opened 1 month ago

Barinzaya commented 1 month ago

Context

Expected Behavior

When attempting to use #reverse #unroll on a loop with a numeric range, the specific error message for #reverse not being supported with ranges should be produced.

Error: #reverse for is not supported with ranges, prefer an explicit for loop with init, condition, and post arguments
        #reverse #unroll for i in 0..<10 { ...
                         ^~~~~~~~~~~~~~~~~ ...

Current Behavior

When attempting to use #reverse #unroll on a loop with a numeric range, the error message indicates that #reverse may only be used on a for in statement, despite apparently preceding one (albeit with an additional #unroll tag).

Syntax Error: #reverse can only be applied to a 'for in' statement
        #reverse #unroll for i in 0..<10 {
        ^

Steps to Reproduce

Attempt to build the following code:

package mre

import "core:fmt"

main :: proc() {
    #reverse #unroll for i in 0..<10 {
        fmt.println(i)
    }
}
gingerBill commented 1 month ago

#unroll is still kind of a placeholder feature that shouldn't really be used.

Barinzaya commented 1 month ago

Is there a permanent alternative planned, aside from hand-unrolling?