DerekStride / tree-sitter-sql

SQL grammar for tree-sitter
http://derek.stride.host/tree-sitter-sql/
MIT License
155 stars 52 forks source link

Generated WASM file not working #268

Open Vokturz opened 3 months ago

Vokturz commented 3 months ago

Hi, I'm trying to use the generated wasm file with web-tree-sitter and the following error appears when trying to parse code:

RuntimeError: null function or function signature mismatch
    at tree-sitter.wasm:0x7960
    at tree-sitter.wasm:0x2a996
    at Parser.parse (web-tree-sitter.js?v=a1488891:676:29)

To make the wasm I'm doing:

  1. npm install --save-dev tree-sitter-cli @derekstride/tree-sitter-sql
  2. npx tree-sitter build --wasm node_modules/@derekstride/tree-sitter-sql

Did I skip any steps? I previously tried with tree-sitter-javascript and everything works perfectly.

matthias-Q commented 3 months ago

I cannot reproduce this. I did a fresh clone, using node 22 and I can build the wasm file without errors.

Building it with the rust cli also works.

matthias-Q commented 2 months ago

Can you check again. We had some releases in between, which might have solved this issue.

duhbbx commented 1 month ago

maybe function pointer convert problem

I build tree-sitter, tree-sitter-sql and rust bindings, one build arg is very is import which may involved with this.

-sEMULATE_FUNCTION_POINTER_CASTS=1
gregnis commented 3 weeks ago

Could be the same issue I'm having. I did the same thing I'd done for other grammars:

git clone https://github.com/DerekStride/tree-sitter-sql
cd tree-sitter-sql
..\tree-sitter generate
..\tree-sitter build
..\tree-sitter build --wasm
..\tree-sitter playground

The tree is not generating, What I get in Chrome dev. console is this:

playground.js:324 Uncaught TypeError: Cannot read properties of null (reading 'rootNode')
    at handleCursorMovement (playground.js:324:23)
    at later (playground.js:451:30)
handleCursorMovement @ playground.js:324
later @ playground.js:451
setTimeout
(anonymous) @ playground.js:455
(anonymous) @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
Gn @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
playground.js:324 Uncaught TypeError: Cannot read properties of null (reading 'rootNode')
    at handleCursorMovement (playground.js:324:23)
    at later (playground.js:451:30)
handleCursorMovement @ playground.js:324
later @ playground.js:451
setTimeout
(anonymous) @ playground.js:455
(anonymous) @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
Gn @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
playground.js:324 Uncaught TypeError: Cannot read properties of null (reading 'rootNode')
    at handleCursorMovement (playground.js:324:23)
    at later (playground.js:451:30)
handleCursorMovement @ playground.js:324
later @ playground.js:451
setTimeout
(anonymous) @ playground.js:455
(anonymous) @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
Gn @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
playground.js:371 resume_parsing
playground.js:371 process version:0, version_count:1, state:1, row:0, col:0
playground.js:371 reduce sym:program, child_count:0
playground.js:371 accept
playground.js:371 done
tree-sitter.wasm:0x7960 Uncaught (in promise) RuntimeError: null function or function signature mismatch
    at tree-sitter.wasm:0x7960
    at tree-sitter.wasm:0x2a996
    at Parser.parse (tree-sitter.js:1:49283)
    at handleCodeChange (playground.js:113:28)
    at it (codemirror.min.js:1:17760)
    at jn (codemirror.min.js:1:65062)
    at codemirror.min.js:1:61536
    at codemirror.min.js:1:61545
    at codemirror.min.js:1:61216
    at Gn (codemirror.min.js:1:61222)
$ts_parser_reset @ tree-sitter.wasm:0x7960
$ts_parser_parse_wasm @ tree-sitter.wasm:0x2a996
parse @ tree-sitter.js:1
handleCodeChange @ playground.js:113
it @ codemirror.min.js:1
jn @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
Gn @ codemirror.min.js:1
Xn @ codemirror.min.js:1
Vl.poll @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
playground.js:324 Uncaught TypeError: Cannot read properties of null (reading 'rootNode')
    at handleCursorMovement (playground.js:324:23)
    at later (playground.js:451:30)
handleCursorMovement @ playground.js:324
later @ playground.js:451
setTimeout
(anonymous) @ playground.js:455
(anonymous) @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
Gn @ codemirror.min.js:1
Xn @ codemirror.min.js:1
Vl.poll @ codemirror.min.js:1
(anonymous) @ codemirror.min.js:1
gregnis commented 3 weeks ago

BTW, I tried using -sEMULATE_FUNCTION_POINTER_CASTS=1, and it didn't help. In fact, it broke other grammars, so I reset it back.