Skip to content

Syntax: accept ranges in designated array initializers#468

Closed
chqrlie wants to merge 1 commit intoc2lang:masterfrom
chqrlie:range-init
Closed

Syntax: accept ranges in designated array initializers#468
chqrlie wants to merge 1 commit intoc2lang:masterfrom
chqrlie:range-init

Conversation

@chqrlie
Copy link
Copy Markdown
Contributor

@chqrlie chqrlie commented Mar 21, 2026

  • boudaries may be omitted: lower bound defaults to current index higher bound default to array length minus one and must be specified if array length is omitted.
  • C generator assumes this feature is supported by the C compiler
  • Note that bouldaries must be specified for gcc and clang
  • This extension will be part of the next C2y standard.
  • add tests

@bvdberg
Copy link
Copy Markdown
Member

bvdberg commented Mar 24, 2026

I can think of many more unit tests, now there are only very few tests. like array[4] tests:
[2 ... 3] -> ok
[2 ... 4]
[2 ... 6]
[3 ... 4]
[4 ... 6]
[5 ... 6]

maybe some with only a left/right limit, that is not the last one etc

@bvdberg bvdberg closed this Mar 24, 2026
@bvdberg
Copy link
Copy Markdown
Member

bvdberg commented Mar 24, 2026

I can think of many more unit tests, now there are only very few tests. like array[4] tests:
[2 ... 3] -> ok
[2 ... 4]
[2 ... 6]
[3 ... 4]
[4 ... 6]
[5 ... 6]

maybe some with only a left/right limit, that is not the last one etc

@bvdberg bvdberg reopened this Mar 24, 2026
@chqrlie chqrlie force-pushed the range-init branch 3 times, most recently from 5fdf2ff to e1cb0af Compare March 28, 2026 08:26
* boudaries may be omitted: lower bound defaults to current index
  higher bound default to array length minus one and must be specified
  if array length is omitted.
* C generator assumes this feature is supported by the C compiler
  - boundaries must be specified for gcc and clang)
  - this extension will be part of the next C2y standard.
* refine error messages for duplicate cases and range overlaps
* add tests
@chqrlie chqrlie closed this Mar 29, 2026
@chqrlie chqrlie deleted the range-init branch March 29, 2026 22:10
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.

2 participants