lezer-parser / highlight

Syntax highlighting from Lezer trees
MIT License
30 stars 9 forks source link

parent.set is not iterable #2

Closed zealot09 closed 1 year ago

zealot09 commented 1 year ago

macOS chrome 108.0.5359.98

maybe chrome upgrades and has special optimize for circular reference,below tag define will push itself into tag.set makes circular reference。

    /// Define a new tag. If `parent` is given, the tag is treated as a
    /// sub-tag of that parent, and
    /// [highlighters](#highlight.tagHighlighter) that don't mention
    /// this tag will try to fall back to the parent tag (or grandparent
    /// tag, etc).
    static define(parent) {
        if (parent === null || parent === void 0 ? void 0 : parent.base)
            throw new Error("Can not derive from a modified tag");
        let tag = new Tag([], null, []);
        tag.set.push(tag);
        if (parent)
            for (let t of parent.set)
                tag.set.push(t);
        return tag;
    }

while debugging in chrome,strange things happened

image

then next line, init name with Tag.define, it turns out with Object[object] , not an instance of Tag

image

and go on, jserror

marijnh commented 1 year ago

I can run @lezer/highlight without trouble in Chrome 108. Can you be a bit more specific about how to trigger the problem?

zealot09 commented 1 year ago

I can run @lezer/highlight without trouble in Chrome 108. Can you be a bit more specific about how to trigger the problem?

Did u try @lezer/highlight/dist/index.js ? I finally found it's my esbuild config packing with the dist/index.js file occured this problem, I just solve this by modify my esbuild config while requiring dist/index.cjs。

But I think problem still exists

marijnh commented 1 year ago

I can't see this happening except if Tag.define is called with an argument that's not a Tag, and the code in the package definitely doesn't do this. Going to close this until I have a working way to reproduce it.