8000 [fuzzer] Generate arrays with an ellipsis by MaxonT · Pull Request #5591 · google/xls · GitHub
[go: up one dir, main page]

Skip to content

[fuzzer] Generate arrays with an ellipsis - #5591

Open
MaxonT wants to merge 1 commit into
google:mainfrom
MaxonT:contrib/809-auto
Open

MaxonT wants to merge 1 commit into
google:mainfrom
MaxonT:contrib/809-auto

Conversation

@MaxonT
@MaxonT MaxonT commented Dec 1, 2026
Copy link
Copy Markdown

The fuzzer never generated array literals that use an ellipsis, so that syntax went untested; this PR teaches it to emit them.

AstGenerator::GenerateArray never produced an array with a trailing ellipsis ([x, y, ...]), so the fuzzer never exercised that syntax. Fixes #809.

With probability 1/4, the generator now ends the array with an ellipsis and sets the annotated length 1 to 3 members longer than the listed values. An array with an ellipsis needs its explicit type annotation, so the annotation is set on the Array node in that case. The total width check runs after the extra members are counted, so the aggregate width limit still applies.

Size: 63 lines added and 3 removed in two files. 45 of the added lines are the new test; the generator change is 18 added and 3 removed.

Compatibility: the change adds one RandomBool draw to GenerateArray, so the programs generated for a given seed change. No public API, type or default changes.

Tests: this PR head (rebased onto current main, 436442cbb) was tested on the fork's GitHub Actions with bazel test --config=ci -c opt --test_output=errors -- //xls/fuzzer:ast_generator_test. Result: PASSED in 11.0s, Executed 1 out of 1 test: 1 test passes. Run: https://github.com/MaxonT/xls/actions/runs/46695707390 (fork commit 442df1630 = this head plus a CI-only workflow file that is not part of this PR; the fuzzer source is identical to this PR head). This is fork CI, not the upstream CI.

Before the fix: the same test file run on base 1a5bbda45 without this change failed with xls/fuzzer/ast_generator_test.cc:194: Failure, Value of: found_ellipsis, Expected: true (fork run 46656295201). So the test fails without the change and passes with it.

Not verified: I did not build or run the test locally. I did not run the fuzzer end to end, so the interpreter and IR-conversion results on generated ellipsis arrays are not tested here; the new test checks that generated programs parse and typecheck.

AstGenerator::GenerateArray never produced an array with a trailing
ellipsis (`[x, y, ...]`), so the fuzzer never exercised that syntax.
Sometimes end the generated array with an ellipsis and an annotated
length longer than the listed members, and add a test that checks the
generated programs contain such an array literal (not only the
array_slice width argument, which already used an ellipsis) and still
parse and typecheck.

Fixes google#809

Signed-off-by: MaxonT <173550318+MaxonT@users.noreply.github.com>
Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Add array with ellipsis in fuzzer

1 participant

0