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

tag mismatch when assigning the 2d variable directly. #694

Open Se8870 opened 2 years ago

Se8870 commented 2 years ago

Issue description:

Me, Cheaterman, and $Michael$ discussed about pawn and encountered the bug that should not happen when trying to assigning the enum tag for global 2d array, since it should work like doing it inside local.

Minimal complete verifiable example (MCVE):

// Declaring enum tag
enum EnumTag 
{
    E_ENUM_ONE = 1,
    E_ENUM_TWO
};

// Declaring another enum to be used for the array
enum MyData
{
    E_DATA_ONE = 1,
    EnumTag:E_DATA_TWO
};

// Declaring global 2d array
new array[2][MyData];

main()
{
   // Trying to add the values directly using local variable, then assigning it into the `array`.
    new myLocal[MyData] = { 1, E_ENUM_ONE };
    array[0] = myLocal;

    // Same as above, but directly assigning the array instead of creating the local variable.
    array[1] = {1, E_ENUM_TWO}; // tag mismatch: expected tag none ("_"), but found "EnumTag"

    // Expected output: 1, 1
    printf("Output: %d | %d", array[1][E_DATA_ONE], array[1][E_DATA_TWO]);

    // Expected output: 1, 2
    printf("Output: %d | %d", array[1][E_DATA_ONE], array[1][E_DATA_TWO]);
}

Workspace Information:

Cheaterman commented 2 years ago

array[1] = {1, E_ENUM_TWO}; Also worth noting this line will complain if you're tagging any of the values in the initialization list, saying "expected : but got mytag:" or something to that effect. From this, I'm guessing the compiler considers this rvalue a : array instead of using the lvalue tag?

EDIT: And TBF I'm wondering if this is really a bug or more of a feature request, but it sure would be nice to have. :-)

stale[bot] commented 2 years ago

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