tree-sitter-julia
tree-sitter-julia copied to clipboard
Add support to @nospecialize in function arguments
Hi!
First of all, thank you very much for adding support for Julia in tree-sitter!
I think the current version of the grammar does not support the macro @nospecialize in function arguments like:
function teste(
a,
(@nospecialize b),
c
)
return a, b, c
end
The grammar says that there is an error in this snippet, but it is a valid Julia code.
Yes, "open" macros in function parameters won't parse correctly (even if enclosed in parenthesis), but using function-like macros works OK:
function teste(
a,
@nospecialize(b),
c
)
return a, b, c
end
Hopefully this isn't very inconvenient.
The reason why only one of the two is allowed:
- The grammar makes some effort to distinguish formal parameters from arguments (for static tools like smart renaming, not because Julia does it).
- function-like macros are much easier to parse.
- Using function-like macros as parameters is overwhelmingly more common than using open macros.
Hi @savq !
I think the proposed work around is fine! Thank you very much!