neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7ce17cd2a2657f0dd58213dc45d0309b18913a6f
parent ce05990823034b18f6284a28df2a79b4be96acd8
Author: Jan Edmund Lazo <jan.lazo@mail.utoronto.ca>
Date:   Sun, 14 Dec 2025 01:35:01 -0500

vim-patch:8.2.4529: Vim9: comparing partial with function fails

Problem:    Vim9: comparing partial with function fails.
Solution:   Support this comparison.  Avoid a crash. (closes vim/vim#9909)
            Add more test cases.

https://github.com/vim/vim/commit/ed0c62e7b16b62655824df28cdd6bd75aadbb8fc

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/eval/userfunc.c | 16++++++++++++----
Mtest/old/testdir/test_vimscript.vim | 3+++
2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c @@ -3782,13 +3782,22 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv) char fname_buf[FLEN_FIXED + 1]; int error; - if (rettv->v_type == VAR_PARTIAL && rettv->vval.v_partial->pt_func != NULL) { + if (rettv->v_type == VAR_PARTIAL + && rettv->vval.v_partial != NULL + && rettv->vval.v_partial->pt_func != NULL) { fp = rettv->vval.v_partial->pt_func; } else { char *fname = rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING ? rettv->vval.v_string + : rettv->vval.v_partial == NULL + ? NULL : rettv->vval.v_partial->pt_name; - if (fname != NULL) { + if (fname == NULL) { + // There is no point binding a dict to a NULL function, just create + // a function reference. + rettv->v_type = VAR_FUNC; + rettv->vval.v_string = NULL; + } else { char *tofree = NULL; // Translate "s:func" to the stored function name. @@ -3799,8 +3808,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv) } // Turn "dict.Func" into a partial for "Func" with "dict". - if ((fp != NULL && (fp->uf_flags & FC_DICT)) - || (rettv->v_type == VAR_FUNC && rettv->vval.v_string == NULL)) { + if (fp != NULL && (fp->uf_flags & FC_DICT)) { partial_T *pt = (partial_T *)xcalloc(1, sizeof(partial_T)); pt->pt_refcount = 1; pt->pt_dict = selfdict; diff --git a/test/old/testdir/test_vimscript.vim b/test/old/testdir/test_vimscript.vim @@ -6569,6 +6569,9 @@ func Test_type() call assert_false(v:true is 1) call assert_false(v:true is v:false) " call assert_false(v:none is 0) + " call assert_false(v:none is []) + " call assert_false(v:none is {}) + " call assert_false(v:none is 'text') call assert_false(v:null is 0) " call assert_false(v:null is v:none)