File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -819,6 +819,8 @@ deref_function_name(
819
819
typval_T ref ;
820
820
char_u * name = * arg ;
821
821
int save_flags = 0 ;
822
+ int evaluate = evalarg != NULL
823
+ && (evalarg -> eval_flags & EVAL_EVALUATE );
822
824
823
825
ref .v_type = VAR_UNKNOWN ;
824
826
if (evalarg != NULL )
@@ -867,7 +869,7 @@ deref_function_name(
867
869
* tofree = name ;
868
870
}
869
871
}
870
- else
872
+ else if ( evaluate )
871
873
{
872
874
if (verbose )
873
875
semsg (_ (e_not_callable_type_str ), name );
Original file line number Diff line number Diff line change @@ -11657,4 +11657,46 @@ def Test_mapnew_with_instance_method()
11657
11657
v9.CheckSourceSuccess (lines )
11658
11658
enddef
11659
11659
11660
+ " Test for using an object method in a method call.
11661
+ def Test_use_object_method_in_a_method_call ()
11662
+ var lines = << trim END
11663
+ vim9script
11664
+
11665
+ class Foo
11666
+ def Cost (nums: list <number> ): number
11667
+ return nums[0 ] * nums[1 ]
11668
+ enddef
11669
+
11670
+ def ShowCost (): string
11671
+ var g = [4 , 5 ]
11672
+ return $ " Cost is: {g->this.Cost()}"
11673
+ enddef
11674
+ endclass
11675
+
11676
+ var d = Foo.new ()
11677
+ assert_equal (' Cost is: 20' , d .ShowCost ())
11678
+ END
11679
+ v9.CheckSourceSuccess (lines )
11680
+
11681
+ # Test for using a non- existing object method in string interpolation
11682
+ lines = << trim END
11683
+ vim9script
11684
+
11685
+ class Foo
11686
+ def Cost (nums: list <number> ): number
11687
+ return nums[0 ] * nums[1 ]
11688
+ enddef
11689
+
11690
+ def ShowCost (): string
11691
+ var g = [4 , 5 ]
11692
+ echo $ " Cost is: {g->this.NewCost()}"
11693
+ enddef
11694
+ endclass
11695
+
11696
+ var d = Foo.new ()
11697
+ d .ShowCost ()
11698
+ END
11699
+ v9.CheckSourceFailure (lines , ' E1326: Variable "NewCost" not found in object "Foo"' )
11700
+ enddef
11701
+
11660
11702
" vim: ts = 8 sw = 2 sts = 2 expandtab tw = 80 fdm = marker
Original file line number Diff line number Diff line change @@ -704,6 +704,8 @@ static char *(features[]) =
704
704
705
705
static int included_patches [] =
706
706
{ /* Add new patch number below this line */
707
+ /**/
708
+ 975 ,
707
709
/**/
708
710
974 ,
709
711
/**/
You can’t perform that action at this time.
0 commit comments