This commit is contained in:
Tomas Lindquist Olsen
2008-10-01 23:17:36 +02:00

View File

@@ -2934,6 +2934,14 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc)
arg->defaultArg = arg->defaultArg->semantic(sc);
arg->defaultArg = resolveProperties(sc, arg->defaultArg);
arg->defaultArg = arg->defaultArg->implicitCastTo(sc, arg->type);
// make sure default arguments only use variables with lower protection
// this check only catches the common case that the default arg Exp is a VarExp
if(arg->defaultArg->op == TOKvar)
{ VarExp *ve = (VarExp *)arg->defaultArg;
if(ve->var->protection < sc->protection)
error(loc, "default argument %s has stronger protection than function %s", ve->var->toChars(), toChars());
}
}
/* If arg turns out to be a tuple, the number of parameters may