lezer-parser / html

An HTML parser for Lezer
MIT License
13 stars 10 forks source link

Nested parsing: TypeError: Cannot read property 'some' of undefined #1

Closed SomaticIT closed 1 year ago

SomaticIT commented 3 years ago

Hi,

Thank you for your work on this project.

I try to experiment building a lezer parser for a language similar to HTML.

When I run the tests, I get this error on mixed tests:

TypeError: Cannot read property 'some' of undefined
      at hasChild (file:///.../lezer-html/node_modules/lezer-tree/dist/tree.es.js:713:26)
      at TreeNode.nextChild (file:///.../lezer-html/node_modules/lezer-tree/dist/tree.es.js:381:61)
      at TreeCursor.enter (file:///.../lezer-html/node_modules/lezer-tree/dist/tree.es.js:563:42)
      at TreeCursor.firstChild (file:///.../lezer-html/node_modules/lezer-tree/dist/tree.es.js:573:32)
      at Tree.iterate (file:///.../lezer-html/node_modules/lezer-tree/dist/tree.es.js:261:23)
      at testTree (file:///.../lezer-html/node_modules/lezer-generator/dist/test.js:125:10)
      at run (file:///.../lezer-html/node_modules/lezer-generator/dist/test.js:190:17)
      at Context.<anonymous> (file:///.../lezer-html/test/test-html.js:26:22)
      at processImmediate (internal/timers.js:461:21)

I can replicate this error on lezer-html when testing mixed.txt using 0.13 deps. I use node 14.

Do you have the same issue?

Thanks

marijnh commented 3 years ago

The tests in the lezer-html repository run fine for me, also on a fresh checkout. Could you say a bit more about what you are doing?

poacher2k commented 1 year ago

I'm experiencing a similar issue, which occurs when attempting to write anything inside a script block. Not sure if they're related, but based on the stack trace it looks very similar:

"@codemirror/basic-setup": "^0.20.0",
"@codemirror/lang-html": "^6.4.2",
"@codemirror/state": "^6.2.0",
"@codemirror/theme-one-dark": "^6.1.0",
"@codemirror/view": "^6.9.0",

image

image

poacher2k commented 1 year ago

Maybe related to https://github.com/codemirror/dev/issues/1064 ?

marijnh commented 1 year ago

"@codemirror/basic-setup": "^0.20.0",

This package is deprecated. Use the package named "codemirror" instead.

poacher2k commented 1 year ago

"@codemirror/basic-setup": "^0.20.0",

This package is deprecated. Use the package named "codemirror" instead.

Yes, apologies. It's not used in the project (just forgot to remove the package) - I'm using the latest (^6.0.1) of codemirror.

marijnh commented 1 year ago

I can't seem to reproduce what you are describing.

poacher2k commented 1 year ago

Same, maybe this has something to do with react. Strange that it's almost the exact same error though.

poacher2k commented 1 year ago

It's very strange, can't seem to replicate it on CodeSandbox either, using the exact same packages I use locally.

https://codesandbox.io/p/sandbox/rodemirror-forked-vdgcvj?file=%2Fpages%2Findex.tsx&selection=%5B%7B%22endColumn%22%3A42%2C%22endLineNumber%22%3A10%2C%22startColumn%22%3A42%2C%22startLineNumber%22%3A10%7D%5D

Locally, I don't even get any syntax highlighting. No clue what's going on - sorry for bumping this issue!

image image
poacher2k commented 1 year ago

Solved by npm uninstalling all related packages and reinstalling them fresh. Thank you for your patience, hope you have a good weekend :)

image