@@ -896,28 +896,30 @@ fn vim_to_type(ret: &vimfuncs::FuncReturnType) -> Type {
896896 }
897897}
898898
899+ pub fn func_info_for_call ( c : & CallExpression ) -> Option < vimfuncs:: FuncInfo > {
900+ match c. name ( ) {
901+ Some ( ident) => {
902+ match ident {
903+ // TODO: Use our very cool new generated stuff here
904+ Identifier :: Raw ( raw) => {
905+ return vimfuncs:: get_func_info ( & raw . name) ;
906+ }
907+ _ => None ,
908+ }
909+ }
910+ _ => None ,
911+ }
912+ }
913+
899914fn guess_type_of_expr ( state : & State , expr : & Expression ) -> Type {
900915 match expr {
901916 Expression :: Number ( _) => Type :: Number ,
902917 Expression :: String ( _) => Type :: String ,
903918 Expression :: Boolean ( _) => Type :: Bool ,
904- Expression :: Call ( c) => {
905- match c. name ( ) {
906- Some ( ident) => {
907- match ident {
908- // TODO: Use our very cool new generated stuff here
909- Identifier :: Raw ( raw) => {
910- match vimfuncs:: get_func_info ( & raw . name) {
911- Some ( info) => vim_to_type ( & info. return_type ) ,
912- _ => Type :: Any ,
913- }
914- }
915- _ => Type :: Any ,
916- }
917- }
918- _ => Type :: Any ,
919- }
920- }
919+ Expression :: Call ( c) => match func_info_for_call ( & c) {
920+ Some ( info) => vim_to_type ( & info. return_type ) ,
921+ _ => Type :: Any ,
922+ } ,
921923 Expression :: Infix ( infix) => {
922924 if infix. operator . is_comparison ( ) {
923925 return Type :: Bool ;
@@ -936,7 +938,7 @@ fn guess_type_of_expr(state: &State, expr: &Expression) -> Type {
936938 && right_ty == Type :: Number
937939 && infix. operator . is_math ( )
938940 {
939- return dbg ! ( Type :: Number ) ;
941+ return Type :: Number ;
940942 }
941943
942944 Type :: Any
@@ -1580,6 +1582,10 @@ mod test {
15801582 busted ! ( busted_methods_1, "../testdata/busted/methods_1.vim" ) ;
15811583 busted ! ( busted_methods_2, "../testdata/busted/methods_2.vim" ) ;
15821584 busted ! ( busted_megamethods, "../testdata/busted/megamethods.vim" ) ;
1585+ busted ! (
1586+ busted_methods_shifted,
1587+ "../testdata/busted/methods_shifted.vim"
1588+ ) ;
15831589
15841590 snapshot ! ( test_expr, "../testdata/snapshots/expr.vim" ) ;
15851591 snapshot ! ( test_if, "../testdata/snapshots/if.vim" ) ;
0 commit comments