Closed inoas closed 1 year ago
The error is the same though:
Error in query file "highlights.scm"
Caused by:
Query error at 82:4. Invalid node type panic
The error is the same though:
Error in query file "highlights.scm" Caused by: Query error at 82:4. Invalid node type panic
Seems like I've fixed it.
I've tried to add let assert
but the tests fail on that. The panic stuff seems to be working.
So I have reverted the changes for let assert
and just did the ones for panic.
@J3RN could you triggrer the workflow?
npm run test
is green for me
Hey @inoas! 👋 Thanks for submitting this patch! 🎉
To answer your direct question: the reason why the tests were failing is that the grammar needed to be "generated" from the
grammar.js
file by runningnpm run generate
. This is totally non-obvious and (AFAIK) not documented anywhere 😓 I'm making a change now such that when you runnpm test
it'll runnpm run generate
first to alleviate this issue!I also flagged a handful of other tiny issues that we'll want to resolve before merging.
How do I emperically test?
❯ tree-sitter parse test/gleam/list_test.gleam No language found ❯ tree-sitter highlight test/gleam/list_test.gleam No language found for path "test/gleam/list_test.gleam"
I have got tree-sitter cloned
❯ which tree-sitter
/usr/local/bin/tree-sitter
I have this repo here cloned: ~/tree-sitters/tree-sitter-gleam
You can use npx tree-sitter parse path/to/file.gleam
to use the tree-sitter-cli version from the package.json
. ./scripts/integration_test.sh
will run the integration tests against the gleam stdlib and other gleam repositories. It looks like the integration tests fail until #48 and #49 are merged in since let assert
is used in the stdlib and use
with patterns is used in gleam-lang/otp
.
When updating this branch, don't worry about resolving the conflicts in src/parser.c
by hand. You can "resolve" the conflicts however you like—even just leaving the >>>>
etc in there—and generate correct contents src/parser.c
by running npm run generate
.
./scripts/integration_test.sh
I do not understand this:
❯ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
❯ ./scripts/integration_test.sh
Running parser against gleam-lang/stdlib
test/integration/gleam_lang_stdlib/src/gleam/string.gleam 1 ms (ERROR [859, 4] - [1025, 28])
test/integration/gleam_lang_stdlib/test/gleam/bool_test.gleam 1 ms (ERROR [159, 13] - [159, 14])
test/integration/gleam_lang_stdlib/test/gleam/iterator_test.gleam 1 ms (ERROR [0, 0] - [574, 0])
test/integration/gleam_lang_stdlib/test/gleam/list_test.gleam 14 ms (ERROR [848, 35] - [848, 41])
test/integration/gleam_lang_stdlib/test/gleam/queue_test.gleam 3 ms (ERROR [85, 2] - [172, 22])
test/integration/gleam_lang_stdlib/test/gleam/regex_test.gleam 0 ms (ERROR [5, 2] - [85, 67])
test/integration/gleam_lang_stdlib/test/gleam/string_test.gleam 3 ms (ERROR [415, 2] - [983, 50])
test/integration/gleam_lang_stdlib/test/gleam/uri_test.gleam 1 ms (ERROR [9, 2] - [554, 66])
Total parses: 45; successful parses: 37; failed parses: 8; success percentage: 82.22%
❯ git checkout add-panic
Switched to branch 'add-panic'
❯ ./scripts/integration_test.sh
Running parser against gleam-lang/stdlib
test/integration/gleam_lang_stdlib/src/gleam/string.gleam 2 ms (ERROR [859, 4] - [1025, 28])
test/integration/gleam_lang_stdlib/test/gleam/bool_test.gleam 1 ms (ERROR [159, 13] - [159, 14])
test/integration/gleam_lang_stdlib/test/gleam/iterator_test.gleam 1 ms (ERROR [0, 0] - [574, 0])
test/integration/gleam_lang_stdlib/test/gleam/list_test.gleam 13 ms (ERROR [848, 35] - [848, 41])
test/integration/gleam_lang_stdlib/test/gleam/queue_test.gleam 4 ms (ERROR [85, 2] - [172, 22])
test/integration/gleam_lang_stdlib/test/gleam/regex_test.gleam 0 ms (ERROR [5, 2] - [85, 67])
test/integration/gleam_lang_stdlib/test/gleam/string_test.gleam 3 ms (ERROR [415, 2] - [983, 50])
test/integration/gleam_lang_stdlib/test/gleam/uri_test.gleam 1 ms (ERROR [9, 2] - [554, 66])
Total parses: 45; successful parses: 37; failed parses: 8; success percentage: 82.22%
Why is it only at 82.22%? At first I thought my panic change reduced that number
ah ok, probably https://github.com/gleam-lang/tree-sitter-gleam/pull/48 was the source of the issue. With that rebased on main it is back at 100%.
Cool!
Sadly I don't know anything at all about treesitter:
Any hints?