Repository navigation
feat: get supertype info - #3938
Conversation
0828734 to
bfe704c
Compare
|
@ribru17 I'll close this out until it's ready, no offense to you but the constant notification everytime you push is a little annoying 😅 |
|
You can unsubscribe, you know. Pushing to a closed PR breaks GitHub. |
|
(Marking as ready was me fat fingering on mobile. Will redraft when I get back home.) |
I would like to be subscribed, when it's ready. And how does it even break GH? Even if it does, that sounds like a GH issue. |
|
Yeah I think it is a really annoying GitHub issue, I'll re-mark as draft and stop pushes haha. (Though I think this is almost ready.) Sorry! |
|
Yes, it's a GH issue. But pushing to a closed PR prevents it from being opened again. |
|
Alright from my perspective it looks like this is pretty much done, but I am having some perplexing issues that look like some data offset weirdness (i.e. |
6af3709 to
f2f96e9
Compare
|
Note that the nvim-treesitter CI check here will inherently fail because this changes the |
Which means that nvim-treesitter will fail in the wild, too, so the check is valuable. (Note that the |
f2f96e9 to
ec586c0
Compare
ec586c0 to
f9b0912
Compare
|
@ObserverOfTime do you have any idea why the rust bindings have some (I am guessing) data offset issues mentioned in this #3938 (comment)? I ported these changes to Neovim locally and everything worked when just called from C directly |
|
Nope. |
ed45118 to
98fb139
Compare
|
Test failures due to out of date fixtures I believe. All failing tests use cached fixtures and all passing tests regenerated. Side question, is there a way to manually tell CI to regenerate fixtures or ignore cache for a workflow run? |
I think you're right, it looks the cache hit on your last force push because it only modified The fixtures cache is indexed by a hash of several files, but doesn't include that one: tree-sitter/.github/actions/cache/action.yml Lines 19 to 23 in 490f79b |
|
Ahh, thank you that makes sense. Yeah I had modified that as a mistake during some debugging... 😅 Seems like |
|
@ribru17 I cleaned up some of the code, though some notable changes are:
If this looks good to you we can get this in :) |
|
Looks good to me, thanks for the help! |
|
One last thing to note now that we have moved the function to return symbol IDs: say we have a supertype: supertype_sym: $ => choice (/* ...stuff */ alias($.symbol, $.unique_alias)),right now the map will return the symbol ID for both Imo an argument for returning strings was that with supertypes, most of their purpose relates to queries, and the notion of symbols is not as strong because of situations like this. But I also could just be unaware of a simple way to rectify this |
|
Yeah true, why not just keep the alias symbol? I think we'd just remove the extra logic for fetching the underlying symbol of an alias in |
|
If we do that, then for the rust rule Edit: keeping the current implementation would still give two symbols when aliasing a named node, which is undesirable Edit2: Actually, this makes me think there is a bug? There should exist a |
|
Ah right, aliasing a terminal is a little different than a non terminal (there's a slight optimization made here), so we can remove the fetching logic when getting the supertype map, and then, if there's no aliased symbol that exists in I just pushed some changes to account for this, I think this should be correct now. Sorry that this was kind of more difficult than I expected 😅 |
eeff8bc to
2bdd82e
Compare
|
Everything is working perfectly in my tests as well, thx again for the help 😄 |
8cc5a56 to
4323db7
Compare
Introduces a new function that takes in a supertype symbol and returns all associated subtypes. Can be used by query.c to give better errors for invalid subtypes, as well as downstream applications like the query LSP to give better diagnostics.
This makes sense because the files are moved to `src/tree_sitter` upon generation
|
cool, this is great to have - thanks @ribru17! |
I didn't update it to 0.25 because its Wasm support seems to be partially broken due to tree-sitter/tree-sitter#3938: it didn't introduce a check that the Wasm module's ABI is new enough to include supertype info while parsing it, and so in the case where it isn't it ends up interpreting random bytes as the number of supertypes, causing out-of-bounds memory accesses. Closes #24489 Release Notes: - Fixed a rare crash during syntax highlighting
|
@ribru17 @amaanq - Just a heads up that backwards-compatibility wasn't handled correctly in this PR, in the case of WASM. If Tree-sitter 0.25.1 tries to load a WASM-compiled language that was generated by an earlier version of Tree-sitter, a crash will occur when executing this line. I'm going to push up a fix shortly. |
|
Ack, sorry about that. Thanks for pushing a fix! |
|
No worries, it's a great PR anyway. I wish we had a better setup for checking backwards compatibility in tests. Right now, the tests all run against freshly-generated parsers, which makes sense for the most part. And I don't want to make the test suite super complicated. Maybe we just need one additional test that regenerates a trivial parser with each supported ABI, and tests that it can be loaded, both natively, and via WASM. |
I didn't update it to 0.25 because its Wasm support seems to be partially broken due to tree-sitter/tree-sitter#3938: it didn't introduce a check that the Wasm module's ABI is new enough to include supertype info while parsing it, and so in the case where it isn't it ends up interpreting random bytes as the number of supertypes, causing out-of-bounds memory accesses. Closes #24489 Release Notes: - Fixed a rare crash during syntax highlighting
Introduces a new function that takes in a supertype symbol and returns all associated subtypes. Can be used by query.c to give better errors for invalid subtypes, as well as downstream applications like the query LSP to give better diagnostics.
Fixes #2081