forked from aniani/vim
patch 9.1.1002: Vim9: unknown func error with interface declaring func var
Problem: Vim9: unknown function error with interface declaring a function variable (lifepillar) Solution: Use correct instruction for getting interface member variables (Yegappan Lakshmanan) fixes: #16345 closes: #16421 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
668e9f2403
commit
c10342da44
@@ -7257,6 +7257,31 @@ def Test_interface_extends_with_dup_members()
|
|||||||
v9.CheckSourceSuccess(lines)
|
v9.CheckSourceSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" Test for implementing an interface with different ordering for the interface
|
||||||
|
" member variables.
|
||||||
|
def Test_implement_interface_with_different_variable_order()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
interface IX
|
||||||
|
var F: func(): string
|
||||||
|
endinterface
|
||||||
|
|
||||||
|
class X implements IX
|
||||||
|
var x: number
|
||||||
|
var F: func(): string = () => 'ok'
|
||||||
|
endclass
|
||||||
|
|
||||||
|
def Foo(ix: IX): string
|
||||||
|
return ix.F()
|
||||||
|
enddef
|
||||||
|
|
||||||
|
var x0 = X.new(0)
|
||||||
|
assert_equal('ok', Foo(x0))
|
||||||
|
END
|
||||||
|
v9.CheckSourceSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
" Test for using "any" type for a variable in a sub-class while it has a
|
" Test for using "any" type for a variable in a sub-class while it has a
|
||||||
" concrete type in the interface
|
" concrete type in the interface
|
||||||
def Test_implements_using_var_type_any()
|
def Test_implements_using_var_type_any()
|
||||||
|
@@ -3586,4 +3586,29 @@ def Test_disassemble_member_initializer()
|
|||||||
unlet g:instr
|
unlet g:instr
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" Disassemble the code generated for accessing a interface member variable
|
||||||
|
def Test_disassemble_interface_variable_access()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
interface IX
|
||||||
|
var F: func(): string
|
||||||
|
endinterface
|
||||||
|
|
||||||
|
def Foo(ix: IX): string
|
||||||
|
return ix.F()
|
||||||
|
enddef
|
||||||
|
|
||||||
|
g:instr = execute('disassemble Foo')
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
|
assert_match('<SNR>\d\+_Foo\_s*' ..
|
||||||
|
'return ix.F()\_s*' ..
|
||||||
|
'0 LOAD arg\[-1\]\_s*' ..
|
||||||
|
'1 ITF_MEMBER 0 on IX\_s*' ..
|
||||||
|
'2 PCALL top (argc 0)\_s*' ..
|
||||||
|
'3 PCALL end\_s*' ..
|
||||||
|
'4 RETURN', g:instr)
|
||||||
|
unlet g:instr
|
||||||
|
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 */
|
||||||
|
/**/
|
||||||
|
1002,
|
||||||
/**/
|
/**/
|
||||||
1001,
|
1001,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -392,8 +392,15 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (generate_GET_OBJ_MEMBER(cctx, m_idx, ocm->ocm_type) ==
|
int status;
|
||||||
FAIL)
|
|
||||||
|
if (IS_INTERFACE(cl))
|
||||||
|
status = generate_GET_ITF_MEMBER(cctx, cl, m_idx,
|
||||||
|
ocm->ocm_type);
|
||||||
|
else
|
||||||
|
status = generate_GET_OBJ_MEMBER(cctx, m_idx,
|
||||||
|
ocm->ocm_type);
|
||||||
|
if (status == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user