Skip to content

Commit

Permalink
bugfix: expr: make index rule non-atomic (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw authored Feb 3, 2025
1 parent ef08ccc commit a2f7a58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ of `zizmor`.

* Fixed a bug where `zizmor` would fail to parse composite actions with
inputs/outputs that are missing descriptions (#502)
* Expressions that contain indices with non-semantic whitespace are now parsed
correctly (#511)

## v1.3.0

Expand Down
2 changes: 1 addition & 1 deletion src/expr/expr.pest
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ null = { "null" }
context = ${ (function_call | identifier) ~ (("." ~ (identifier | star)) | index)* }
star = { "*" }
identifier = @{ (ASCII_ALPHA | "_" | "-") ~ (ASCII_ALPHANUMERIC | "_" | "-")* }
index = { ("[" ~ (or_expr | star) ~ "]") }
index = !{ ("[" ~ (or_expr | star) ~ "]") }

/// Function calls
function_call = !{ identifier ~ "(" ~ (or_expr ~ ("," ~ or_expr)*)? ~ ")" }
4 changes: 4 additions & 0 deletions src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ mod tests {
"foo()[0]",
"fromJson(steps.runs.outputs.data).workflow_runs[0].id",
multiline,
"'a' == 'b' && 'c' || 'd'",
"github.event['a']",
"github.event['a' == 'b']",
"github.event['a' == 'b' && 'c' || 'd']",
];

for case in cases {
Expand Down

0 comments on commit a2f7a58

Please sign in to comment.