-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use *file* identifier: produces a tree-sitter error #89
Comments
Good catch. Thanks! |
After testing a bit more I think the issue is not actually in the final argument of the use. The actual issue compes from using a pipeline to get the module name. For example |
This seems like invalid syntax |
The syntax definitely works. The whole point of that syntaxs is to be able to use pipes to provide the module name. |
In theory it should be valid, I think we added subexpressions to const eval. Might be a bug. |
After looking through the grammar.js, I think this could be a potential fix. On line 121 it is originally: field("module", choice($.val_string, $.unquoted)), instead this can be used: field("module", choice($.val_string, $.expr_parenthesized, $.unquoted)), From what I saw looking through the grammar expr_parenthesized is used exactly for this type of expression. I tested this via the treesitter cli (both by running test & also by parsing individual files) and it seems to have fixed the issue. If someone want to give this change a try with their collection of nushell files to see if this creates any ERRORs or incorrect highlighting, give it a go. |
The module field can be any expression that can be evaluated at parse time, I think the only relevant missing is string interpolation, e.g., |
I don't think treesitter can test for expressions that could be evaluated at parse time, but string interpolation can be added in. I will add this to the PR: #90 |
Using the pattern
use file identifier
produces a TS error. This happens when the identifier is not put in a list ex:use file [identifier
- this produces no error. Also happens when * is used instead of an identifier.Picture (look at the highlighting of the use - on the line before the incorrectly highlighted use there is an TS error, which can be seen via the TSPlayground):
![image](https://private-user-images.githubusercontent.com/1347244/333213828-32d83105-a658-416e-92eb-b5f5da1edbd5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1Njk3NTksIm5iZiI6MTcyMDU2OTQ1OSwicGF0aCI6Ii8xMzQ3MjQ0LzMzMzIxMzgyOC0zMmQ4MzEwNS1hNjU4LTQxNmUtOTJlYi1iNWY1ZGExZWRiZDUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDlUMjM1NzM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NGIzZDVlNzg1OTg2MTJjOWFmNzczZTUzMjJhYTdjZTEzZjQ2OGY3OGNhODYzNjJiNTllZGZjMzg1OTA4NjgyZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.QBawD3GqR3YM0kWf4Gb18acuRg98UgaRpOlAK2yZoyA)
The text was updated successfully, but these errors were encountered: