I’ve been troubleshooting an issue where inserting a right parenthesis in the editor causes an error:
ReferenceError: _i is not defined
Which tracing it was coming from here in the @lezer/lr package:
Seriously scratching my head over this, as when I created the same setup with the same package versions in code sandbox there was no error.
Just because I had run out of ideas, I tried changing the variable in the for loop from i to j and this resolved the issue. Because I can’t reproduce I’m not raising it as a bug on Github, but would be interested to hear if people have any thoughts on why this might be happening?
I’ve generated a patch for the change in our project, so it’s not a blocking issue for us, but of course I would ideally like to not have to rely on a patch.
Seeing how the variable is not called _i in the source (or in the bundled code in the package’s dist dir), I suspect some tool you’re running on this on your side might be transforming the code in a broken way.
Sounds like a likely culprit. Yes looking at the minified code, it seems to have been incorrectly minified, thanks for the guidance.
if (t.length > 8 || this.stack.length >= 120) {
for (var n, r = [], o = 0; o < t.length; o += 2)
(n = t[o + 1]) != this.state && this.p.parser.hasAction(n, e) && r.push(t[o], n);
if (this.stack.length < 120)
for (var a = function() {
var e = t[_i + 1];
r.some((function(t, n) {
return 1 & n && t == e
}
)) || r.push(t[_i], e)
}, i = 0; r.length < 8 && i < t.length; i += 2)
a();
t = r
}