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

Packed array syntax #658

Open Y-Less opened 3 years ago

Y-Less commented 3 years ago

Issue description:

Minimal complete verifiable example (MCVE):

new arr[10 char] = !{5, 6, 7, 8, 9, ...};

Pretty obvious I think. Just allows declaring packed arrays, similar to packed strings.

Workspace Information:

Daniel-Cortez commented 3 years ago

If the number of specified elements is not a multiple of cell size (4), e.g.:

new arr[] = !{ 0, 1, 2 };

should we treat this as an error or rather silently fill the remaining positions with zeroes? (I'm pretty sure it should be the second option, as there's no similar requirement for the number of characters in packed strings, but asking just in case).

Also, we'll probably need a new diagnostic for situations when the specified value is out of representable range, e.g.:

new array[] = !{ 253, 254, 255, 256 }; // would compile as !{ 253, 254, 255, 0 }
Y-Less commented 3 years ago

I'd say fill it with 0s. That's already the way other arrays work when you don't specify everything:

new arr[10] = {1, 2};
stale[bot] commented 2 years ago

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