Skip to content

OOM when type checking with array slices #4162

@mikex-oss

Description

@mikex-oss

Describe the bug
This is related to #4160 and #4161. I don't actually know what the root cause is.

If you write the following code:

pub fn array_rotl_fixed<K: u32, ELEMENT_SZ: u32, ARRAY_SZ: u32>
    (x: bits[ELEMENT_SZ][ARRAY_SZ]) -> bits[ELEMENT_SZ][ARRAY_SZ] {
    const K = K % ARRAY_SZ;
    const if K == 0 || K == ARRAY_SZ {
        x
    } else {
        let left = array_slice(x, u32:0, zero!<bits[ELEMENT_SZ][K]>());
        let right = array_slice(x, K, zero!<bits[ELEMENT_SZ][ARRAY_SZ - K]>());
        array_rev(array_rev(left) ++ array_rev(right))
    }
}

#[test]
fn array_rotl_fixed_test() {
    let x = u8[4]:[0, 1, 2, 3];
    assert_eq(array_rotl_fixed<1>(x), u8[4]:[1, 2, 3, 0]);
    assert_eq(array_rotl_fixed<2>(x), u8[4]:[2, 3, 0, 1]);
    assert_eq(array_rotl_fixed<4>(x), u8[4]:[0, 1, 2, 3]);
    assert_eq(array_rotl_fixed<5>(x), u8[4]:[1, 2, 3, 0]);
}

we get an OOM at 12G of memory executing ParseAndTypeCheckDSLXSourceFile command.

To Reproduce
See above.

Expected behavior
An error message for what is wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dslxDSLX (domain specific language) implementation / front-end

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions