You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parser fails to correctly parse a parapoly struct when the opening bracket is not in the same line as the struct declaration.
Instead of receiving a correct field list for the struct we get a Bad_Expr node.
Odin: dev-2022-11:382bd876
OS: Windows 10 Professional (version: 21H2), build 19044.2251
CPU: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
RAM: 32706 MiB
Expected Behavior
Brackets can be in different lines for compilation so the parser should also correctly parse this.
Current Behavior
Parser returns a Bad_Expr.
Failure Information (for bugs)
Step 1: write the following code into a file inside a directory of its own.
Step 2: run the code using odin run <filename.odin> -file -ignore-unknown-attributes
Step 3: see the location of the bad expression and how the first parapoly struct didn't have the same issue.
package main
import "core:odin/parser"
import "core:odin/ast"
import "core:fmt"
main :: proc()
{
p := parser.Parser{}
pkg, ok := parser.parse_package_from_path(".", &p)
if !ok
{
fmt.println("error")
return
}
ast.inspect(&pkg.node, inspect_func)
}
inspect_func :: proc(n : ^ast.Node) -> bool
{
if n == nil do return true
#partial switch d in n.derived {
case ^ast.Bad_Expr:
fmt.println(d)
}
return true
}
@meta
Parapoly_Ok :: struct($T : typeid) {
ok : int
}
@meta
Parapoly_Bad :: struct($T: typeid)
{
ok : int
}
Uh oh!
There was an error while loading. Please reload this page.
Context
The parser fails to correctly parse a parapoly struct when the opening bracket is not in the same line as the struct declaration.
Instead of receiving a correct field list for the struct we get a Bad_Expr node.
Expected Behavior
Brackets can be in different lines for compilation so the parser should also correctly parse this.
Current Behavior
Parser returns a Bad_Expr.
Failure Information (for bugs)
Step 1: write the following code into a file inside a directory of its own.
Step 2: run the code using
odin run <filename.odin> -file -ignore-unknown-attributes
Step 3: see the location of the bad expression and how the first parapoly struct didn't have the same issue.
The text was updated successfully, but these errors were encountered: