Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 27565:0b12dd90a5d6 v8.2.4309
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Commit: https://github.com/vim/vim/commit/fe1bfc9b267fffedac6b5224d7aa6cc5d9d15f64
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 6 13:55:03 2022 +0000
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Problem: Vim9: crash when using a partial in the wrong context.
Solution: Don't use an NULL outer pointer. (closes https://github.com/vim/vim/issues/9706)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 06 Feb 2022 15:00:03 +0100 |
parents | 7898c7847293 |
children | ecea41486e8a |
comparison
equal
deleted
inserted
replaced
27564:b7040a16ebb1 | 27565:0b12dd90a5d6 |
---|---|
3123 const Call = Foo(Expr) | 3123 const Call = Foo(Expr) |
3124 END | 3124 END |
3125 v9.CheckScriptFailure(lines, 'E1235:') | 3125 v9.CheckScriptFailure(lines, 'E1235:') |
3126 enddef | 3126 enddef |
3127 | 3127 |
3128 " Using "idx" from a legacy global function does not work. | |
3129 " This caused a crash when called from legacy context. | |
3130 func Test_partial_call_fails() | |
3131 let lines =<< trim END | |
3132 vim9script | |
3133 | |
3134 var l = ['a', 'b', 'c'] | |
3135 def Iter(container: any): any | |
3136 var idx = -1 | |
3137 var obj = {state: container} | |
3138 def g:__NextItem__(self: dict<any>): any | |
3139 ++idx | |
3140 return self.state[idx] | |
3141 enddef | |
3142 obj.__next__ = function('g:__NextItem__', [obj]) | |
3143 return obj | |
3144 enddef | |
3145 | |
3146 var it = Iter(l) | |
3147 echo it.__next__() | |
3148 END | |
3149 call writefile(lines, 'XpartialCall') | |
3150 try | |
3151 source XpartialCall | |
3152 catch /E1248:/ | |
3153 endtry | |
3154 call delete('XpartialCall') | |
3155 endfunc | |
3156 | |
3128 def Test_cmd_modifier() | 3157 def Test_cmd_modifier() |
3129 tab echo '0' | 3158 tab echo '0' |
3130 v9.CheckDefFailure(['5tab echo 3'], 'E16:') | 3159 v9.CheckDefFailure(['5tab echo 3'], 'E16:') |
3131 enddef | 3160 enddef |
3132 | 3161 |