diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-26 11:43:17 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-26 11:43:17 +0100 |
| commit | ae25787f48f4190a90428228c22faf6ae22d7365 (patch) | |
| tree | fb4e9d5be16b4cb2fdf7a152dd86d9851ffdaf0a /src/parser.cpp | |
| parent | 08dc829b70ffacc5a3f4db6831b08dcd6e89aa78 (diff) | |
Fix syntax error for a missing package name
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index b22d063d2..fcc8078f7 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -5428,8 +5428,14 @@ ParseFileError process_imported_file(Parser *p, ImportedFile const &imported_fil if (pkg->name.len == 0) { pkg->name = file->package_name; - } else if (file->tokens.count > 0 && pkg->name != file->package_name) { - syntax_error(file->package_token, "Different package name, expected '%.*s', got '%.*s'", LIT(pkg->name), LIT(file->package_name)); + } else if (pkg->name != file->package_name) { + if (file->tokens.count > 0 && file->tokens[0].kind != Token_EOF) { + Token tok = file->package_token; + tok.pos.file_id = file->id; + tok.pos.line = gb_max(tok.pos.line, 1); + tok.pos.column = gb_max(tok.pos.column, 1); + syntax_error(tok, "Different package name, expected '%.*s', got '%.*s'", LIT(pkg->name), LIT(file->package_name)); + } } p->total_line_count += file->tokenizer.line_count; |