Skip to content
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

Unresolved reference on slices declared as types #1846

Closed
vburenin opened this issue Sep 7, 2015 · 4 comments
Closed

Unresolved reference on slices declared as types #1846

vburenin opened this issue Sep 7, 2015 · 4 comments
Assignees
Milestone

Comments

@vburenin
Copy link

vburenin commented Sep 7, 2015

Hey folks. This is unresolved reference on slices, round two.
SomeId member highlighted as unresolved.

Originating bug has been fixed, however in that case object was created using NewDataSlice. This time I created a data structure in place: data := &DataSlice{} and as data := DataSlice{}

I am using 488 build of Go plugin.

type TestStruct struct {
    SomeId int
}

type DataSlice []*TestStruct

func NewDataSlice() *DataSlice {
    return &DataSlice{}
}

func ErrorCode() {
    data := DataSlice{}
    for _, element := range data {
        if element.SomeId > 20 {
            println("some text")
        }
    }
}

One more example:

type TestStruct struct {
    SomeId int
}

type DataSlice []*TestStruct

func NewDataSlice() *DataSlice {
    return &DataSlice{}
}

func ErrorCode() {
    data := DataSlice{}
    for _, element := range *data {
        if element.SomeId > 20 {
            println("some text")
        }
    }
}

image

@dlsniper dlsniper changed the title The unresolved reference on slices, round two. Unresolved reference on slices declared as types Sep 7, 2015
@dlsniper dlsniper added this to the 1.0 maybe? milestone Sep 7, 2015
@ignatov ignatov modified the milestones: 1.0.0, 1.0 maybe? Sep 8, 2015
@esiqveland
Copy link

Adding example for non pointer slice:

import (
    "testing"
    "fmt"
)

type Route struct {
    Name        string
}
type Routes []Route

func TestRoutesType(t *testing.T) {
    routes := Routes{
        Route{Name: "TestRoute"},
    }
    for _, route := range routes {
        fmt.Println(route.Name) // route.Name is marked as unresolved.
    }

}

@zolotov
Copy link
Contributor

zolotov commented Sep 29, 2015

@esiqveland is it reproducible for the last alpha (0.9.518)?

@vburenin
Copy link
Author

It still is. Pointer and non pointer examples are both reproducible.

@esiqveland
Copy link

@ignatov Yes, it is reproducible on 0.9.518 alpha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants