# HG changeset patch # User Tomas Lindquist Olsen # Date 1222895856 -7200 # Node ID d208fc4291df8ee693704c0b80f521bd65d8d1e9 # Parent df196c8dea26768df39604edc88a5981a2c00ded# Parent 9fcb5f1a4c54640e499eaa96fc3db4b0a6815324 merge diff -r df196c8dea26 -r d208fc4291df dmd/mtype.c --- a/dmd/mtype.c Wed Oct 01 23:17:14 2008 +0200 +++ b/dmd/mtype.c Wed Oct 01 23:17:36 2008 +0200 @@ -2934,6 +2934,14 @@ 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