Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 630:bc83491463f0

Show
Ignore:
Timestamp:
10/01/08 15:14:15 (2 months ago)
Author:
Christian Kamm <kamm incasoftware de>
branch:
default
Message:

Nicer error message on some invalid default args.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmd/mtype.c

    r599 r630  
    29352935        arg->defaultArg = resolveProperties(sc, arg->defaultArg); 
    29362936        arg->defaultArg = arg->defaultArg->implicitCastTo(sc, arg->type); 
     2937 
     2938        // make sure default arguments only use variables with lower protection 
     2939        // this check only catches the common case that the default arg Exp is a VarExp 
     2940        if(arg->defaultArg->op == TOKvar) 
     2941        {   VarExp *ve = (VarExp *)arg->defaultArg; 
     2942            if(ve->var->protection < sc->protection) 
     2943            error(loc, "default argument %s has stronger protection than function %s", ve->var->toChars(), toChars()); 
     2944        } 
    29372945        } 
    29382946 
Copyright © 2008, LDC Development Team.