odin-lang / Odin

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

odin doc -doc-format crashes when aliasing an imported struct #1706

Open kururen opened 2 years ago

kururen commented 2 years ago

Context

When creating an alias for an imported struct and running odin doc -doc-format (doesn't matter whether it's a directory or a single file) it crashes with the following message:

odin doc . -doc-format D:\a\Odin\Odin\src\docs_writer.cpp(263): Assertion Failure: file_index_found != nullptr

Expected Behavior

The odin-doc files are generated.

Current Behavior

Crashes the compiler

Steps to Reproduce

Minimal example:

package bug

import "core:container/queue"

Q :: queue.Queue(int)

main :: proc() {
}

Note that it also happens with non-polymorphic structs (e.g. anything from raylib, which is where I ran into the bug). For context, the odin installation is in C:\odin

I could reproduce the same behaviour on MacOS as well, with the same version 2022-04.

jrfondren commented 1 year ago

This might be the same bug, with fresh Odin on Linux:

package nocrash
MaybeLike :: union($T: typeid) { T }
ok :: proc() -> MaybeLike(int) { return 1 }
bad :: proc() -> Maybe(int) { return 1 }

The above does not crash.

The below does crash:

package crash
bad :: proc() -> Maybe(int) { return 1 }

Crash:

$ odin doc hello.odin -file -doc-format
src/docs_writer.cpp(263): Assertion Failure: `file_index_found != nullptr` 
Illegal instruction (core dumped)
mtarik34b commented 2 months ago

Still an issue, please open. Struct :: struct { texture: raylib.Texture2D } is another example that'll lead to the bug.