openmultiplayer / openmultiplayer/compiler
Tagged arrays not being initialized correctly with `...` syntax
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 22
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
Compiler version: Pawn compiler 3.10.11 downloaded from open.mp v1.4.0.2779 server build
When initializing an array using a tagged enum size with the ellipsis (...) syntax, the array is not being properly initialized. Specifically, elements after the first one are set to 0 instead of being repeated as expected.
MVCE:
enum e_TEST_ENUM {
TEST_ITEM_1,
TEST_ITEM_2,
TEST_ITEM_3,
TEST_ITEM_4
};
new NotWorking[e_TEST_ENUM] = { 5, ... };
const TEST_ENUM_SIZE = _:e_TEST_ENUM;
new Working[e_TEST_ENUM:TEST_ENUM_SIZE] = { 5, ... };
#assert sizeof NotWorking == sizeof Working
main() {
for(new i = 0; i != sizeof NotWorking; ++ i) {
printf("%d, %d", NotWorking[e_TEST_ENUM:i], Working[e_TEST_ENUM:i]);
}
}
Output:
5, 5
0, 5
0, 5
0, 5
Expected behavior:
5, 5
5, 5
5, 5
5, 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the MVCE with Pawn compiler 3.10.11 and compare the tagged enum-size initialization with the integer-size form. Trace the compiler's handling of { 5, ... } for both declarations; done when the tagged form repeats 5 for every element and matches the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100