Hi,
On Sat, Sep 5, 2020 at 12:30 PM lacygoill <[email protected]> wrote:
> *Describe the bug*
>
> In Vim9 script, we cannot pass true as an argument to setqflist(), to
> specify that an entry is valid.
>
> *To Reproduce*
>
> Run this shell command:
>
> vim -Nu NONE -S <(cat <<'EOF'
> vim9script
> let items = [#{filename: '/tmp/file', lnum: 1, valid: true}]
> let what = #{items: items}
> setqflist([], ' ', what)
> EOF
> )
>
>
The following change will address this issue:
==================================================
diff --git a/src/quickfix.c b/src/quickfix.c
index 09d5d8fa0..06178d37e 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -7072,7 +7072,7 @@ qf_add_entry_from_dict(
// If the 'valid' field is present it overrules the detected value.
if ((dict_find(d, (char_u *)"valid", -1)) != NULL)
- valid = (int)dict_get_number(d, (char_u *)"valid");
+ valid = (int)dict_get_bool(d, (char_u *)"valid", valid);
status = qf_add_entry(qfl,
NULL, // dir
==================================================
Regards,
Yegappan
> And this shell command:
>
> vim -Nu NONE -S <(cat <<'EOF'
> vim9script
> let items = [#{filename: '/tmp/file', lnum: 1, valid: false}]
> let what = #{items: items}
> setloclist(0, [], ' ', what)
> EOF
> )
>
> E611 is raised in both cases:
>
> E611: Using a Special as a Number
>
> *Expected behavior*
>
> No error is raised.
>
> *Environment*
>
> - Vim version: 8.2 Included patches: 1-1613
> - OS: Ubuntu 16.04.7 LTS
> - Terminal: xterm(359)
>
> *Additional context*
>
> Regression introduced in 8.2.1465
> <https://github.com/vim/vim/releases/tag/v8.2.1465>.
> ------------------------------
>
> I don't know how to fix this issue; the code for the quickfix list is too
> complex for me. Here is a patch adding a test:
>
> diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
> index b3b6b3225..c2c7416ec 100644--- a/src/testdir/test_vim9_func.vim+++
> b/src/testdir/test_vim9_func.vim@@ -1609,6 +1609,18 @@ def Test_mapcheck()
> iunabbrev foo
> enddef
> +def Test_setqflist()+ let items = [#{filename: '/tmp/file', lnum: 1,
> valid: true}]+ let what = #{items: items}+ setqflist([], ' ', what)+
> assert_equal(1, getqflist()[0].valid)++ items = [#{filename: '/tmp/file',
> lnum: 1, valid: false}]+ what = #{items: items}+ setloclist(0, [], ' ',
> what)+ assert_equal(0, getloclist(0)[0].valid)+enddef+
> def Test_recursive_call()
> assert_equal(6765, Fibonacci(20))
> enddef
>
>
>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/CAAW7x7nX3FbsK8LPKOfm7-mfpU_EO1Pk_fhy9UAgoK%3Dh5zcqeg%40mail.gmail.com.