Fix bug where the STInterpreterReturnException was not handled when a

block returns nil.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@36426 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2013-03-25 11:32:20 +00:00
parent b7a0150e02
commit ac8fc9cbb6
2 changed files with 9 additions and 6 deletions

View file

@ -1,3 +1,8 @@
2013-03-25 Wolfgang Lux <wolfgang.lux@gmail.com>
* STBytecodeInterpreter.m (returnValue:): Fix bug where the
STInterpreterReturnException was not handled when a block returns nil.
2013-03-24 Wolfgang Lux <wolfgang.lux@gmail.com>
* STCompiler.m (-compileMethod:): Follow Smalltalk convention to

View file

@ -296,25 +296,23 @@ static Class NSInvocation_class = nil;
@"%@ return value '%@' from method",
activeContext,value);
[activeContext invalidate];
if (activeContext != [activeContext homeContext])
{
NSDictionary *userInfo;
/* Don't try to optimize this code by invalidating the context before
the conditional. The method -invalidate resets the home context of
a block and hence the test above would always fail. */
/* FIXME Invalidate all contexts between the active context and the
home context as well. Note that the semantics presented in the
Blue Book doesn't get this right either. */
userInfo =
[NSDictionary dictionaryWithObjectsAndKeys:
value, @"Value", [activeContext homeContext], @"Context", nil];
[activeContext invalidate];
/* Attention: Order is important here. The returned value
may be nil, so the context value must come first. */
[activeContext homeContext], @"Context", value, @"Value", nil];
[[NSException exceptionWithName:STInterpreterReturnException
reason:@"Block cannot return"
userInfo:userInfo] raise];
}
[activeContext invalidate];
[stack push:value];
}