tree-sitter / tree-sitter-julia

Julia grammar for Tree-sitter
MIT License
93 stars 32 forks source link

Add support to @nospecialize in function arguments #88

Closed ronisbr closed 5 months ago

ronisbr commented 1 year ago

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.

savq commented 1 year ago

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:

ronisbr commented 1 year ago

Hi @savq !

I think the proposed work around is fine! Thank you very much!