Skip to content

Commit

Permalink
expressionsem: Remove redundant dependency to dmd.root.file (#15083)
Browse files Browse the repository at this point in the history
FileManager.lookup will already attempt to read the file if it is not cached,
and will insert it in the list of files if it manages to read it,
so only the 'if (!readResult.success)' branch was reachable.
This in turn allows us to remove expressionsem's dependency
to dmd.root.file.
  • Loading branch information
Geod24 authored Apr 6, 2023
1 parent 4a7f82a commit 0775845
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import dmd.parse;
import dmd.printast;
import dmd.root.array;
import dmd.root.ctfloat;
import dmd.root.file;
import dmd.root.filename;
import dmd.common.outbuffer;
import dmd.root.rootobject;
Expand Down Expand Up @@ -6318,19 +6317,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
else
{
auto readResult = File.read(resolvedNamez);
if (!readResult.success)
{
e.error("cannot read file `%s`", resolvedNamez.ptr);
return setError();
}
else
{
// take ownership of buffer (probably leaking)
auto data = readResult.extractSlice();
se = new StringExp(e.loc, data);
global.fileManager.add(fileName, data);
}
e.error("cannot read file `%s`", resolvedNamez.ptr);
return setError();
}
}
result = se.expressionSemantic(sc);
Expand Down

0 comments on commit 0775845

Please sign in to comment.