deoplete-plugins / deoplete-go

Asynchronous Go completion for Neovim. deoplete source for Go.
MIT License
424 stars 28 forks source link

gocode panicked #137

Closed osleg closed 6 years ago

osleg commented 6 years ago

With autocomplete on there are some (rare) cases where I get gocode panicked. Use :messages / see above for error details

Here a screen shot image

This happens in 2 cases:

  1. If the package referred is not imported yet like above, eg

    package main
    
    type A struct {
    sync.Mutex
    i int
    }
    
    func main() {
    a := A{}
    a.M   // Gocode panic occurs
    }
  2. When running vim/go under non unix GOOS, eg

    $ GOOS=windows vim

    And then this code

    package main
    
    import "sync"
    
    type A struct {
    sync.Mutex
    i int
    }
    
    func main() {
    a := A{}
    a.M   // Gocode panic occurs
    }
    
Shougo commented 6 years ago

I cannot reproduce the both problems with https://github.com/mdempsky/gocode. And it is not deoplete-go's issue.

osleg commented 6 years ago

I'm using the latest gocode from the same repository above. And I feel like it does deoplete issue since running gocode directly on the file does provide results: Without GOOS:

$ gocode -f json --in main.go autocomplete 96
[0,[{"class":"func","package":"","name":"main","type":"func()"},{"class":"package","package":"","name":"sync","type":""},{"class":"type","package":"","name":"A","type":"struct"},{"class":"var","package":"","name":"a","type":"A"}]]

With GOOS:

$ GOOS=windows gocode -f json --in main.go autocomplete 96
[1,[{"class":"type","package":"sync","name":"Map","type":"struct"},{"class":"type","package":"sync","name":"Mutex","type":"struct"}]]

Offset 96 is right after the . on line 12 a.M| where | is cursor position Hence gocode doesn't actually panicking when trying to parse the data whether with GOOS or without.

Shougo commented 6 years ago

If so, why I don't reproduce the problem? Please upload the minimal init.vim to reproduce it.

Shougo commented 6 years ago

And deoplete-go is open source project. You can research the problem.

osleg commented 6 years ago

Hm... I removed deoplete and then installed it again and it works :thinking: probably was something wrong with my install

osleg commented 6 years ago

@Shougo was about to do minimal vimrc but it started to work :man_shrugging:

Shougo commented 6 years ago

Oh... I see. I think gocode close is needed.