tree-sitter / tree-sitter-go

Go grammar for tree-sitter
MIT License
310 stars 65 forks source link

parse more complex interface type constraints #104

Closed aryx closed 1 year ago

aryx commented 1 year ago

Here is an example of code that should parse:

package Foo

type MyConstraint interface {
    []*MyStruct | []MyInterface
}
aryx commented 1 year ago

This currently works though:

package Foo

type MyConstraint interface {
    MyStruct | MyInterface
}
aryx commented 1 year ago

I think the interface_body tree-sitter rule need to be adjusted. See the spec here: https://go.dev/ref/spec#InterfaceType

aryx commented 1 year ago

Interface type has been simplified and generalized actually. The grammar should actually become smaller after fixing this bug.

TorchedSammy commented 1 year ago

this doesnt work either

package Foo

import "bar"

type MyConstraint interface {
    bar.MyStruct | bar.MyInterface
}