Patch 8.2.4678

11 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 3, 2022, 4:12:18 PM4/3/22
to vim...@googlegroups.com

Patch 8.2.4678
Problem: Vim9: not all code is tested.
Solution: Add a few more tests.
Files: src/vim9execute.c, src/testdir/test_vim9_script.vim,
src/testdir/test_vim9_import.vim, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.4677/src/vim9execute.c 2022-04-01 15:26:54.988558723 +0100
--- src/vim9execute.c 2022-04-03 19:46:09.277664634 +0100
***************
*** 2636,2642 ****
--- 2636,2645 ----
SOURCING_LNUM = iptr->isn_lnum;
if (do_source(si->sn_name, FALSE, DOSO_NONE, NULL)
== FAIL)
+ {
+ semsg(_(e_cant_open_file_str_2), si->sn_name);
goto on_error;
+ }
}
}
break;
*** ../vim-8.2.4677/src/testdir/test_vim9_script.vim 2022-04-03 16:13:03.420370565 +0100
--- src/testdir/test_vim9_script.vim 2022-04-03 21:10:45.923612372 +0100
***************
*** 2130,2135 ****
--- 2130,2146 ----
endfor
assert_equal('', res)

+ total = 0
+ for c in null_list
+ total += 1
+ endfor
+ assert_equal(0, total)
+
+ for c in null_blob
+ total += 1
+ endfor
+ assert_equal(0, total)
+
var foo: list<dict<any>> = [
{a: 'Cat'}
]
*** ../vim-8.2.4677/src/testdir/test_vim9_import.vim 2022-03-31 16:18:19.916278625 +0100
--- src/testdir/test_vim9_import.vim 2022-04-03 20:26:55.879006212 +0100
***************
*** 858,863 ****
--- 858,865 ----
writefile(lines, 'XimportRel.vim')
writefile(lines, 'XimportRel2.vim')
writefile(lines, 'XimportRel3.vim')
+ writefile(lines, 'XimportRel4.vim')
+ writefile(lines, 'XimportRel5.vim')

lines =<< trim END
vim9script
***************
*** 928,944 ****
END
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)

lines =<< trim END
vim9script
! import autoload './XimportRel.vim'
def Func()
! XimportRel.notexp = 'bad'
enddef
Func()
END
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)

! # does not fail if the script wasn't loaded yet
g:loaded = 'no'
lines =<< trim END
vim9script
--- 930,947 ----
END
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)

+ # Same, script not imported before
lines =<< trim END
vim9script
! import autoload './XimportRel4.vim'
def Func()
! echo XimportRel4.notexp
enddef
Func()
END
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)

! # does not fail if the script wasn't loaded yet and only compiling
g:loaded = 'no'
lines =<< trim END
vim9script
***************
*** 951,956 ****
--- 954,969 ----
v9.CheckScriptSuccess(lines)
assert_equal('no', g:loaded)

+ lines =<< trim END
+ vim9script
+ import autoload './XimportRel.vim'
+ def Func()
+ XimportRel.notexp = 'bad'
+ enddef
+ Func()
+ END
+ v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)
+
# fails with a not loaded import
lines =<< trim END
vim9script
***************
*** 964,972 ****
--- 977,1013 ----
assert_equal('yes', g:loaded)
unlet g:loaded

+ lines =<< trim END
+ vim9script
+ import autoload './XimportRel5.vim'
+ def Func()
+ XimportRel5.nosuchvar = 'bad'
+ enddef
+ Func()
+ END
+ v9.CheckScriptFailure(lines, 'E121: Undefined variable: nosuchvar', 1)
+ unlet g:loaded
+
+ # nasty: delete script after compiling function
+ writefile(['vim9script'], 'XimportRelDel.vim')
+ lines =<< trim END
+ vim9script
+
+ import autoload './XimportRelDel.vim'
+ def DoIt()
+ echo XimportRelDel.var
+ enddef
+ defcompile
+ delete('XimportRelDel.vim')
+ DoIt()
+ END
+ v9.CheckScriptFailure(lines, 'E456:')
+
delete('XimportRel.vim')
delete('XimportRel2.vim')
delete('XimportRel3.vim')
+ delete('XimportRel4.vim')
+ delete('XimportRel5.vim')
enddef

def Test_autoload_import_relative_autoload_dir()
***************
*** 1576,1585 ****
var lines =<< trim END
vim9script

! if exists('g:loaded')
finish
endif
! g:loaded = 1
delcommand CallFunc
command CallFunc Func()
def Func()
--- 1617,1626 ----
var lines =<< trim END
vim9script

! if exists('g:loadedThis')
finish
endif
! g:loadedThis = 1
delcommand CallFunc
command CallFunc Func()
def Func()
***************
*** 1594,1600 ****

delete('XreloadFunc.vim')
delcommand CallFunc
! unlet g:loaded
unlet g:didTheFunc
enddef

--- 1635,1641 ----

delete('XreloadFunc.vim')
delcommand CallFunc
! unlet g:loadedThis
unlet g:didTheFunc
enddef

*** ../vim-8.2.4677/src/testdir/test_vim9_cmd.vim 2022-04-02 19:43:53.927491819 +0100
--- src/testdir/test_vim9_cmd.vim 2022-04-03 20:43:49.016578428 +0100
***************
*** 1538,1543 ****
--- 1538,1551 ----
d.a = 7
assert_equal({a: 7, b: 5}, d)

+ caught = false
+ try
+ lockvar d.c
+ catch /E716/
+ caught = true
+ endtry
+ assert_true(caught)
+
var lines =<< trim END
vim9script
g:bl = 0z1122
*** ../vim-8.2.4677/src/version.c 2022-04-03 18:01:39.659574455 +0100
--- src/version.c 2022-04-03 19:20:49.113476573 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4678,
/**/

--
BRIDGEKEEPER: What is your favorite editor?
GAWAIN: Emacs ... No, Viiiiiiiiiiimmmmmmm!
"Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

John Marriott

unread,
Apr 3, 2022, 4:49:32 PM4/3/22
to vim...@googlegroups.com

On 04-Apr-2022 06:12, Bram Moolenaar wrote:
> Patch 8.2.4678
> Problem: Vim9: not all code is tested.
> Solution: Add a few more tests.
> Files: src/vim9execute.c, src/testdir/test_vim9_script.vim,
> src/testdir/test_vim9_import.vim, src/testdir/test_vim9_cmd.vim
>
>
>
After this patch, mingw64 (gcc 11.2.0) throws this error:
<snip>
gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD vim9execute.c -o
gobjnative/vim9execute.o
In file included from vim9execute.c:15:
vim9execute.c: In function 'exec_instructions':
vim9execute.c:2640:37: error: 'e_cant_open_file_str_2' undeclared (first
use in this function); did you mean 'e_cant_open_file_str'?
 2640 |                             semsg(_(e_cant_open_file_str_2),
si->sn_name);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~
vim.h:564:25: note: in definition of macro '_'
  564 | # define _(x) ((char *)(x))
      |                         ^
vim9execute.c:2640:37: note: each undeclared identifier is reported only
once for each function it appears in
 2640 |                             semsg(_(e_cant_open_file_str_2),
si->sn_name);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~
vim.h:564:25: note: in definition of macro '_'
  564 | # define _(x) ((char *)(x))
      |                         ^
make: *** [Make_cyg_ming.mak:1187: gobjnative/vim9execute.o] Error 1
</snip>

The attached patch tries to fix it.

Also, I noticed that two error messages have the same error number in
errors.h:



Cheers
John
errors.h.8.2.4678.patch

Bram Moolenaar

unread,
Apr 3, 2022, 5:00:52 PM4/3/22
to vim...@googlegroups.com, John Marriott

John Marriott wrote:

> On 04-Apr-2022 06:12, Bram Moolenaar wrote:
> > Patch 8.2.4678
> > Problem: Vim9: not all code is tested.
> > Solution: Add a few more tests.
> > Files: src/vim9execute.c, src/testdir/test_vim9_script.vim,
> > src/testdir/test_vim9_import.vim, src/testdir/test_vim9_cmd.> vim
> >
> >
> >
> After this patch, mingw64 (gcc 11.2.0) throws this error:
> <snip>
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO
> -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return
> -fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD vim9execute.c -o
> gobjnative/vim9execute.o
> In file included from vim9execute.c:15:
> vim9execute.c: In function 'exec_instructions':
> vim9execute.c:2640:37: error: 'e_cant_open_file_str_2' undeclared (first
> use in this function); did you mean 'e_cant_open_file_str'?
>  2640 |          >             Â>        semsg(_(e_cant_open_file_str_2),
> si->sn_name);
>       |       >             Â>              >      ^~~~~~~~~~~~~~~~~~~~~~
> vim.h:564:25: note: in definition of macro '_'
>   564 | # define _(x) ((char *)(x))
>       |       >             Â>       ^
> vim9execute.c:2640:37: note: each undeclared identifier is reported only
> once for each function it appears in
>  2640 |          >             Â>        semsg(_(e_cant_open_file_str_2),
> si->sn_name);
>       |       >             Â>              >      ^~~~~~~~~~~~~~~~~~~~~~
> vim.h:564:25: note: in definition of macro '_'
>   564 | # define _(x) ((char *)(x))
>       |       >             Â>       ^
> make: *** [Make_cyg_ming.mak:1187: gobjnative/vim9execute.o] Error 1
> </snip>
>
> The attached patch tries to fix it.

I had just sent out a patch to fix this.

> Also, I noticed that two error messages have the same error number in
> errors.h:

Missing quote?

If it's a very similar error, that would be OK.

--
BRIDGEKEEPER: What is the air-speed velocity of an unladen swallow?
ARTHUR: What do you mean? An African or European swallow?
BRIDGEKEEPER: Er ... I don't know that ... Aaaaarrrrrrggghhh!
BRIDGEKEEPER is cast into the gorge.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Reply all
Reply to author
Forward
0 new messages