Skip to content

Bug: Arithmetic expressions in a dim statement with arrays are not evaluated correctly #179

@Hevanafa

Description

@Hevanafa

When declaring an array with an arithmetic expression in its bounds, QBJS only reads the first variable / literal rather than evaluating the full expression

Minimal reproducible program

dim grid(32 \ 8, 64 \ 8) as integer
print str$(ubound(grid, 1)) + str$(ubound(grid, 2))

Expected output (matches QB64PE and VB6 behaviour):

 4 8

Actual output in QBJS:

 32 64

Workaround: Pre-evaluate the expression into a const before the dim statement

const rows = 32 \ 8
const cols = 64 \ 8
dim grid(rows, cols) as integer
print str$(ubound(grid, 1)) + str$(ubound(grid, 2))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions