mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -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
|
||||
enddef
|
||||
|
||||
" Test for using an autoloaded class from another autoloaded script
|
||||
def Test_class_from_auloaded_script()
|
||||
" Test for using an imported class as a type
|
||||
def Test_use_imported_class_as_type()
|
||||
mkdir('Xdir', 'R')
|
||||
var save_rtp = &rtp
|
||||
&rtp = getcwd()
|
||||
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
||||
|
||||
mkdir('Xdir/autoload/SomeClass/bar', 'p')
|
||||
|
||||
mkdir('Xdir/autoload', 'D')
|
||||
mkdir('Xdir/import', 'D')
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
|
||||
export class Baz
|
||||
static var v1: string = "v1"
|
||||
var v2: string = "v2"
|
||||
def GetName(): string
|
||||
return "baz"
|
||||
export class B
|
||||
var foo: string
|
||||
def new()
|
||||
this.foo = 'bar'
|
||||
enddef
|
||||
endclass
|
||||
END
|
||||
writefile(lines, 'Xdir/autoload/SomeClass/bar/baz.vim', 'D')
|
||||
writefile(lines, 'Xdir/autoload/b.vim')
|
||||
|
||||
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
|
||||
import autoload '../autoload/b.vim'
|
||||
export class A
|
||||
final AO: b.B = b.B.new()
|
||||
endclass
|
||||
var a = A.new()
|
||||
assert_equal('bar', a.AO.foo)
|
||||
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
|
||||
writefile(lines, 'Xdir/import/a.vim')
|
||||
source Xdir/import/a.vim
|
||||
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
|
||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1128,
|
||||
/**/
|
||||
1127,
|
||||
/**/
|
||||
|
@@ -2053,7 +2053,7 @@ early_ret:
|
||||
tv.v_type = VAR_CLASS;
|
||||
tv.vval.v_class = cl;
|
||||
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)
|
||||
goto cleanup;
|
||||
|
||||
@@ -2873,7 +2873,7 @@ ex_type(exarg_T *eap)
|
||||
tv.vval.v_class = type->tt_class;
|
||||
++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);
|
||||
|
||||
done:
|
||||
|
Reference in New Issue
Block a user