ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.36k stars 2.8k forks source link

Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery #958

Closed alferpal closed 10 years ago

alferpal commented 10 years ago

I keep getting this stacktrace every time i try to complete ( add an app.get or something the likes of that ) a file with this code javascript ( nodejs ) :

user.methods.comparePassword = function(candidatePassword, cb) {
    bcrypt.compare(candidatePassword, this.password, function(err, isMatch) {
        if(err){ 
            return cb(err);
        }
        cb(null, isMatch);
    });
};

I've pointed that this code is what causes the error, putting the code into a separate file and trying to complete something, and I'm able to reproduce the error.

Using Arch Linux

gVim console Output:

Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
Traceback (most recent call last):
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
  File "<string>", line 1, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
  File "<string>", line 3, in GetCompletions
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
  File "/home/akai/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/omni_completion_request.py", line 31, in Start
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
    self._results = self._omni_completer.ComputeCandidates( self.request_data )
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
  File "/home/akai/.vim/bundle/YouCompleteMe/autoload/../python/ycm/completers/all/omni_completer.py", line 69, in ComputeCandidates
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
    request_data )
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
  File "/home/akai/.vim/bundle/YouCompleteMe/autoload/../python/ycm/completers/completer.py", line 173, in ComputeCandidates
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
    request_data[ 'query' ] )
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
  File "/home/akai/.vim/bundle/YouCompleteMe/autoload/../python/ycm/completers/completer.py", line 228, in FilterAndSortCandidates
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
    ToUtf8IfNeeded( query ) )
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Complete..<SNR>31_CompletionsForQuery:
line    1:
TypeError: string indices must be integers, not str  
Vim version:
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May  4 2014 07:23:59)
Included patches: 1-274
Compiled by Arch Linux
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz  -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl   -lacl -lattr -lgpm -ldl  -L/usr/lib -llua -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic   -lruby -lpthread -lgmp -ldl -lcrypt -lm  -L/usr/lib   

might be important, my vimrc:

" ~/.vimrc
" Alexandre Ferrando

" See: http://vimdoc.sourceforge.net/htmldoc/options.html for details

" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

""Vundle
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'Valloric/YouCompleteMe'

nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
let g:ycm_global_ycm_extra_conf = '/home/akai/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
map <F7> mzgg=G`z<CR>

set scrolloff=10
set cmdheight=2
set foldmethod=indent

:nnoremap <Leader>zz :let &scrolloff=999-&scrolloff<CR>

cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))

let g:ycm_server_use_vim_stdout = 1
let g:ycm_server_log_level = 'debug'

set nocompatible
set whichwrap=b,s,<,>,[,]

set guiheadroom=0
"colors

colorscheme vividchalk
set guiheadroom=0
set backupdir=~/.vim/backup,/tmp

set nobackup
set nowritebackup
set noswapfile

set tabstop=4       " Number of spaces that a <Tab> in the file counts for.

set shiftwidth=4    " Number of spaces to use for each step of (auto)indent.

set expandtab       " Use the appropriate number of spaces to insert a <Tab>.
" Spaces are used in indents with the '>' and '<' commands
" and when 'autoindent' is on. To insert a real tab when
" 'expandtab' is on, use CTRL-V <Tab>.

set smarttab        " When on, a <Tab> in front of a line inserts blanks
" according to 'shiftwidth'. 'tabstop' is used in other
" places. A <BS> will delete a 'shiftwidth' worth of space
" at the start of the line.

set showcmd         " Show (partial) command in status line.

set formatoptions=c,q,r,t " This is a sequence of letters which describes how
" automatic formatting is to be done.
"
" letter    meaning when present in 'formatoptions'
" ------    ---------------------------------------
" c         Auto-wrap comments using textwidth, inserting
"           the current comment leader automatically.
" q         Allow formatting of comments with "gq".
" r         Automatically insert the current comment leader
"           after hitting <Enter> in Insert mode. 
" t         Auto-wrap text using textwidth (does not apply
"           to comments)

set number          " Show line numbers.

set showmatch       " When a bracket is inserted, briefly jump to the matching
" one. The jump is only done if the match can be seen on the
" screen. The time to show the match can be set with
" 'matchtime'.

" Make backspace behave in a sane manner.
set backspace=indent,eol,start

set ignorecase      " Ignore case in search patterns.

set smartcase       " Override the 'ignorecase' option if the search pattern
" contains upper case characters.

set autoindent      " Copy indent from current line when starting a new line
" (typing <CR> in Insert mode or when using the "o" or "O"
" command).
set ruler  

set background=dark

set mouse=a

if has("autocmd")
    au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif

" Enable file type detection and do language-dependent indenting.
filetype plugin indent on

"Spell
set nospell

" C/C++ stuff
autocmd FileType c,cpp,cc,h,hpp set omnifunc=ccomplete#Complete

" " PKGBUILD stuff
autocmd FileType PKGBUILD set expandtab shiftwidth=2 softtabstop=4
"
" " sh stuff
autocmd FileType sh set expandtab shiftwidth=2 softtabstop=4

" Switch syntax highlighting on
syntax on
Valloric commented 10 years ago

The error appears to be caused by your omnifunc returning bad data. The output of :set omnifunc? should tell you what your JS omnifunc is.