Thread overview
cannot go into try block
Jan 22, 2002
Mike Wynn
Jan 22, 2002
Walter
January 22, 2002
The following will not compile, it give the followig error : cannot goto into try block

class Test
{
 Object o;
 int c;

 Object failToCompile(  )
 {
  if ( o == null )
  {
   try
   {
    if ( c < 33 )


     if ( c == 0 ) { return null; }
    }
   }
   catch ( Exception e )
   {
   }
  }
  return o;
 }
}

curiously removing the if ( c== 0) allows it to compile, and in this
example removing the if (o==null) does not but in the original code (which
was more complex) it did.

as an aside, commenting out the return does not give a 'this function has a
missing return value' but this error
: cannot goto forward into different try block level
as opposed to
: failToCompile function expected to return a value of type Object

only seems to occur in member functions. if its not a member function then removing the return will result in it compiling without error.

I have to admit to being confused by the error message I assume it internal exception stuff or have I totally missed the meaning of the error message.

Mike.


January 22, 2002
Ok, I'll check into it. Thanks! -Walter

"Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message news:a2kqin$qp8$1@digitaldaemon.com...
> The following will not compile, it give the followig error : cannot goto into try block
>
> class Test
> {
>  Object o;
>  int c;
>
>  Object failToCompile(  )
>  {
>   if ( o == null )
>   {
>    try
>    {
>     if ( c < 33 )
>
>
>      if ( c == 0 ) { return null; }
>     }
>    }
>    catch ( Exception e )
>    {
>    }
>   }
>   return o;
>  }
> }
>
> curiously removing the if ( c== 0) allows it to compile, and in this
> example removing the if (o==null) does not but in the original code (which
> was more complex) it did.
>
> as an aside, commenting out the return does not give a 'this function has
a
> missing return value' but this error
> : cannot goto forward into different try block level
> as opposed to
> : failToCompile function expected to return a value of type Object
>
> only seems to occur in member functions. if its not a member function then removing the return will result in it compiling without error.
>
> I have to admit to being confused by the error message I assume it
internal
> exception stuff or have I totally missed the meaning of the error message.
>
> Mike.
>
>


January 30, 2002
This problem could be resolved so:

[dmd\src\phobos\object.d]
remove line: "extern (C) static int printf(char *, ...);"
add    line: "import c.stdio;"

Then everything works OK. =]

How do think?

Walter wrote:

> Ok, I'll check into it. Thanks! -Walter
> 
> "Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message
> news:a2kqin$qp8$1@digitaldaemon.com...
> 
>>The following will not compile, it give the followig error
>>: cannot goto into try block
>>
>>class Test
>>{
>> Object o;
>> int c;
>>
>> Object failToCompile(  )
>> {
>>  if ( o == null )
>>  {
>>   try
>>   {
>>    if ( c < 33 )
>>
>>
>>     if ( c == 0 ) { return null; }
>>    }
>>   }
>>   catch ( Exception e )
>>   {
>>   }
>>  }
>>  return o;
>> }
>>}
>>
>>curiously removing the if ( c== 0) allows it to compile, and in this
>>example removing the if (o==null) does not but in the original code (which
>>was more complex) it did.
>>
>>as an aside, commenting out the return does not give a 'this function has
>>
> a
> 
>>missing return value' but this error
>>: cannot goto forward into different try block level
>>as opposed to
>>: failToCompile function expected to return a value of type Object
>>
>>only seems to occur in member functions. if its not a member function then
>>removing the return will result in it compiling without error.
>>
>>I have to admit to being confused by the error message I assume it
>>
> internal
> 
>>exception stuff or have I totally missed the meaning of the error message.
>>
>>Mike.
>>
>>
>>
> 
>