odin-lang / Odin

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

core/math/linalg/general.odin does not compile with -vet #3826

Closed iciuperca closed 3 days ago

iciuperca commented 3 days ago

Context

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

Expected Behavior

Odin standard library should compile with -vet

Current Behavior

[work@ionut-work /mnt/data/projects/odin]$ odin build ./runtime_error.odin -file -vet /opt/odin/core/math/linalg/general.odin(6:8) Error: 'runtime' declared but not used import "base:runtime" ^

Failure Information (for bugs)

Git bisect show commit 88598c2c6483cdaa9d574d9883a65543d0d31676 as having introduced it. Looking at the commit it does add the import of base:runtime even though the code changes do not use runtime Other pre-existing parts of the code do use runtime so I'm not sure why the "not used" warning is happening.

Steps to Reproduce

Compile the following program

[work@ionut-work /mnt/data/projects/odin]$ cat ./runtime_error.odin package main

import "core:math/linalg"

import "core:fmt"

main :: proc() { fmt.println("PI: %v", linalg.PI) }

Feoramund commented 3 days ago

The not used warning is happening because the parts that use the code are in parametric polymorphic procedures which do not get evaluated unless they are used, so the compiler wouldn't know that the import is actually used, unless you called one of the procs.