Skip to content

Commit

Permalink
fix(Source-to-Sink): handle empty token list in PPI find method
Browse files Browse the repository at this point in the history
- prevent runtime error when no tokens are found by using an empty array reference as a fallback
  • Loading branch information
scriptprivate authored Dec 16, 2024
1 parent ccf020a commit 57d02c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Zarn/Engine/Source_to_Sink.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package Zarn::Engine::Source_to_Sink {
);

if ($ast && $rules) {
foreach my $token (@{$ast -> find('PPI::Token')}) {
foreach my $token (@{$ast -> find('PPI::Token') || []}) {
foreach my $rule (@{$rules}) {
my @sample = $rule -> {sample} -> @*;
my $category = $rule -> {category};
Expand Down Expand Up @@ -63,4 +63,4 @@ package Zarn::Engine::Source_to_Sink {
}
}

1;
1;

0 comments on commit 57d02c5

Please sign in to comment.