Odin icon indicating copy to clipboard operation
Odin copied to clipboard

parser.parse_package_from_path crashes the program when folder contains an .odin file with missing package declaration

Open kleeon opened this issue 10 months ago • 0 comments

Context

λ odin version
odin version dev-2024-04:2207a0149

Steps to Reproduce

Can be reproduced with two files.

first.odin contains following text:

package main

import "core:odin/parser"

main :: proc() {
  parser.parse_package_from_path(".")
}

And second.odin, which is empty.

odin run . crashes the program on this line due to file.pkg_decl being a null pointer:

https://github.com/odin-lang/Odin/blob/8a6a3e883ce3e87070aef083f6233643e3fb0308/core/odin/parser/parse_files.odin#L73

Expected Behavior

Parser should give me an error.

kleeon avatar Apr 10 '24 01:04 kleeon