comparison src/userfunc.c @ 33379:7c9124711f99 v9.0.1948

patch 9.0.1948: Vim9: object variable "this." should only be used in constructor Commit: https://github.com/vim/vim/commit/db38552dcdc7460459df8bf5cf02666256045308 Author: h-east <h.east.727@gmail.com> Date: Thu Sep 28 22:18:19 2023 +0200 patch 9.0.1948: Vim9: object variable "this." should only be used in constructor Problem: Vim9: object variable "this." should only be used in constructor Solution: Disallow to this in normal object methods (other than constructors) closes: #13152 closes: #13212 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: h-east <h.east.727@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Sep 2023 22:30:03 +0200
parents ce5257a49f56
children 4db948057fa6
comparison
equal deleted inserted replaced
33378:dd9da4eb6780 33379:7c9124711f99
317 p += 5; 317 p += 5;
318 arg = p; 318 arg = p;
319 while (ASCII_ISALNUM(*p) || *p == '_') 319 while (ASCII_ISALNUM(*p) || *p == '_')
320 ++p; 320 ++p;
321 char_u *argend = p; 321 char_u *argend = p;
322
323 // object variable this. can be used only in a constructor
324 if (STRNCMP(eap->arg, "new", 3) != 0)
325 {
326 c = *argend;
327 *argend = NUL;
328 semsg(_(e_cannot_use_an_object_variable_except_with_the_new_method_str), arg);
329 *argend = c;
330 break;
331 }
322 332
323 if (*skipwhite(p) == '=') 333 if (*skipwhite(p) == '=')
324 { 334 {
325 char_u *defval = skipwhite(skipwhite(p) + 1); 335 char_u *defval = skipwhite(skipwhite(p) + 1);
326 if (STRNCMP(defval, "v:none", 6) != 0) 336 if (STRNCMP(defval, "v:none", 6) != 0)