mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-26 03:31:12 +08:00
fix: 同名捕获组回引与 groups 字段改末次已定义语义
This commit is contained in:
Vendored
+21
@@ -238,6 +238,27 @@ fn try_match_state<Input: InputIndexer, Dir: Direction>(
|
||||
nextinsn_or_fail!(matched)
|
||||
}
|
||||
|
||||
Insn::BackRefLastDefined(group_indices) => {
|
||||
// Scan the occurrences in reverse source order and match the text of
|
||||
// the last occurrence that is defined; a later occurrence overrides
|
||||
// an earlier one only when it matched.
|
||||
let mut matched = true;
|
||||
for &group_idx in group_indices.iter().rev() {
|
||||
let group = &s.groups[group_idx as usize];
|
||||
if let Some(orig_range) = group.as_range() {
|
||||
if re.flags.icase {
|
||||
matched = matchers::backref_icase(input, dir, orig_range, &mut s.pos);
|
||||
} else {
|
||||
matched = matchers::backref(input, dir, orig_range, &mut s.pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// No occurrence is defined, and therefore the match succeeds
|
||||
// (ES6 21.2.2.9).
|
||||
nextinsn_or_fail!(matched)
|
||||
}
|
||||
|
||||
&Insn::Lookahead {
|
||||
negate,
|
||||
start_group: _,
|
||||
|
||||
Reference in New Issue
Block a user