odin-lang / Odin

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

`core:odin/parser` package doesn't support putting labels on `#reverse for in` loops #3715

Closed thetarnav closed 3 weeks ago

thetarnav commented 3 weeks ago

Doing label: #reverse for item in list will cause errors when using core:odin/parser.

Similar issue was raised for the compiler here: https://github.com/odin-lang/Odin/issues/3319 But only the compiler got fixed, not the core package.

CODE

list := []string{"a"}
label: #reverse for a in list {
    fmt.println(a)
}

pkg, ok := parser.collect_package(".")
if !ok do panic("Failed to collect package\n")

ok = parser.parse_package(pkg)
if !ok do panic("Failed to parse package\n")

OUTPUT

$ odin run .
a
/odin-bug/main.odin(9:13): expected ';', got for
/odin-bug/main.odin(13:16): expected 2 expressions on the right-hand side, got 1
/odin-bug/main.odin(18:1): expected a statement, got }

REPORT

    Odin:    dev-2024-06:7c529e990
    OS:      Ubuntu 22.04.4 LTS, Linux 6.5.0-35-generic
    CPU:     Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    RAM:     7631 MiB
    Backend: LLVM 17.0.6
gingerBill commented 3 weeks ago

Fixed in https://github.com/odin-lang/Odin/commit/1945218f6df814ea95233035d0b51585e2522b2e