odin-lang / Odin

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

Incorrect hexadecimal literal is an invalid token #3754

Closed Feoramund closed 2 days ago

Feoramund commented 2 weeks ago

Here's a minimal program to test. Note the space between the 0x and 1.

package silent

main :: proc() {
    a := 0x 1
}

And the error it reports (or would, if the issue that #3753 fixes wasn't stopping it):

/tmp/odin/silent.odin(4:7) Syntax Error: Failed to parse file: /tmp/odin/silent; invalid token found in file

    ^

I'm assuming "invalid token" hints at a deeper issue here, since the compiler fails to display what the token is. It does give me a line and column though, which was helpful. I ran into this issue with a file full of hex tables.

Kelimion commented 2 weeks ago

Better. I'm getting the error message now.

W:\Odin\bug>build
W:/Odin/bug/bug.odin(4:7) Syntax Error: Failed to parse file: W:/Odin/bug/bug; invalid token found in file

        ^
Error 1

Where build.bat

@echo off
odin run bug.odin -file -vet -strict-style
IF %ERRORLEVEL% NEQ 0 (
    echo Error %ERRORLEVEL%
)