Commit 880bbbbe authored by Kenton Varda's avatar Kenton Varda

Don't report missing file ID error after parse error.

Fixes #251
parent 559a592b
...@@ -172,11 +172,17 @@ void parseFile(List<Statement>::Reader statements, ParsedFile::Builder result, ...@@ -172,11 +172,17 @@ void parseFile(List<Statement>::Reader statements, ParsedFile::Builder result,
} }
if (fileDecl.getId().which() != Declaration::Id::UID) { if (fileDecl.getId().which() != Declaration::Id::UID) {
// We didn't see an ID. Generate one randomly for now.
uint64_t id = generateRandomId(); uint64_t id = generateRandomId();
fileDecl.getId().initUid().setValue(id); fileDecl.getId().initUid().setValue(id);
errorReporter.addError(0, 0,
kj::str("File does not declare an ID. I've generated one for you. Add this line to your " // Don't report missing ID if there was a parse error, because quite often the parse error
"file: @0x", kj::hex(id), ";")); // prevents us from parsing the ID even though it is actually there.
if (!errorReporter.hadErrors()) {
errorReporter.addError(0, 0,
kj::str("File does not declare an ID. I've generated one for you. Add this line to "
"your file: @0x", kj::hex(id), ";"));
}
} }
auto declsBuilder = fileDecl.initNestedDecls(decls.size()); auto declsBuilder = fileDecl.initNestedDecls(decls.size());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment