]> granicus.if.org Git - vim/commitdiff
patch 9.0.1186: imported class does not work when used twice in a line v9.0.1186
authorBram Moolenaar <Bram@vim.org>
Thu, 12 Jan 2023 20:04:51 +0000 (20:04 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 12 Jan 2023 20:04:51 +0000 (20:04 +0000)
Problem:    Imported class does not work when used twice in a line.
Solution:   Fix the type parsing.

src/evalvars.c
src/testdir/test_vim9_class.vim
src/version.c

index e473e48763fac2ff4ff2e7de43190c962c7512be..8061a5096dac744d5f2dc935005b636dc094eef3 100644 (file)
@@ -3122,8 +3122,12 @@ eval_variable_import(
        return FAIL;
     if (rettv->v_type == VAR_ANY && *s == '.')
     {
+       char_u *ns = s + 1;
+       s = ns;
+       while (ASCII_ISALNUM(*s) || *s == '_')
+           ++s;
        int sid = rettv->vval.v_number;
-       return eval_variable(s + 1, 0, sid, rettv, NULL, 0);
+       return eval_variable(ns, (int)(s - ns), sid, rettv, NULL, 0);
     }
     return OK;
 }
index cf7a6c1ce2d5eb78bfadec50c3f9377457ac44e3..c6c583a5458de8e93302a8a88ff05f21652036e1 100644 (file)
@@ -992,6 +992,10 @@ def Test_class_import()
       a = animal.Animal.new('fish', 'Eric')
       assert_equal('fish', a.kind)
       assert_equal('Eric', a.name)
+
+      var b: animal.Animal = animal.Animal.new('cat', 'Garfield')
+      assert_equal('cat', b.kind)
+      assert_equal('Garfield', b.name)
   END
   v9.CheckScriptSuccess(lines)
 enddef
index a0fc017a03ad6da7b791d441061a858205dd770d..f702b36a3437d8e0f7f636ad0499857e0e764aa5 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1186,
 /**/
     1185,
 /**/