Commit 5d8a332
fix: remove double parenthesis as valid opening to arithmetic expasion (#311)
* chore: checkpoint with formatted tests
No changes for now, we only re-formatted tests to make it easier to diff
them when we actually do changes.
* feat: avoid spurious parsing of arithmetic expansion
* test: add test for parenthesis in quote
* chore: update known failures with master
Update the `script/known-failures.txt` document with the latest grammar
in `master`, to make it easier to check what our changes are impacting.
* refactor: move (( expression )) from test_command to compound_statement
With the introduced changes, some of the examples were failing with a
specific pattern, namely the files:
- `examples/wild-corpus/esoteric/lishp/evaluator.sh`
- `examples/wild-corpus/esoteric/lishp/test.sh`
- `examples/wild-corpus/esoteric/lishp/variables.map.sh`
- `examples/wild-corpus/esoteric/lishp/variables.sh`
When taking a closer look it was noted that the following program was
failing to parse:
```
(( size=1, max_index=10 )
```
After taking a closer look at bash's manual, it seems this should be
possible and it should be considered a compound command instead. As
such, this commit moves this pattern from `test_command` to
`compound_statement`, updating it so that we can have multiple
expressions separated by a comma.
Note that these changes will very very very likely break the existing
tests, as we recently updated some to expect `test_command`. However,
for the time being, I'm keeping those failures since I'd like to have
someone else take another look at the changes I'm introducing with this
commit to see if they make sense.
* refactor: revert changes to subscript
This commit reverts the changes that had been done to `subscript` in
order to fix failing examples for the following files:
- `examples/gentoo/dev-lang/mlton/mlton-20180207.ebuild`
- `examples/gentoo/eclass/cuda.eclass`
- `examples/wild-corpus/cloud/kubernetes/cluster/lib/logging.sh`
- `examples/wild-corpus/cloud/kubernetes/hack/update-godep-licenses.sh`
- `examples/wild-corpus/git/t/t9902-completion.sh`
- `examples/wild-corpus/shell/bashdb/test/unit/test-columns.sh`
- `examples/wild-corpus/shell/bashdb/lib/frame.sh`
- `examples/gentoo/dev-qt/qt-docs/qt-docs-6.10.0_p202510021201.ebuild`
- `examples/gentoo/dev-qt/qt-docs/qt-docs-6.9.3_p202509261208.ebuild`
- `examples/gentoo/eclass/linux-mod-r1.eclass`
Namely, with the introduced changes, the following program could not be parsed:
```
echo "${array[${index}+1]}"
```
Even though I've confirmed this is valid bash syntax and, if the
variables were set, this would actually be evaluated to the value in
that specific index of the array.
Once again, not touching tests right now as I want someone to
double-check that my changes make sense.
* test: commit updated good tests
Add the updated tests for both `test/corpus/literals.txt` and
`test/corpus/statements.txt`, while leaving the failure in
`test/corpus/commands.txt`, as the two first simply updated the
`test_command` node to `compound_statement`, which is expected.
The latter broke the binary expression in a parenthesized expression in
a subscript, which is simply returning word instead of actually parsing
the binary or unary expression, still need to figure that out.
* refactor: replace parenthesized_expression for compound_statement
Replace `parenthesized_expression` for `compound_statement` in
`subscript`, as that fixes the issue with patterns like
`${array[(($number+1))]}` where `(($number+1))` was being parsed as a
`(parenthesized_expression(word))`.
This removes even more known failures, while introducing a new single
on, which needs to be looked into.
* fix: add subshell to possible options in subscript
Not sure if we should add `subshell` but, since the last commit removed
`parenthesized_expression`, we now need another one to allow `( ... )`
in subscript.
* refactor: remove unnecessary optional
Co-authored-by: Max Brunsfeld <[email protected]>
* ci: disable node tests
Co-authored-by: Max Brunsfeld <[email protected]>
---------
Co-authored-by: Max Brunsfeld <[email protected]>1 parent 20f55fb commit 5d8a332
File tree
10 files changed
+196799
-205052
lines changed- .github/workflows
- script
- src
- test/corpus
10 files changed
+196799
-205052
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
393 | 405 | | |
394 | 406 | | |
395 | 407 | | |
| |||
435 | 447 | | |
436 | 448 | | |
437 | 449 | | |
438 | | - | |
439 | 450 | | |
440 | 451 | | |
441 | 452 | | |
| |||
508 | 519 | | |
509 | 520 | | |
510 | 521 | | |
511 | | - | |
| 522 | + | |
512 | 523 | | |
513 | 524 | | |
514 | 525 | | |
| |||
701 | 712 | | |
702 | 713 | | |
703 | 714 | | |
704 | | - | |
| 715 | + | |
705 | 716 | | |
706 | 717 | | |
707 | 718 | | |
| |||
731 | 742 | | |
732 | 743 | | |
733 | 744 | | |
| 745 | + | |
734 | 746 | | |
735 | 747 | | |
736 | 748 | | |
| |||
1108 | 1120 | | |
1109 | 1121 | | |
1110 | 1122 | | |
1111 | | - | |
| 1123 | + | |
1112 | 1124 | | |
1113 | 1125 | | |
1114 | 1126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
| |||
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
82 | | - | |
83 | | - | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
| |||
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
100 | | - | |
101 | | - | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| |||
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | 286 | | |
284 | 287 | | |
285 | 288 | | |
286 | 289 | | |
287 | 290 | | |
288 | 291 | | |
289 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
290 | 297 | | |
291 | 298 | | |
292 | 299 | | |
| |||
353 | 360 | | |
354 | 361 | | |
355 | 362 | | |
356 | | - | |
357 | 363 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments