mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.1.1128: patch 9.1.1119 caused a regression with imports
Problem: patch 9.1.1119 caused a regression with imports (girishji) Solution: revert the script ID change for the class script variable for now (Yegappan Lakshmanan) fixes: #16664 closes: #16670 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
106899eb21
commit
e3fed4828c
@@ -3494,75 +3494,105 @@ def Test_vim9_import_and_class_extends_2()
|
|||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Test for using an autoloaded class from another autoloaded script
|
" Test for using an imported class as a type
|
||||||
def Test_class_from_auloaded_script()
|
def Test_use_imported_class_as_type()
|
||||||
mkdir('Xdir', 'R')
|
mkdir('Xdir', 'R')
|
||||||
var save_rtp = &rtp
|
mkdir('Xdir/autoload', 'D')
|
||||||
&rtp = getcwd()
|
mkdir('Xdir/import', 'D')
|
||||||
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
|
||||||
|
|
||||||
mkdir('Xdir/autoload/SomeClass/bar', 'p')
|
|
||||||
|
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
export class B
|
||||||
export class Baz
|
var foo: string
|
||||||
static var v1: string = "v1"
|
def new()
|
||||||
var v2: string = "v2"
|
this.foo = 'bar'
|
||||||
def GetName(): string
|
|
||||||
return "baz"
|
|
||||||
enddef
|
enddef
|
||||||
endclass
|
endclass
|
||||||
END
|
END
|
||||||
writefile(lines, 'Xdir/autoload/SomeClass/bar/baz.vim', 'D')
|
writefile(lines, 'Xdir/autoload/b.vim')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
import autoload '../autoload/b.vim'
|
||||||
import autoload './bar/baz.vim'
|
export class A
|
||||||
|
final AO: b.B = b.B.new()
|
||||||
export def MyTestFoo(): string
|
endclass
|
||||||
assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
|
var a = A.new()
|
||||||
assert_fails('var x = baz.Baz.foobar', 'E1337: Class variable "foobar" not found in class "Baz"')
|
assert_equal('bar', a.AO.foo)
|
||||||
|
|
||||||
const instance = baz.Baz.new()
|
|
||||||
return $'{instance.GetName()} {baz.Baz.v1} {instance.v2}'
|
|
||||||
enddef
|
|
||||||
END
|
END
|
||||||
writefile(lines, 'Xdir/autoload/SomeClass/foo.vim', 'D')
|
writefile(lines, 'Xdir/import/a.vim')
|
||||||
|
source Xdir/import/a.vim
|
||||||
lines =<< trim END
|
|
||||||
vim9script
|
|
||||||
|
|
||||||
import autoload 'SomeClass/foo.vim'
|
|
||||||
import autoload 'SomeClass/bar/baz.vim'
|
|
||||||
|
|
||||||
def NotInAutoload()
|
|
||||||
# Use non-existing class method and variable
|
|
||||||
assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
|
|
||||||
|
|
||||||
var caught_exception = false
|
|
||||||
try
|
|
||||||
var x = baz.Baz.foobar
|
|
||||||
catch /E1337: Class variable "foobar" not found in class "Baz"/
|
|
||||||
caught_exception = true
|
|
||||||
endtry
|
|
||||||
assert_true(caught_exception)
|
|
||||||
|
|
||||||
const instance = baz.Baz.new()
|
|
||||||
assert_equal("baz v1 v2", $'{instance.GetName()} {baz.Baz.v1} {instance.v2}')
|
|
||||||
enddef
|
|
||||||
|
|
||||||
def InAutoload()
|
|
||||||
assert_equal("baz v1 v2", foo.MyTestFoo())
|
|
||||||
enddef
|
|
||||||
|
|
||||||
NotInAutoload()
|
|
||||||
InAutoload()
|
|
||||||
END
|
|
||||||
v9.CheckScriptSuccess(lines)
|
|
||||||
|
|
||||||
&rtp = save_rtp
|
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" FIXME: The following test currently fails.
|
||||||
|
" " Test for using an autoloaded class from another autoloaded script
|
||||||
|
" def Test_class_from_auloaded_script()
|
||||||
|
" mkdir('Xdir', 'R')
|
||||||
|
" var save_rtp = &rtp
|
||||||
|
" &rtp = getcwd()
|
||||||
|
" exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
||||||
|
"
|
||||||
|
" mkdir('Xdir/autoload/SomeClass/bar', 'p')
|
||||||
|
"
|
||||||
|
" var lines =<< trim END
|
||||||
|
" vim9script
|
||||||
|
"
|
||||||
|
" export class Baz
|
||||||
|
" static var v1: string = "v1"
|
||||||
|
" var v2: string = "v2"
|
||||||
|
" def GetName(): string
|
||||||
|
" return "baz"
|
||||||
|
" enddef
|
||||||
|
" endclass
|
||||||
|
" END
|
||||||
|
" writefile(lines, 'Xdir/autoload/SomeClass/bar/baz.vim', 'D')
|
||||||
|
"
|
||||||
|
" lines =<< trim END
|
||||||
|
" vim9script
|
||||||
|
"
|
||||||
|
" import autoload './bar/baz.vim'
|
||||||
|
"
|
||||||
|
" export def MyTestFoo(): string
|
||||||
|
" assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
|
||||||
|
" assert_fails('var x = baz.Baz.foobar', 'E1337: Class variable "foobar" not found in class "Baz"')
|
||||||
|
"
|
||||||
|
" const instance = baz.Baz.new()
|
||||||
|
" return $'{instance.GetName()} {baz.Baz.v1} {instance.v2}'
|
||||||
|
" enddef
|
||||||
|
" END
|
||||||
|
" writefile(lines, 'Xdir/autoload/SomeClass/foo.vim', 'D')
|
||||||
|
"
|
||||||
|
" lines =<< trim END
|
||||||
|
" vim9script
|
||||||
|
"
|
||||||
|
" import autoload 'SomeClass/foo.vim'
|
||||||
|
" import autoload 'SomeClass/bar/baz.vim'
|
||||||
|
"
|
||||||
|
" def NotInAutoload()
|
||||||
|
" # Use non-existing class method and variable
|
||||||
|
" assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
|
||||||
|
"
|
||||||
|
" var caught_exception = false
|
||||||
|
" try
|
||||||
|
" var x = baz.Baz.foobar
|
||||||
|
" catch /E1337: Class variable "foobar" not found in class "Baz"/
|
||||||
|
" caught_exception = true
|
||||||
|
" endtry
|
||||||
|
" assert_true(caught_exception)
|
||||||
|
"
|
||||||
|
" const instance = baz.Baz.new()
|
||||||
|
" assert_equal("baz v1 v2", $'{instance.GetName()} {baz.Baz.v1} {instance.v2}')
|
||||||
|
" enddef
|
||||||
|
"
|
||||||
|
" def InAutoload()
|
||||||
|
" assert_equal("baz v1 v2", foo.MyTestFoo())
|
||||||
|
" enddef
|
||||||
|
"
|
||||||
|
" NotInAutoload()
|
||||||
|
" InAutoload()
|
||||||
|
" END
|
||||||
|
" v9.CheckScriptSuccess(lines)
|
||||||
|
"
|
||||||
|
" &rtp = save_rtp
|
||||||
|
" enddef
|
||||||
|
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1128,
|
||||||
/**/
|
/**/
|
||||||
1127,
|
1127,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2053,7 +2053,7 @@ early_ret:
|
|||||||
tv.v_type = VAR_CLASS;
|
tv.v_type = VAR_CLASS;
|
||||||
tv.vval.v_class = cl;
|
tv.vval.v_class = cl;
|
||||||
SOURCING_LNUM = start_lnum;
|
SOURCING_LNUM = start_lnum;
|
||||||
int rc = set_var_const(cl->class_name, 0, NULL, &tv, FALSE, 0, 0);
|
int rc = set_var_const(cl->class_name, current_sctx.sc_sid, NULL, &tv, FALSE, 0, 0);
|
||||||
if (rc == FAIL)
|
if (rc == FAIL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@@ -2873,7 +2873,7 @@ ex_type(exarg_T *eap)
|
|||||||
tv.vval.v_class = type->tt_class;
|
tv.vval.v_class = type->tt_class;
|
||||||
++tv.vval.v_class->class_refcount;
|
++tv.vval.v_class->class_refcount;
|
||||||
}
|
}
|
||||||
set_var_const(name_start, 0, NULL, &tv, FALSE,
|
set_var_const(name_start, current_sctx.sc_sid, NULL, &tv, FALSE,
|
||||||
ASSIGN_CONST | ASSIGN_FINAL, 0);
|
ASSIGN_CONST | ASSIGN_FINAL, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Reference in New Issue
Block a user