vim9script
def X()
var x = null_object
echom x
enddef
X()
Bisecting indicates
3164cf8
date: Thu Mar 28 10:36:42 2024 +0100
summary: patch 9.1.0219: Vim9: No enum support
No exception, error message like
E1324: Using an Object as a String
Not all uses of null_object have this problem
9.1.611
ubuntu gtk3
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
FYI, I'm in the middle of some stuff, including cleanup after trying to track this down. So not sure when I'll be able to take a look. If someone starts looking, leaving a note would help.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Thanks. This one should fix it:
diff --git a/src/typval.c b/src/typval.c index 67c819f0a..e50e96af0 100644 --- a/src/typval.c +++ b/src/typval.c @@ -267,11 +267,16 @@ tv_get_bool_or_number_chk( break; case VAR_OBJECT: { - class_T *cl = varp->vval.v_object->obj_class; - if (cl != NULL && IS_ENUM(cl)) - semsg(_(e_using_enum_str_as_number), cl->class_name); + if (varp->vval.v_object == NULL) + emsg(_(e_using_object_as_string)); else - emsg(_(e_using_object_as_number)); + { + class_T *cl = varp->vval.v_object->obj_class; + if (cl != NULL && IS_ENUM(cl)) + semsg(_(e_using_enum_str_as_number), cl->class_name); + else + emsg(_(e_using_object_as_number)); + } } break; case VAR_VOID: @@ -1146,11 +1151,16 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict) break; case VAR_OBJECT: { - class_T *cl = varp->vval.v_object->obj_class; - if (cl != NULL && IS_ENUM(cl)) - semsg(_(e_using_enum_str_as_string), cl->class_name); - else + if (varp->vval.v_object == NULL) emsg(_(e_using_object_as_string)); + else + { + class_T *cl = varp->vval.v_object->obj_class; + if (cl != NULL && IS_ENUM(cl)) + semsg(_(e_using_enum_str_as_string), cl->class_name); + else + emsg(_(e_using_object_as_string)); + } } break; case VAR_JOB:
Haven't yet created a proper PR with a test case yet.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@chrisbra I tried your fix and of course it took care of the OP case. But it didn't take care of the original problem I ran into. Tracking down the original problem, I ran into 3 (count 'em, three) SEGV cases; see below. I've got them fixed and I'm putting together a PR with these fixes and your typval.c fixes. The OP case is fixed (generated an error) with the change around line 1146. I couldn't find a test for the change around line 267, any ideas?; it looks like this case might be triggered where vim9script wants to do an automatic string to int conversion, but I'm not seeing where this happens. BTW, the error reported for the line 1146 case displays the wrong line number.
I'll open a PR with both sets of fixes and some tests. (except for that missing one).
vim9script
def Z()
var o: any = null_object
o.v = 4
enddef
#Z() # SEGV
class C0
def F()
enddef
endclass
class C extends C0
endclass
def X()
var o: C0 = null_object
o.F()
enddef
#X() # SEGV
def Y()
var o: C0 = null_object
var XXX = o.F
enddef
#Y() # SEGV
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Closed #15338 as completed via be82825.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.