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.


Compiler implementation of the D programming language.

Source typesem.d

Expression typeToExpression(Type t);
We've mistakenly parsed t as a type. Redo t as an Expression.
Type t mistaken type
t redone as Expression, null if cannot
Type typeSemantic(Type t, Loc loc, Scope* sc);
Perform semantic analysis on a type.
Type t Type AST node
Loc loc the location of the type
Scope* sc context
Type with completed semantic analysis, Terror if errors were encountered
RootObject compileTypeMixin(TypeMixin tm, Loc loc, Scope* sc);
Compile the MixinType, returning the type or expression AST.
Doesn't run semantic() on the returned object.
TypeMixin tm mixin to compile as a type or expression
Loc loc location for error messages
Scope* sc context

Return null if error, else RootObject AST as parsed

Type merge(Type type);
If an identical type to type is in type.stringtable, return the latter one. Otherwise, add it to type.stringtable. Some types don't get merged and are returned as-is.
Type type Type to check against existing types
the type that was merged
Expression getProperty(Type t, ref const Loc loc, Identifier ident, int flag);
Calculate built-in properties which just the type is necessary.
Type t the type for which the property is calculated
Loc loc the location where the property is encountered
Identifier ident the identifier of the property
int flag if flag & 1, don't report "not a property" error and just return NULL.
expression representing the property, or null if not a property and (flag & 1)
void resolve(Type mt, ref const Loc loc, Scope* sc, Expression* pe, Type* pt, Dsymbol* ps, bool intypeid = false);
Resolve type 'mt' to either type, symbol, or expression. If errors happened, resolved to Type.terror.
Type mt type to be resolved
Loc loc the location where the type is encountered
Scope* sc the scope of the type
Expression* pe is set if t is an expression
Type* pt is set if t is a type
Dsymbol* ps is set if t is a symbol
bool intypeid true if in type id
Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag);
Access the members of the object e. This type is same as e.type.
Type mt type for which the dot expression is used
Scope* sc instantiating scope
Expression e expression to convert
Identifier ident identifier being used
int flag DotExpFlag bit flags
resulting expression with e.ident resolved
Expression defaultInit(Type mt, ref const Loc loc);
Get the the default initialization expression for a type.
Type mt the type for which the init expression is returned
Loc loc the location where the expression needs to be evaluated
The initialization expression for the type.