Skip to content

Fix array initialization handling in stage3 and C codegen#24

Open
manux81 wants to merge 2 commits into
beremiz:defaultfrom
manux81:fix-array-initialization
Open

Fix array initialization handling in stage3 and C codegen#24
manux81 wants to merge 2 commits into
beremiz:defaultfrom
manux81:fix-array-initialization

Conversation

@manux81

@manux81 manux81 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

This PR fixes array initialization handling across semantic analysis and C code generation.

Before this change, some array initialization cases were not handled consistently in stage3, and invalid initializations could propagate to stage4 and end in an internal compiler error instead of a proper user-facing error.

Changes included:

add explicit stage3 handling for array initialization elements in fill, narrow, and error-reporting passes
propagate array element datatypes through nested and non-elementary initializers
make lvalue_check explicitly traverse structured and array variables
replace internal backend crashes in stage4 with a proper diagnostic when an array initialization exceeds the array size declared in its type
User-facing improvement:

invalid array initializations no longer fail with an internal compiler error in the tested path
stage4 now reports:
Array initialization exceeds the array size declared in its type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant