Skip to content

Tagged arrays not being initialized correctly with ... syntax #10

@xunder-matth

Description

@xunder-matth

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  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions