Patch 9.0.1265

1 view
Skip to first unread message

Bram Moolenaar

unread,
Jan 30, 2023, 3:25:04 PM1/30/23
to vim...@googlegroups.com

Patch 9.0.1265
Problem: Using an interface method may give a compilation error.
Solution: Do not try to compile the body of a method of an interface.
(closes #11885)
Files: src/vim9compile.c, src/testdir/test_vim9_class.vim


*** ../vim-9.0.1264/src/vim9compile.c 2023-01-26 11:58:39.606071598 +0000
--- src/vim9compile.c 2023-01-30 19:45:29.004751867 +0000
***************
*** 3181,3186 ****
--- 3181,3196 ----
}
ufunc->uf_args_visible = ufunc->uf_args.ga_len;

+ // Compiling a function in an interface is done to get the function type.
+ // No code is actually compiled.
+ if (ufunc->uf_class != NULL
+ && (ufunc->uf_class->class_flags & CLASS_INTERFACE))
+ {
+ ufunc->uf_def_status = UF_NOT_COMPILED;
+ ret = OK;
+ goto erret;
+ }
+
/*
* Loop over all the lines of the function and generate instructions.
*/
***************
*** 3705,3711 ****
iemsg("Type stack underflow");
goto erret;
}
! }

if (cctx.ctx_scope != NULL)
{
--- 3715,3721 ----
iemsg("Type stack underflow");
goto erret;
}
! } // END of the loop over all the function body lines.

if (cctx.ctx_scope != NULL)
{
*** ../vim-9.0.1264/src/testdir/test_vim9_class.vim 2023-01-28 19:18:56.737720609 +0000
--- src/testdir/test_vim9_class.vim 2023-01-30 19:47:09.340691197 +0000
***************
*** 1049,1054 ****
--- 1049,1071 ----
unlet g:result
END
v9.CheckScriptSuccess(lines)
+
+ # No class that implements the interface.
+ lines =<< trim END
+ vim9script
+
+ interface IWithEE
+ def Enter(): any
+ def Exit(): void
+ endinterface
+
+ def With1(ee: IWithEE, F: func)
+ var r = ee.Enter()
+ enddef
+
+ defcompile
+ END
+ v9.CheckScriptSuccess(lines)
enddef

def Test_class_used_as_type()
*** ../vim-9.0.1264/src/version.c 2023-01-30 19:26:20.481324263 +0000
--- src/version.c 2023-01-30 19:41:12.608941475 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1265,
/**/

--
hundred-and-one symptoms of being an internet addict:
70. ISDN lines are added to your house on a hourly basis

/// 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 ///
Reply all
Reply to author
Forward
0 new messages