Seen with aetherc from Aether 0.651.0 (Windows, ae3d).
A program with a local variable named floor:
on_start(state: ptr, e: *Engine) {
floor = loader.plane(2, 10.0)
core.model_set_position(floor, 0.0, 0.0, 0.0)
}
fails type checking with three errors that point at a different file altogether:
error[E0200]: cannot cast ptr to int with `as`: a value cast converts between a distinct type and its base, or between numeric types
--> examples/gltf_viewer.ae:127:18
--> examples/gltf_viewer.ae:128:18
--> examples/gltf_viewer.ae:129:18
examples/gltf_viewer.ae has nothing at those lines; the errors are in an imported module (ae3d.noise, which does floor(x) as int), where the builtin floor now resolves to the program's *Model variable. Editing the program does not move the line numbers, which is what makes it hard to find: I bisected the whole file before guessing the name.
Two asks:
- A local should not shadow a builtin across module boundaries -- the module's
floor(x) should stay libm's whatever a program names its variables -- or the compiler should refuse the shadowing with a message naming it.
- An error inside an imported module should name the module's file and line, not the main program with the module's line numbers.
Renaming the variable (ground) fixes it.
Seen with aetherc from Aether 0.651.0 (Windows, ae3d).
A program with a local variable named
floor:fails type checking with three errors that point at a different file altogether:
examples/gltf_viewer.aehas nothing at those lines; the errors are in an imported module (ae3d.noise, which doesfloor(x) as int), where the builtinfloornow resolves to the program's*Modelvariable. Editing the program does not move the line numbers, which is what makes it hard to find: I bisected the whole file before guessing the name.Two asks:
floor(x)should stay libm's whatever a program names its variables -- or the compiler should refuse the shadowing with a message naming it.Renaming the variable (
ground) fixes it.