Home Bug Reports

exception specification error in slice2cs

hello everyone

the slice:


exception A {
string reason;
};

exception B extends A {};

class Test
{
void foo() throws B, A;
}

I need code is follow:

...
catch(B ex)
{
... }
catch(A ex)
{
.. }

but the code that was generate by slice2cs is:

...
catch(A ex)
{
... }
catch(B ex)
{
.. }


then build error CS0160.

please check this bug, thanks.

Comments

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    Patch available

    Thanks for the bug report!

    I've posted a patch in the Patches forum.

    Note that you can avoid the problem entirely by not mentioning a base exception and one ore more of its derived exceptions in an exception specification. For example, for your Slice definitions:
    exception A {
        string reason;
    };
    
    exception B extends A {};
    
    class Test
    {
       void foo() throws A; // No need to mention B here, because a B "is-a" A.
    }
    

    The next release of Icicle will have this fixed of course, or you can apply the patch now, or you can not apply the patch and just delete the derived exception from the exception specification.

    Cheers,

    Michi.
Sign In or Register to comment.