patch 9.1.0329: String interpolation fails for Dict type
Problem: String interpolation fails for Dict type
Solution: Support Dict data type properly, also support :put =Dict
(without having to convert it to string() first)
(Yegappan Lakshmanan)
fixes: #14529
closes: #14541
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/eval.c b/src/eval.c
index e4c8bae..d81ef17 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -575,7 +575,8 @@
/*
* Convert "tv" to a string.
- * When "convert" is TRUE convert a List into a sequence of lines.
+ * When "convert" is TRUE convert a List into a sequence of lines and a Dict
+ * into a textual representation of the Dict.
* Returns an allocated string (NULL when out of memory).
*/
char_u *
@@ -596,6 +597,8 @@
ga_append(&ga, NUL);
retval = (char_u *)ga.ga_data;
}
+ else if (convert && tv->v_type == VAR_DICT)
+ retval = dict2string(tv, get_copyID(), FALSE);
else
retval = vim_strsave(tv_get_string(tv));
return retval;