FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.

Home Page:https://fuellabs.github.io/sway

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type of the array index not type-checked in reassignment LHS

ironcev opened this issue · comments

The following script compiles without any errors. The array["test"] line will emit Internal compiler error: Attempt to load from non-copy type. but only if the poke(array) call is there. If that call is removed, even the array["test"] will not produce any error.

script;

fn main() {
    let mut array = [1, 2, 3];

    array[0] = 0;

    array[0u8] = 0;

    array[0u16] = 0;

    array[0u32] = 0;

    array[0u64] = 0;

    array[true] = 0;

    array[false] = 0;

    array[()] = 0;

    // array["test"] = 0;

    poke(array);
}

#[inline(never)]
fn poke<T>(_x: T) { }