diff src/vim9class.c @ 34709:a1d0ef54a24b v9.1.0233

patch 9.1.0233: Vim9: string() output of enum is problematic Commit: https://github.com/vim/vim/commit/3cf121ed31f7a022e2ae6585391434d9c88e9792 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Mar 31 18:45:35 2024 +0200 patch 9.1.0233: Vim9: string() output of enum is problematic Problem: Vim9: string() output of enum is problematic Solution: Make string() output for an enum consistent with that of a regular object (Yegappan Lakshmanan). closes: #14343 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 31 Mar 2024 19:00:02 +0200
parents ad86d59d7510
children d4fb6ea26ae4
line wrap: on
line diff
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -3844,16 +3844,18 @@ object_string(
 	class_T *cl = obj == NULL ? NULL : obj->obj_class;
 	if (cl != NULL && IS_ENUM(cl))
 	{
+	    ga_concat(&ga, (char_u *)"enum ");
 	    ga_concat(&ga, cl->class_name);
-	    char_u *name = ((typval_T *)(obj + 1))->vval.v_string;
+	    char_u *enum_name = ((typval_T *)(obj + 1))->vval.v_string;
 	    ga_concat(&ga, (char_u *)".");
-	    ga_concat(&ga, name);
-	    return ga.ga_data;
+	    ga_concat(&ga, enum_name);
 	}
-
-	ga_concat(&ga, (char_u *)"object of ");
-	ga_concat(&ga, cl == NULL ? (char_u *)"[unknown]"
-		: cl->class_name);
+	else
+	{
+	    ga_concat(&ga, (char_u *)"object of ");
+	    ga_concat(&ga, cl == NULL ? (char_u *)"[unknown]"
+		    : cl->class_name);
+	}
 	if (cl != NULL)
 	{
 	    ga_concat(&ga, (char_u *)" {");