Skip to content

Commit

Permalink
fix: Fix import path for std libs not being reflected in error
Browse files Browse the repository at this point in the history
  • Loading branch information
alinalihassan committed May 7, 2022
1 parent b2a9892 commit 3a82f97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/liblesma/Backend/Codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ std::unique_ptr<llvm::TargetMachine> Codegen::InitializeTargetMachine() {
void Codegen::CompileModule(Span span, const std::string &filepath, bool isStd) {
std::filesystem::path mainPath = filename;
// Read source
auto source = readFile(isStd ? filepath : fmt::format("{}/{}", std::filesystem::absolute(mainPath).parent_path().c_str(), filepath));
auto absolute_path = isStd ? filepath : fmt::format("{}/{}", std::filesystem::absolute(mainPath).parent_path().c_str(), filepath);
auto source = readFile(absolute_path);

try {
// Lexer
Expand Down Expand Up @@ -117,7 +118,7 @@ void Codegen::CompileModule(Span span, const std::string &filepath, bool isStd)
if (err.getSpan() == Span{})
print(ERROR, err.what());
else
showInline(err.getSpan(), err.what(), fmt::format("{}/{}", std::filesystem::absolute(mainPath).parent_path().c_str(), filepath), true);
showInline(err.getSpan(), err.what(), absolute_path, true);

throw CodegenError(span, "Unable to import {} due to errors", filepath);
}
Expand Down

0 comments on commit 3a82f97

Please sign in to comment.