Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fuzzer never generated array literals that use an ellipsis, so that syntax went untested; this PR teaches it to emit them.
AstGenerator::GenerateArraynever 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
Arraynode 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
RandomBooldraw toGenerateArray, 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 withbazel 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 commit442df1630= 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
1a5bbda45without this change failed withxls/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.