mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
fix(typval): don't treat v:null as truthy (#23281)
This commit is contained in:
@@ -4224,7 +4224,7 @@ bool tv2bool(const typval_T *const tv)
|
|||||||
case VAR_BOOL:
|
case VAR_BOOL:
|
||||||
return tv->vval.v_bool == kBoolVarTrue;
|
return tv->vval.v_bool == kBoolVarTrue;
|
||||||
case VAR_SPECIAL:
|
case VAR_SPECIAL:
|
||||||
return tv->vval.v_special == kSpecialVarNull;
|
return tv->vval.v_special != kSpecialVarNull;
|
||||||
case VAR_BLOB:
|
case VAR_BLOB:
|
||||||
return tv->vval.v_blob != NULL && tv->vval.v_blob->bv_ga.ga_len > 0;
|
return tv->vval.v_blob != NULL && tv->vval.v_blob->bv_ga.ga_len > 0;
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
|
@@ -130,6 +130,12 @@ describe('Special values', function()
|
|||||||
eq("v:false", eval('"" . v:false'))
|
eq("v:false", eval('"" . v:false'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('work with ?? (falsy operator)', function()
|
||||||
|
eq(true, eval('v:true ?? 42'))
|
||||||
|
eq(42, eval('v:false ?? 42'))
|
||||||
|
eq(42, eval('v:null ?? 42'))
|
||||||
|
end)
|
||||||
|
|
||||||
it('work with type()', function()
|
it('work with type()', function()
|
||||||
eq(6, funcs.type(true))
|
eq(6, funcs.type(true))
|
||||||
eq(6, funcs.type(false))
|
eq(6, funcs.type(false))
|
||||||
|
Reference in New Issue
Block a user