clarity-pattern-parser 11.0.25 → 11.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3588,8 +3588,16 @@
3588
3588
  const aliasNode = statementNode.find(n => n.name === "alias-literal");
3589
3589
  const aliasName = aliasNode.value;
3590
3590
  const name = nameNode.value;
3591
- const alias = this._getPattern(aliasName).clone(name);
3592
- this._parseContext.patternsByName.set(name, alias);
3591
+ const aliasPattern = this._getPattern(aliasName);
3592
+ // This solves the problem for an alias pointing to a reference.
3593
+ if (aliasPattern.type === "reference") {
3594
+ const sequence = new Sequence(name, [aliasPattern]);
3595
+ this._parseContext.patternsByName.set(name, sequence);
3596
+ }
3597
+ else {
3598
+ const alias = aliasPattern.clone(name);
3599
+ this._parseContext.patternsByName.set(name, alias);
3600
+ }
3593
3601
  }
3594
3602
  static parse(expression, options) {
3595
3603
  const grammar = new Grammar(options);