Problem: Cannot have a line break before an object member access.
Solution: Check for "." in next line. (closes #11864)
// the next line then consume the line break.
p = eval_next_non_blank(*arg, evalarg, &getnext);
if (getnext
- && ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1]))
+ && ((*p == '.'
+ && ((rettv->v_type == VAR_DICT && eval_isdictc(p[1]))
+ || rettv->v_type == VAR_CLASS
+ || rettv->v_type == VAR_OBJECT))
|| (p[0] == '-' && p[1] == '>' && (p[2] == '{'
|| ASCII_ISALPHA(in_vim9script() ? *skipwhite(p + 2)
: p[2])))))
var c = MyCar.new("def")
END
v9.CheckScriptFailure(lines, 'E1041:')
+
+ lines =<< trim END
+ vim9script
+
+ class Foo
+ this.x: list<number> = []
+
+ def Add(n: number): any
+ this.x->add(n)
+ return this
+ enddef
+ endclass
+
+ echo Foo.new().Add(1).Add(2).x
+ echo Foo.new().Add(1).Add(2)
+ .x
+ echo Foo.new().Add(1)
+ .Add(2).x
+ echo Foo.new()
+ .Add(1).Add(2).x
+ echo Foo.new()
+ .Add(1)
+ .Add(2)
+ .x
+ END
+ v9.CheckScriptSuccess(lines)
enddef
def Test_class_object_compare()
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1239,
/**/
1238,
/**/