Mercurial > vim
comparison src/evalbuffer.c @ 22002:c9517003821d v8.2.1550
patch 8.2.1550: Vim9: bufname('%') gives an error
Commit: https://github.com/vim/vim/commit/02aaad91094939758e053588dd23ebda467eea29
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 30 21:26:57 2020 +0200
patch 8.2.1550: Vim9: bufname('%') gives an error
Problem: Vim9: bufname('%') gives an error.
Solution: Only give an error for wrong argument type. (closes https://github.com/vim/vim/issues/6807)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 30 Aug 2020 21:30:03 +0200 |
parents | c8456ff7a4c3 |
children | 71f886a48ef5 |
comparison
equal
deleted
inserted
replaced
22001:b77a58769130 | 22002:c9517003821d |
---|---|
357 */ | 357 */ |
358 void | 358 void |
359 f_bufname(typval_T *argvars, typval_T *rettv) | 359 f_bufname(typval_T *argvars, typval_T *rettv) |
360 { | 360 { |
361 buf_T *buf; | 361 buf_T *buf; |
362 | 362 typval_T *tv = &argvars[0]; |
363 if (argvars[0].v_type == VAR_UNKNOWN) | 363 |
364 if (tv->v_type == VAR_UNKNOWN) | |
364 buf = curbuf; | 365 buf = curbuf; |
365 else | 366 else |
366 { | 367 { |
367 (void)tv_get_number(&argvars[0]); // issue errmsg if type error | |
368 ++emsg_off; | 368 ++emsg_off; |
369 buf = tv_get_buf(&argvars[0], FALSE); | 369 buf = tv_get_buf(tv, FALSE); |
370 --emsg_off; | 370 --emsg_off; |
371 if (buf == NULL | |
372 && tv->v_type != VAR_NUMBER | |
373 && tv->v_type != VAR_STRING) | |
374 // issue errmsg for type error | |
375 (void)tv_get_number(tv); | |
371 } | 376 } |
372 rettv->v_type = VAR_STRING; | 377 rettv->v_type = VAR_STRING; |
373 if (buf != NULL && buf->b_fname != NULL) | 378 if (buf != NULL && buf->b_fname != NULL) |
374 rettv->vval.v_string = vim_strsave(buf->b_fname); | 379 rettv->vval.v_string = vim_strsave(buf->b_fname); |
375 else | 380 else |