Skip to content

Test has incorrect lowering #410

Open
@Mark1626

Description

@Mark1626

The test file-tests/should-lower/hoist.fuse fails typecheck as there is an out of bounds access let w = b[10 * 12];. However when --lower is present it seems to pass.

decl a: bit<32>[1];
decl b: bit<32>[1];

// Recusively hoist nested reads
let x = a[b[0]];
---

// Hoist binary expressions with reads
let y = 10 + a[0];

// Recusively hoist slow ops
let z = (x * 10) / (y * 20 - 15);

// Recursively hoist slow index expressions
let w = b[10 * 12];

// Complex chained binary expression
let k = (((0-1) * 1 + (2*2) * 2 - 1*1 - 1*2) as ubit<32>);

Error without --lower

[WARN] [5.11] bit<32> is used for an array access. This might be out of bounds at runtime.
let x = a[b[0]];
          ^

[Type error] [Line 15, Column 11] Index out of bounds for `b'. Memory size is 1, iterator max val is 120
let w = b[10 * 12];
          ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions