Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

辞書関数内で remove(l: 'self') でクラッシュ #653

Open
thinca opened this issue Oct 13, 2014 · 5 comments
Open

辞書関数内で remove(l: 'self') でクラッシュ #653

thinca opened this issue Oct 13, 2014 · 5 comments

Comments

@thinca
Copy link
Member

thinca commented Oct 13, 2014

test.vim

let obj = {}
function! obj.rm()
  call remove(l:, 'self')
endfunction

call obj.rm()
$ vim -u NONE -i NONE -N -S test.vim
Vim: Caught deadly signal ABRT
Vim: Finished.

Vim 7.4.475
OS: Gentoo Linux

@thinca
Copy link
Member Author

thinca commented Oct 13, 2014

備考: unlet self はきちんとハンドルされているようです。 => E795: 変数 self を削除できません

@mattn
Copy link
Member

mattn commented Oct 14, 2014

diff -r 79c59b4c9d20 src/eval.c
--- a/src/eval.c    Sat Oct 11 14:47:26 2014 +0200
+++ b/src/eval.c    Tue Oct 14 16:47:07 2014 +0900
@@ -15663,7 +15663,7 @@
        di = dict_find(d, key, -1);
        if (di == NULL)
            EMSG2(_(e_dictkey), key);
-       else
+       else if (!var_check_fixed(di->di_flags, key))
        {
            *rettv = di->di_tv;
            init_tv(&di->di_tv);

remove() はOKなんですが filter() をどうすべきか。

  1. filter にはアイテムとして現れない
  2. v:key != "self" を指定しても消せない

どちらがいいでしょうね。

@thinca
Copy link
Member Author

thinca commented Oct 14, 2014

そう言えば、extend() を使うと self を上書きできます。特にクラッシュなどはしないようですが…。

@mattn
Copy link
Member

mattn commented Oct 21, 2014

filter の件、どうしましょうか

@thinca
Copy link
Member Author

thinca commented Oct 31, 2014

どっちも微妙な気がしますし、Bram さんに報告してどうするか決めてもらうのがいいかもしれないですね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants