Mercurial > vim
diff src/eval.c @ 23673:6d35bc0f161e v8.2.2378
patch 8.2.2378: Vim9: no error message for dividing by zero
Commit: https://github.com/vim/vim/commit/99880f96cf444014d589fc1d99bb164deaba71ce
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 20 21:23:14 2021 +0100
patch 8.2.2378: Vim9: no error message for dividing by zero
Problem: Vim9: no error message for dividing by zero.
Solution: Give an error message. (issue https://github.com/vim/vim/issues/7704)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 20 Jan 2021 21:30:04 +0100 |
parents | b26bbc03126a |
children | e8c379b20765 |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -63,8 +63,10 @@ num_divide(varnumber_T n1, varnumber_T n { varnumber_T result; - if (n2 == 0) // give an error message? + if (n2 == 0) { + if (in_vim9script()) + emsg(_(e_divide_by_zero)); if (n1 == 0) result = VARNUM_MIN; // similar to NaN else if (n1 < 0) @@ -84,7 +86,8 @@ num_divide(varnumber_T n1, varnumber_T n varnumber_T num_modulus(varnumber_T n1, varnumber_T n2) { - // Give an error when n2 is 0? + if (n2 == 0 && in_vim9script()) + emsg(_(e_divide_by_zero)); return (n2 == 0) ? 0 : (n1 % n2); }