Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.


Does semantic analysis for functions.

Specification Functions


Source funcsem.d

void funcDeclarationSemantic(Scope* sc, FuncDeclaration funcdecl);
Main semantic routine for functions.
bool functionSemantic(FuncDeclaration fd);
Resolve forward reference of function signature - parameter types, return type, and attributes.
FuncDeclaration fd function declaration
false if any errors exist in the signature.
bool functionSemantic3(FuncDeclaration fd);
Resolve forward reference of function body. Returns false if any errors exist in the body.
void declareThis(FuncDeclaration fd, Scope* sc);
Creates and returns the hidden parameters for this function declaration.
Hidden parameters include the this parameter of a class, struct or nested function and the selector parameter for Objective-C methods.
bool checkForwardRef(FuncDeclaration fd, const ref Loc loc);
Check that this function type is properly resolved. If not, report "forward reference error" and return true.
int findVtblIndex(FuncDeclaration fd, Dsymbol[] vtbl);
Find index of function in vtbl[0..length] that this function overrides. Prefer an exact match to a covariant one.
FuncDeclaration fd function
Dsymbol[] vtbl vtable to use
-1 didn't find one -2 can't determine because of forward references
BaseClass* overrideInterface(FuncDeclaration fd);
If function is a function in a base class, return that base class.
FuncDeclaration fd function
base class if overriding, null if not
enum FuncResolveFlag: ubyte;
Flag used by resolveFuncCall.
issue error messages, solve the call.
do not issue error message on no match, just return null.
only resolve overloads, i.e. do not issue error on ambiguous
matches and need explicit this.
trying to resolve UFCS call
FuncDeclaration resolveFuncCall(const ref Loc loc, Scope* sc, Dsymbol s, Objects* tiargs, Type tthis, ArgumentList argumentList, FuncResolveFlag flags);
Given a symbol that could be either a FuncDeclaration or a function template, resolve it to a function symbol.
Loc loc instantiation location
Scope* sc instantiation scope
Dsymbol s instantiation symbol
Objects* tiargs initial list of template arguments
Type tthis if !NULL, the this argument type
ArgumentList argumentList arguments to function
FuncResolveFlag flags see FuncResolveFlag.
if match is found, then function symbol, else null
Expression addInvariant(AggregateDeclaration ad, VarDeclaration vthis);
Generate Expression to call the invariant.

Input ad aggregate with the invariant vthis variable with 'this'

void expression that calls the invariant
void buildResultVar(FuncDeclaration fd, Scope* sc, Type tret);
Declare result variable lazily.