pawn-lang / compiler

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

Zero array size (need error 009) #668

Open kennytowN opened 3 years ago

kennytowN commented 3 years ago

new arr[0] = {132131}; printf("arr[0] = %d", arr[0]);

This code is fully functional, despite the zero size of the array, although there is an error 009 in the compiler that describes this case: "error 009: invalid array size (negative, zero or out of bounds)"

ghost commented 2 years ago

No, this is invalid. When declaring the array you either declare no array size (let the compiler decide this -- assuming you've an initial value). Otherwise you have to declare the size of the array. Array indexes start at 0. To have an array with just one index, you have to declare it with 1 cell.

new arr[1];

main()
{
    arr[0] = 132131;
}

The error you got already told that: error 009: invalid array size (negative, zero or out of bounds). Your code is not fully functional.

stale[bot] commented 2 years ago

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