clarity-pattern-parser 10.1.7 → 10.1.8

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.
package/dist/index.js CHANGED
@@ -846,16 +846,25 @@ class Reference {
846
846
  continue;
847
847
  }
848
848
  const foundPattern = pattern.getPatternWithinContext(this.name);
849
- if (foundPattern != null && foundPattern.type !== "reference") {
849
+ if (foundPattern != null && this._isValidPattern(foundPattern)) {
850
850
  return foundPattern;
851
851
  }
852
852
  pattern = pattern.parent;
853
853
  }
854
854
  const root = this._getRoot();
855
855
  return findPattern(root, (pattern) => {
856
- return pattern.name === this._name && pattern.type !== "reference";
856
+ return pattern.name === this._name && this._isValidPattern(pattern);
857
857
  });
858
858
  }
859
+ _isValidPattern(pattern) {
860
+ if (pattern.type === "reference") {
861
+ return false;
862
+ }
863
+ if (pattern.type === "context" && pattern.children[0].type === "reference") {
864
+ return false;
865
+ }
866
+ return true;
867
+ }
859
868
  _getRoot() {
860
869
  let node = this;
861
870
  while (true) {