Thread overview | |||||
---|---|---|---|---|---|
|
January 22, 2002 cannot go into try block | ||||
---|---|---|---|---|
| ||||
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 Re: cannot go into try block | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wynn | 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 Re: cannot go into try block | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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.
>>
>>
>>
>
>
|
Copyright © 1999-2021 by the D Language Foundation