Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions compiler/src/dmd/typinf.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import dmd.dscope;
import dmd.dclass;
import dmd.dstruct;
import dmd.errors;
import dmd.errorsink;
import dmd.expression;
import dmd.hdrgen : toErrMsg;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this import needed? it seems unused.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toErrMsg is imported into dmd.errors. I think it should be imported from where it came from.

import dmd.location;
import dmd.mtype;
import dmd.templatesem;
Expand All @@ -40,6 +42,8 @@ import core.stdc.stdio;
bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc)
{
// printf("genTypeInfo() %s\n", torig.toChars());
import dmd.globals : global;
auto eSink = global.errorSink;

// Even when compiling without `useTypeInfo` (e.g. -betterC) we should
// still be able to evaluate `TypeInfo` at compile-time, just not at runtime.
Expand All @@ -51,9 +55,9 @@ bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc)
{
global.gag = 0;
if (e)
.error(loc, "expression `%s` uses the GC and cannot be used with switch `-betterC`", e.toErrMsg());
eSink.error(loc, "expression `%s` uses the GC and cannot be used with switch `-betterC`", e.toErrMsg());
else
.error(loc, "`TypeInfo` cannot be used with `-betterC`");
eSink.error(loc, "`TypeInfo` cannot be used with `-betterC`");

if (sc && sc.tinst)
sc.tinst.printInstantiationTrace(Classification.error, uint.max);
Expand All @@ -64,7 +68,7 @@ bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc)

if (!Type.dtypeinfo)
{
.error(loc, "`object.TypeInfo` could not be found, but is implicitly used");
eSink.error(loc, "`object.TypeInfo` could not be found, but is implicitly used");
fatal();
}

Expand Down
Loading