patch 9.1.0286: Vim9: E1027 with defcompile for abstract methods Commit: https://github.com/vim/vim/commit/1af0fbf955f799392f614bc38f9d2fcbd9960526 Author: Yegappan Lakshmanan <yegap...@yahoo.com> Date: Tue Apr 9 21:39:27 2024 +0200
patch 9.1.0286: Vim9: E1027 with defcompile for abstract methods Problem: Vim9: E1027 with defcompile for abstract methods with non-void return types, but still compiles it (zzzyxwvut) Solution: Don't compile abstract methods (Yegappan Lakshmanan) fixes: #14443 closes: #14447 Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index 77a2102c2..6d6d17851 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -10583,4 +10583,46 @@ def Test_lambda_block_in_class() v9.CheckScriptSuccess(lines) enddef +" Test for defcompiling an abstract method +def Test_abstract_method_defcompile() + # Compile an abstract class with abstract object methods + var lines =<< trim END + vim9script + abstract class A + abstract def Foo(): string + abstract def Bar(): list<string> + endclass + defcompile + END + v9.CheckScriptSuccess(lines) + + # Compile a concrete object method in an abstract class + lines =<< trim END + vim9script + abstract class A + abstract def Foo(): string + abstract def Bar(): list<string> + def Baz(): string + pass + enddef + endclass + defcompile + END + v9.CheckScriptFailure(lines, 'E476: Invalid command: pass', 1) + + # Compile a concrete class method in an abstract class + lines =<< trim END + vim9script + abstract class A + abstract def Foo(): string + abstract def Bar(): list<string> + static def Baz(): string + pass + enddef + endclass + defcompile + END + v9.CheckScriptFailure(lines, 'E476: Invalid command: pass', 1) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index d3fde434c..4cece61ad 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 286, /**/ 285, /**/ diff --git a/src/vim9class.c b/src/vim9class.c index 11e952c79..a6b3ee2dc 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -3723,7 +3723,9 @@ defcompile_class(class_T *cl) { ufunc_T *ufunc = loop == 1 ? cl->class_class_functions[i] : cl->class_obj_methods[i]; - defcompile_function(ufunc, cl); + // Don't compile abstract methods + if (!IS_ABSTRACT_METHOD(ufunc)) + defcompile_function(ufunc, cl); } } } -- -- 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 vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1ruHOy-000m1s-83%40256bit.org.