pawn-lang / compiler

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

singleton array as enum field #241

Open YashasSamaga opened 6 years ago

YashasSamaga commented 6 years ago
enum T{
  Float:pos[4],
  x[1]
}
main ()
{
    new a[T];
    a[x][0] = 5;
}
test.pwn(10) : warning 215: expression has no effect
test.pwn(10) : error 001: expected token: ";", but found "["
test.pwn(10) : error 029: invalid expression, assumed zero
test.pwn(10) : warning 215: expression has no effect
test.pwn(10) : error 001: expected token: ";", but found "]"
test.pwn(10) : fatal error 107: too many error messages on one line

These errors appear iff the array size of the x field is 1.

Are they correct?

Southclaws commented 6 years ago

Probably because x[1] in an enumerator field is just x because of how enumerators work.

So, that's effectively the same as:

new a;
a[0] = 5;