No more error message : Do not return in body of try

I pulled my hair yesterday because there was no error reported anymore. When I ran nil.bla the post window show nothing at all.

Then I found today it was this code in a class of mine:

try {
   ^val
} {
   "error".postln
}

just replacing with

^try {
   val
} {
   "error".postln
}

solve the problem.

Would be nice if a warning was added to the try documentation.

By the way, i think the documentation for try is hard to find. when you search “try” in help browser, you only get the function documentation which does not tell the syntax and there no link to the Exception documentation where everything is explained. The help page “Control Structures” does not mention it either, but I think it’s a good place to quickly show the syntax and link to the Exception help page

I’m not sure how the compiler could check for that. try is formally not a control structure – it’s a normal method call, with a function as the receiver and another function as an argument I’m pretty sure there’s no special case for it in the compiler.

Perhaps one could be added – you could file a feature request.

Agreed that documentation could be improved – such as, adding links into the method help.

hjh

My apologies, the documentation is clear, it is stated just a bit higher in the help file.

For the following two methods a return ^ inside of the receiver itself cannot be caught. Returns in methods called by the receiver are OK.