[Nice-commit] Nice/src/bossa/syntax typecheck.nice,1.53,1.54
Brought to you by:
bonniot
|
From: <bo...@us...> - 2003-03-12 12:07:41
|
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv17433/src/bossa/syntax
Modified Files:
typecheck.nice
Log Message:
Fix assignment to possibly null in a nested context of non-null tests.
Index: typecheck.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** typecheck.nice 12 Mar 2003 03:26:36 -0000 1.53
--- typecheck.nice 12 Mar 2003 12:07:38 -0000 1.54
***************
*** 53,57 ****
variable.setVarType(now: unsureType,
otherBranch: variable.type,
! out: unsureType);
return;
}
--- 53,57 ----
variable.setVarType(now: unsureType,
otherBranch: variable.type,
! overrideOut: unsureType);
return;
}
***************
*** 335,338 ****
--- 335,349 ----
}
+ void overrideOuterType(MonoSymbol variable, mlsub.typing.Monotype newType)
+ {
+ for (int i = 0; i < levels.size(); i++)
+ if (levels.get(i) % 2 == 1)
+ {
+ (MonoSymbol v, mlsub.typing.Monotype t) = conditionalTypes.get(i);
+ if (variable == v)
+ conditionalTypes.set(i, (variable, newType));
+ }
+ }
+
typecheck(e@IfExp)
{
***************
*** 405,415 ****
@param otherBranch type to be used in the other branches
@param out type to be used after returning to the outer block
*/
private void setVarType(MonoSymbol variable,
mlsub.typing.Monotype now,
?mlsub.typing.Monotype otherBranch = null,
! ?mlsub.typing.Monotype out = null)
{
variable.type = now;
if (out != null)
pushOuterType(variable, out);
--- 416,435 ----
@param otherBranch type to be used in the other branches
@param out type to be used after returning to the outer block
+ @param overrideOut use that type when exiting all englobing blocks
*/
private void setVarType(MonoSymbol variable,
mlsub.typing.Monotype now,
?mlsub.typing.Monotype otherBranch = null,
! ?mlsub.typing.Monotype out = null,
! ?mlsub.typing.Monotype overrideOut = null)
{
variable.type = now;
+ if (overrideOut != null)
+ {
+ overrideOuterType(variable, overrideOut);
+ // We also set it for the current block, in case there was no previous
+ // type set.
+ pushOuterType(variable, overrideOut);
+ }
if (out != null)
pushOuterType(variable, out);
|