Breush / odin-binding-generator

An Odin library to convert a C header file into an Odin binding file.
MIT License
42 stars 21 forks source link

Syntax Errors: 'else' unattached to an 'if' statement #15

Closed AlectronikForge closed 3 years ago

AlectronikForge commented 3 years ago

I tried to run the xcb example (Arch Linux, last release of odin) and got the following output:

/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-helpers.odin(53:13) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-helpers.odin(79:9) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/generator-clean.odin(29:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-evaluate.odin(131:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-helpers.odin(87:9) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-evaluate.odin(135:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/generator-clean.odin(34:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-helpers.odin(94:9) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-evaluate.odin(139:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-evaluate.odin(143:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-evaluate.odin(147:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-helpers.odin(121:9) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-helpers.odin(129:9) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/generator-helpers.odin(154:9) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-evaluate.odin(182:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-helpers.odin(175:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/generator-helpers.odin(181:9) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser-evaluate.odin(234:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/generator-helpers.odin(325:41) Syntax Error: Expected a comma, got a newline
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/generator-helpers.odin(374:41) Syntax Error: Expected a comma, got a newline
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser.odin(428:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser.odin(447:5) Syntax Error: 'else' unattached to an 'if' statement
/run/media/nix/BtrStorage/LinData/GitHub/2-Languages/Odin/odin-binding-generator/bindgen/c-parser.odin(713:5) Syntax Error: 'else' unattached to an 'if' statement`

Seems to me like it's a bug in the compiler but as it runs the test suite flawlessly I'm posting it here. Hopefully somebody could point me into the direction of how to resolve!

Breush commented 3 years ago

Hello, thanks for reporting!

Looks like a compiler error to me, indeed. I might try to fix it myself.

For tracability, here is the link to the odin-lang issue: https://github.com/odin-lang/Odin/issues/1115

A workaround should be to use an older version of the compiler until it is fixed.