mirror of
https://github.com/vim/vim.git
synced 2025-09-06 21:53:38 -04:00
patch 9.1.1040: Vim9: imported type cannot be used as func return type
Problem: Vim9: imported type cannot be used as func return type (Dayvid Albuquerque) Solution: temporarily reset the is_export flag (Yegappan Lakshmanan) fixes: #16489 closes: #16492 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
4335fcfed1
commit
d79ea47079
@ -3387,4 +3387,37 @@ def Test_import_locked_var()
|
|||||||
v9.CheckScriptFailure(lines, 'E741: Value is locked: Foo', 3)
|
v9.CheckScriptFailure(lines, 'E741: Value is locked: Foo', 3)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" Test for using an autoload imported class as the function return type
|
||||||
|
def Test_imported_class_as_def_func_rettype()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
export class Foo
|
||||||
|
var name: string = "foo"
|
||||||
|
endclass
|
||||||
|
END
|
||||||
|
writefile(lines, 'Ximportclassrettype1.vim', 'D')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
import autoload "./Ximportclassrettype1.vim" as A
|
||||||
|
|
||||||
|
export def CreateFoo(): A.Foo
|
||||||
|
return A.Foo.new()
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(lines, 'Ximportclassrettype2.vim', 'D')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
import './Ximportclassrettype2.vim' as B
|
||||||
|
|
||||||
|
var foo = B.CreateFoo()
|
||||||
|
assert_equal('foo', foo.name)
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
|
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
|
||||||
|
@ -5472,11 +5472,19 @@ define_function(
|
|||||||
// The function may use script variables from the context.
|
// The function may use script variables from the context.
|
||||||
function_using_block_scopes(fp, cstack);
|
function_using_block_scopes(fp, cstack);
|
||||||
|
|
||||||
|
// The argument types and the return type may use an imported type.
|
||||||
|
// In that case, the imported file will be sourced. To avoid treating
|
||||||
|
// everything in the imported file as exported, temporarily reset
|
||||||
|
// is_export.
|
||||||
|
int save_is_export = is_export;
|
||||||
|
is_export = FALSE;
|
||||||
|
|
||||||
if (parse_argument_types(fp, &argtypes, varargs, &arg_objm,
|
if (parse_argument_types(fp, &argtypes, varargs, &arg_objm,
|
||||||
obj_members, obj_member_count) == FAIL)
|
obj_members, obj_member_count) == FAIL)
|
||||||
{
|
{
|
||||||
SOURCING_LNUM = lnum_save;
|
SOURCING_LNUM = lnum_save;
|
||||||
free_fp = fp_allocated;
|
free_fp = fp_allocated;
|
||||||
|
is_export = save_is_export;
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
varargs = FALSE;
|
varargs = FALSE;
|
||||||
@ -5486,8 +5494,10 @@ define_function(
|
|||||||
{
|
{
|
||||||
SOURCING_LNUM = lnum_save;
|
SOURCING_LNUM = lnum_save;
|
||||||
free_fp = fp_allocated;
|
free_fp = fp_allocated;
|
||||||
|
is_export = save_is_export;
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
|
is_export = save_is_export;
|
||||||
SOURCING_LNUM = lnum_save;
|
SOURCING_LNUM = lnum_save;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* Vim originated from Stevie version 3.6 (Fish disk 217) by GRWalter (Fred)
|
* Vim originated from Stevie version 3.6 (Fish disk 217) by GRWalter (Fred)
|
||||||
* It has been changed beyond recognition since then.
|
* It has been changed beyond recognition since then.
|
||||||
*
|
*
|
||||||
* Differences between version 8.2 and 9.0 can be found with ":help version9".
|
* Differences between version 8.2 and 9.1 can be found with ":help version9".
|
||||||
* Differences between version 7.4 and 8.x can be found with ":help version8".
|
* Differences between version 7.4 and 8.x can be found with ":help version8".
|
||||||
* Differences between version 6.4 and 7.x can be found with ":help version7".
|
* Differences between version 6.4 and 7.x can be found with ":help version7".
|
||||||
* Differences between version 5.8 and 6.x can be found with ":help version6".
|
* Differences between version 5.8 and 6.x can be found with ":help version6".
|
||||||
@ -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 */
|
||||||
|
/**/
|
||||||
|
1040,
|
||||||
/**/
|
/**/
|
||||||
1039,
|
1039,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user