v0.13.7
errors and warnings / names

errors and warnings / names / W1036

W1036 warning

A module of an import cycle reads an export (or, with import internal, a file-level local) of a module of the cycle checked after it that has no type annotation (or a typeof type alias it has not reached): it is any there

area
names (x1xxx)
fails the build
with --deny-warnings

Two modules import each other (a cycle that only runs later, which is allowed), and the one checked first reads an export of the other that has no type annotation. The modules of a cycle are checked in source order, so that export's type isn't known yet and reads as any there: mistakes in its use go unnoticed. Annotate the export in its module (export local items: string[] = {}). The same applies to a typeof type alias of the later module, and to file-level locals read through import internal in tests.

Example

× failssrc/main.wowluawowlua
import items from "./other"export function show()    print(#items)end
src/other.wowluawowlua
import show from "./main"export local items = {}export function add(name: string)    table.insert(items, name)    show()end
✓ compilessrc/main.wowluawowlua
import items from "./other"export function show()    print(#items)end
src/other.wowluawowlua
import show from "./main"export local items: string[] = {}export function add(name: string)    table.insert(items, name)    show()end

The compiler reports it like this:

warning[W1036]: `items` is `any` here: `other` is checked after this module in their import cycle, and its export `items` has no type annotation
  ┌─ src/main.wowlua:1:8
  │
1 │ import items from "./other"
  │        ^^^^^ read as `any`
  │
  = help: annotate it where `other` exports it (`export local items: T = …`)
codemessage
E1014Import or usage cycle containing a load-time edge (run-time-only cycles are allowed)

Offline

terminal
$ wowlua explain W1036
W1036 (warning): A module of an import cycle reads an export (or, with import internal, a file-level local) of a module of the cycle checked after it that has no type annotation (or a typeof type alias it has not reached): it is any there

source on GitHub ↗