compiler: open byte slice and string embeds using the absolute path
The paths vector contains the names of the files that the embed_files_
map is keyed by. While the code processing embed.FS values looks up
the paths in the embed_files_ map, the code processing string and byte
slice embeds tries opening the files using their names directly. Look
up the full paths in the embed_files_ map when opening them.
Change-Id: I8224a0a2d490be490fcfa0cf5a1cf6a5a7cfc278
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/291429
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/go/embed.cc b/go/embed.cc
index bea1003..0a7df05 100644
--- a/go/embed.cc
+++ b/go/embed.cc
@@ -812,8 +812,7 @@
}
// Each pattern in the embedcfg file maps to a list of file
- // names. For each file name, the embedcfg file records an
- // absolute path. Add those absolute paths to PATHS.
+ // names. Add those file names to PATHS.
for (std::vector<std::string>::const_iterator pf = pp->second.begin();
pf != pp->second.end();
pf++)
@@ -865,7 +864,7 @@
}
std::string data;
- if (!read_file(paths[0].c_str(), loc, &data))
+ if (!read_file(this->embed_files_[paths[0]].c_str(), loc, &data))
return Expression::make_error(loc);
Expression* e = Expression::make_string(data, loc);