Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: src/ast/modules.cc

Issue 2451153002: [modules] Improve error messages. (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/modules.h ('k') | src/ast/scopeinfo.cc » ('j') | src/objects.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/modules.cc
diff --git a/src/ast/modules.cc b/src/ast/modules.cc
index 2d28d5564b546b01ea1b2ab5bd3eb56b6572b379..6b527de1f568b8c408cdd11d5d6a0abf1fc75aeb 100644
--- a/src/ast/modules.cc
+++ b/src/ast/modules.cc
@@ -88,7 +88,8 @@ Handle<ModuleInfoEntry> ModuleDescriptor::Entry::Serialize(
isolate, ToStringOrUndefined(isolate, export_name),
ToStringOrUndefined(isolate, local_name),
ToStringOrUndefined(isolate, import_name),
- Handle<Object>(Smi::FromInt(module_request), isolate));
+ Handle<Object>(Smi::FromInt(module_request), isolate),
+ location.beg_pos, location.end_pos);
}
ModuleDescriptor::Entry* ModuleDescriptor::Entry::Deserialize(
@@ -184,6 +185,14 @@ void ModuleDescriptor::MakeIndirectExportsExplicit(Zone* zone) {
static_cast<int>(module_requests_.size()));
entry->import_name = import->second->import_name;
entry->module_request = import->second->module_request;
+ // Hack: When the indirect export cannot be resolved, we want the error
+ // message to point at the import statement, not at the export statement.
+ // Therefore we overwrite [entry]'s location here. Note that Validate()
+ // has already checked for duplicate exports, so it's guaranteed that we
+ // won't need to report any error pointing at the (now lost) export
+ // location.
+ entry->location.beg_pos = import->second->location.beg_pos;
adamk 2016/10/26 12:38:16 Why can't you just assign the location directly?
+ entry->location.end_pos = import->second->location.end_pos;
entry->local_name = nullptr;
AddSpecialExport(entry, zone);
it = regular_exports_.erase(it);
« no previous file with comments | « src/ast/modules.h ('k') | src/ast/scopeinfo.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698