Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Using a binary literal will not compile

Open geefuoco opened this issue 2 years ago • 2 comments

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

    Odin: dev-2023-12:040b90c
    OS:   Ubuntu 20.04.6 LTS, Linux 5.15.90.4-microsoft-standard-WSL2
    CPU:  Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    RAM:  15975 MiB

Expected Behavior

Binary literal should work

Current Behavior

Marked as syntax error expected ';' token

Failure Information (for bugs)

hello_world.odin(7:13) Syntax Error: Expected ';', got integer

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Create simple file
//test.odin
package main

main :: proc() {
    x := 0b12
}

  1. Run file odin run .

Failure Logs

hello_world.odin(7:13) Syntax Error: Expected ';', got integer

geefuoco avatar Dec 08 '23 22:12 geefuoco

You can't have 2 in a binary literal; the error message should be improved, but it is a syntax error

xtactis avatar Dec 09 '23 06:12 xtactis

The compiler parses the string 0b12 as two tokens: 0b1 and 2 due to how integer parsing is set up. It should probably scan the whole string including letters and digits in other bases, and if contains them output the error after the token has been parsed with token location. This should improve the error behavior.

flysand7 avatar Dec 09 '23 06:12 flysand7