Mercurial > vim
comparison src/typval.c @ 22025:71f886a48ef5 v8.2.1562
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Commit: https://github.com/vim/vim/commit/3767e3a3302d745349eff8cfe45411f03e13de43
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 1 23:06:01 2020 +0200
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Problem: Vim9: error when using "%" where a buffer is expected.
Solution: Add tv_get_buf_from_arg(). (closes https://github.com/vim/vim/issues/6814)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 01 Sep 2020 23:15:03 +0200 |
parents | 9fc27a955f00 |
children | 4bc644f4dd2d |
comparison
equal
deleted
inserted
replaced
22024:dd2ca50d7e0a | 22025:71f886a48ef5 |
---|---|
1560 buf = find_buffer(tv); | 1560 buf = find_buffer(tv); |
1561 | 1561 |
1562 return buf; | 1562 return buf; |
1563 } | 1563 } |
1564 | 1564 |
1565 /* | |
1566 * Like tv_get_buf() but give an error message is the type is wrong. | |
1567 */ | |
1568 buf_T * | |
1569 tv_get_buf_from_arg(typval_T *tv) | |
1570 { | |
1571 buf_T *buf; | |
1572 | |
1573 ++emsg_off; | |
1574 buf = tv_get_buf(tv, FALSE); | |
1575 --emsg_off; | |
1576 if (buf == NULL | |
1577 && tv->v_type != VAR_NUMBER | |
1578 && tv->v_type != VAR_STRING) | |
1579 // issue errmsg for type error | |
1580 (void)tv_get_number(tv); | |
1581 return buf; | |
1582 } | |
1583 | |
1565 #endif // FEAT_EVAL | 1584 #endif // FEAT_EVAL |