Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 26974:fceb494e22de v8.2.4016
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Commit: https://github.com/vim/vim/commit/58493cfae255adec2d5b407593b82d07abcc0975
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 6 12:23:30 2022 +0000
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Problem: Vim9: incorrect error for argument that is shadowing var.
Solution: Ignore variable that is not in block where the function was
defined.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Jan 2022 13:30:04 +0100 |
parents | 043a15b37bf1 |
children | eebbcc83fb75 |
comparison
equal
deleted
inserted
replaced
26973:3d561592f19b | 26974:fceb494e22de |
---|---|
929 def g:Func(): string | 929 def g:Func(): string |
930 return 'global' | 930 return 'global' |
931 enddef | 931 enddef |
932 assert_equal('global', Func()) | 932 assert_equal('global', Func()) |
933 delfunc g:Func | 933 delfunc g:Func |
934 END | |
935 CheckScriptSuccess(lines) | |
936 | |
937 # This does not shadow "i" which is visible only inside the for loop | |
938 lines =<< trim END | |
939 vim9script | |
940 | |
941 def Foo(i: number) | |
942 echo i | |
943 enddef | |
944 | |
945 for i in range(3) | |
946 # Foo() is compiled here | |
947 Foo(i) | |
948 endfor | |
934 END | 949 END |
935 CheckScriptSuccess(lines) | 950 CheckScriptSuccess(lines) |
936 enddef | 951 enddef |
937 | 952 |
938 func TakesOneArg(arg) | 953 func TakesOneArg(arg) |