pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
301 stars 71 forks source link

Copying from enum array generates incorrect code #687

Open IS4Code opened 2 years ago

IS4Code commented 2 years ago

Issue description:

When an enum contains an array (including but not limited to another enum), copying from this array to either a normal array or an array inside another enum results in incorrect code.

Assigning from an array to an array inside an enum seems to be the only thing that works.

Minimal complete verifiable example:

#include <a_samp>

enum E
{
    E1[32]
}

public OnFilterScriptInit()
{
    new e1[E], e2[E];
    new a[32];

    a = e1[E1];
    e2[E1] = e1[E1];
}

The assignment to a also produces a warning:

warning 229: index tag mismatch (symbol "e1"): expected tag none ("_"), but found "E"

The last two lines produce this assembly code:

    ; line d
    break   ; 6c
    addr.pri fffffe80
    push.pri
    addr.pri ffffff80
    load.i
    pop.alt
    movs 80
    ;$exp
    ; line e
    break   ; 94
    addr.pri ffffff00
    push.pri
    addr.pri ffffff80
    load.i
    pop.alt
    stor.i

In the first case, movs is correctly generated, but it seems like the compiler treats e1 like a two-dimensional array and tries to find the offset in the non-existent header. In the second case, movs isn't even generated at all, and instead it seems just like reassigning cells.

Workspace Information:

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity.