[Coldstuff] set_method_access bug in genesis

Brad Roberts coldstuff@cold.org
Thu, 21 Mar 2002 19:11:51 -0800 (PST)


You're correct, both of those cthrows() should be turned into THROW()s.

Index: object.c
===================================================================
RCS file: /cvsroot/cold/genesis/src/ops/object.c,v
retrieving revision 1.22.2.1
diff -u -r1.22.2.1 object.c
--- object.c    10 Jan 2002 03:39:39 -0000      1.22.2.1
+++ object.c    22 Mar 2002 03:07:54 -0000
@@ -399,12 +399,12 @@
     else if (sym == frob_id)
         access = MS_FROB;
     else
-        cthrow(type_id, "Invalid method access flag.");
+        THROW((type_id, "Invalid method access flag."));

     access = object_set_method_access(cur_frame->object, SYM1, access);

     if (access == -1)
-        cthrow(type_id, "Method %I not found.", SYM1);
+        THROW((type_id, "Method %I not found.", SYM1));

     pop(2);
     push_int(access);

This diff is against 1.1.9, but it should apply fine to 1.1.10 also.  I've
not extensively (ok, I ran the test suite, which doesn't actually test set
method access at all).  But I'm 99.9% sure this is the right thing to do.
I'll make sure that Bruce includes this in 1.1.11 when he puts it out.

Good catch.

Also, worth noting that, if my memory holds correctly, nested catches in
the same method doesn't work.  Or is it that a throw() won't be caught by
the catch block that it's in?  I forget exactly and don't have time right
now to try a few tests to remind myself what the issue is.

Later,
Brad

On Thu, 21 Mar 2002 pvx@wmute.net wrote:

> Date: Thu, 21 Mar 2002 21:05:56 -0500
> From: pvx@wmute.net
> Reply-To: coldstuff@cold.org
> To: cold-coldstuff@cold.org
> Subject: [Coldstuff] set_method_access bug in genesis
>
> There's a bug in set_method_access in Genesis which is causing errors to propagate incorrectly:
>
> ;catch any { catch any { .set_method_access('bad_method_name, 'bad_access_type); } with { return 'should_get_this; } } with { return 'should_not_get_this; }
> => 'should_not_get_this
>
> The problem is that COLDC_FUNC(set_method_access) in ops/object.c will call cthrow() twice if you supply both a bad method name and a bad access type.  I'd assume a fix would be as simple as replacing the cthrow()s with THROW()s, although somebody who's more familiar with Genesis should verify this as I'm not sure why the non-returning cthrow() is ever used in the first place.
> _______________________________________________
> Cold-Coldstuff mailing list
> Cold-Coldstuff@cold.org
> http://web.cold.org/mailman/listinfo/cold-coldstuff
>