Skip to content

Commit

Permalink
Node repetition operator's reference analysis bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliah-Lakhin committed May 25, 2023
1 parent 8a44e95 commit ef66348
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions work/crates/derive/src/node/regex/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use syn::{Error, Result};
use crate::{
node::{
builder::{kind::VariantKind, Builder},
regex::{operand::RegexOperand, Regex},
regex::{operand::RegexOperand, operator::RegexOperator, Regex},
},
utils::{debug_panic, PredictableCollection, Set, SetImpl},
};
Expand Down Expand Up @@ -141,7 +141,21 @@ impl CheckReferences for Regex {

Self::Operand(RegexOperand::Token { .. }) => Ok(Set::empty()),

Self::Unary { inner, .. } => inner.check_references(context, builder),
Self::Unary { operator, inner } => {
let inner = inner.check_references(context, builder)?;

match operator {
RegexOperator::ZeroOrMore {
separator: Some(separator),
} => Ok(separator.check_references(context, builder)?.merge(inner)),

RegexOperator::OneOrMore {
separator: Some(separator),
} => Ok(separator.check_references(context, builder)?.merge(inner)),

_ => Ok(inner),
}
}

Self::Binary { left, right, .. } => {
let left = left.check_references(context, builder)?;
Expand Down

0 comments on commit ef66348

Please sign in to comment.