Skip to content

[native] Two generated-Rust compile failures on the host backend: E0308 element write into a boxed array, E0382 on a shared module-scope loop counter #669

Description

@spacedevin

Two generated-Rust compile failures on --target native (host). Both are pre-existing on main; found while building repros for #663.

1. E0308 — writing a number into an array that lowered to Vec<Value>

let E: i32[] = []
let keep = null
let i: i32 = 0
while (i < 4) { E.push(i); i = i + 1 }
fn stash(arr) { keep = arr }
fn main() {
  stash(E)
  E[1] = 77
  console.log(keep[1])
}
main()
error[E0308]: mismatched types
   --> src/main.rs:319:86
319 | { let __i = (1_f64) as usize; let __v = 77_f64; (*E.borrow_mut())[__i] = __v; };
    |                                                 ----------------------   ^^^ expected `Value`, found `f64`

The array is boxed to Vec<Value> (it escapes via stash) but the element write still emits the f64 form. The two halves disagree about the representation.

2. E0382 — module-scope loop counter reported as moved

let C: i32[] = []
let D: i32[] = []
let E: i32[] = []
let F: i32[] = []
let keep = null
let i: i32 = 0
while (i < 4) { C.push(i); D.push(i); E.push(i); F.push(i); i = i + 1 }
fn stash(arr) { keep = arr }
fn main() { stash(E) }
main()
error[E0382]: use of moved value: `i`

Giving each fill loop its own counter avoids it, which is why this is easy to miss.

Impact

Both are hard compile errors — the program does not build — so they are loud rather than silent, unlike #668. But they reject valid tish, and the shapes are ordinary.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnativeNative (tish->Rust->cargo) backend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions