-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Problem: Vim9: type checking global variables is inconsistent. Solution: Use the "unknown" type in more places.
- Loading branch information
Showing
7 changed files
with
121 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,6 +547,39 @@ def Test_call_default_args() | |
defcompile | ||
END | ||
CheckScriptFailure(lines, 'E1001: Variable not found: b') | ||
|
||
# using script variable requires matching type or type cast | ||
lines =<< trim END | ||
vim9script | ||
var a: any | ||
def Func(arg: string = a) | ||
echo arg | ||
enddef | ||
defcompile | ||
END | ||
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got any') | ||
|
||
lines =<< trim END | ||
vim9script | ||
var a: any | ||
def Func(arg: string = <string>a) | ||
echo arg | ||
enddef | ||
a = 'works' | ||
Func() | ||
END | ||
CheckScriptSuccess(lines) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
brammool
via email
Author
Contributor
|
||
|
||
# using global variable does not require type cast | ||
lines =<< trim END | ||
vim9script | ||
def Func(arg: string = g:str) | ||
echo arg | ||
enddef | ||
g:str = 'works' | ||
Func() | ||
END | ||
CheckScriptSuccess(lines) | ||
enddef | ||
|
||
def FuncWithComment( # comment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
In
src/testdir/test_vim9_func.vim
, line 571, the test doesn't pass for me:And it doesn't work when run alone: