From 68db996b621b98066fb7ab7028ed5c6aaa3954a8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 9 May 2021 23:19:22 +0200 Subject: patch 8.2.2846: Vim9: "echo Func()" does not give an error for using void Problem: Vim9: "echo Func()" does not give an error for a function without a return value. Solution: Give an error. Be more specific about why a value is invalid. --- src/testdir/test_vim9_cmd.vim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/testdir/test_vim9_cmd.vim') diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index 080fe20cc..87832ce2e 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1282,5 +1282,28 @@ def Test_redir_to_var() CheckDefFailure(lines, 'E1141:') enddef +def Test_echo_void() + var lines =<< trim END + vim9script + def NoReturn() + echo 'nothing' + enddef + echo NoReturn() + END + CheckScriptFailure(lines, 'E1186:', 5) + + lines =<< trim END + vim9script + def NoReturn() + echo 'nothing' + enddef + def Try() + echo NoReturn() + enddef + defcompile + END + CheckScriptFailure(lines, 'E1186:', 1) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker -- cgit v1.2.1