@@ -2008,8 +2008,7 @@ static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhs
20082008FUNC_ATTR_NONNULL_ARG (1 )
20092009{
20102010Dictionary dict = ARRAY_DICT_INIT ;
2011- char * const lhs = str2special_save ((const char * )mp -> m_keys ,
2012- compatible , !compatible );
2011+ char * const lhs = str2special_save ((const char * )mp -> m_keys ,compatible , !compatible );
20132012char * const mapmode = map_mode_to_chars (mp -> m_mode );
20142013varnumber_T noremap_value ;
20152014
@@ -2122,13 +2121,15 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
21222121 }
21232122 }else {
21242123// Return a dictionary.
2125- tv_dict_alloc_ret (rettv );
21262124if (mp != NULL && (rhs != NULL || rhs_lua != LUA_NOREF )) {
21272125Dictionary dict = mapblock_fill_dict (mp ,
21282126did_simplify ? (char * )keys_simplified :NULL ,
21292127buffer_local , true);
21302128 (void )object_to_vim (DICTIONARY_OBJ (dict ),rettv ,NULL );
21312129api_free_dictionary (dict );
2130+ }else {
2131+ // Return an empty dictionary.
2132+ tv_dict_alloc_ret (rettv );
21322133 }
21332134 }
21342135
@@ -2164,12 +2165,12 @@ void f_mapset(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
21642165Object callback_obj = vim_to_object (& callback_di -> di_tv );
21652166if (callback_obj .type == kObjectTypeLuaRef && callback_obj .data .luaref != LUA_NOREF ) {
21662167rhs_lua = callback_obj .data .luaref ;
2167- orig_rhs = "" ;// need non-NULL for strlen()
2168+ orig_rhs = "" ;
21682169callback_obj .data .luaref = LUA_NOREF ;
21692170 }
21702171api_free_object (callback_obj );
21712172 }
2172- if (lhs == NULL || lhsraw == NULL || ( orig_rhs == NULL && rhs_lua == LUA_NOREF ) ) {
2173+ if (lhs == NULL || lhsraw == NULL || orig_rhs == NULL ) {
21732174emsg (_ ("E460: entries missing in mapset() dict argument" ));
21742175api_free_luaref (rhs_lua );
21752176return ;