mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 08:33:15 +00:00
stage2: omit Decl compile errors from failed AstGen files
Just like when new parse errors occur during an update, when new AstGen errors occur during an update, we do not reveal compile errors for Decl objects which are inside of a newly failed File. Once the File passes AstGen successfully, it will be compared with the previously succeeded ZIR and the saved Decl compile errors will be handled properly.
This commit is contained in:
parent
dc036f5b6f
commit
7cd94d2123
@ -1696,17 +1696,15 @@ pub fn totalErrorCount(self: *Compilation) usize {
|
||||
// the previous parse success, including compile errors, but we cannot
|
||||
// emit them until the file succeeds parsing.
|
||||
for (module.failed_decls.items()) |entry| {
|
||||
if (entry.key.namespace.file_scope.status == .parse_failure) {
|
||||
continue;
|
||||
if (entry.key.namespace.file_scope.okToReportErrors()) {
|
||||
total += 1;
|
||||
}
|
||||
total += 1;
|
||||
}
|
||||
if (module.emit_h) |emit_h| {
|
||||
for (emit_h.failed_decls.items()) |entry| {
|
||||
if (entry.key.namespace.file_scope.status == .parse_failure) {
|
||||
continue;
|
||||
if (entry.key.namespace.file_scope.okToReportErrors()) {
|
||||
total += 1;
|
||||
}
|
||||
total += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1767,21 +1765,19 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {
|
||||
}
|
||||
}
|
||||
for (module.failed_decls.items()) |entry| {
|
||||
if (entry.key.namespace.file_scope.status == .parse_failure) {
|
||||
// Skip errors for Decls within files that had a parse failure.
|
||||
// We'll try again once parsing succeeds.
|
||||
continue;
|
||||
// Skip errors for Decls within files that had a parse failure.
|
||||
// We'll try again once parsing succeeds.
|
||||
if (entry.key.namespace.file_scope.okToReportErrors()) {
|
||||
try AllErrors.add(module, &arena, &errors, entry.value.*);
|
||||
}
|
||||
try AllErrors.add(module, &arena, &errors, entry.value.*);
|
||||
}
|
||||
if (module.emit_h) |emit_h| {
|
||||
for (emit_h.failed_decls.items()) |entry| {
|
||||
if (entry.key.namespace.file_scope.status == .parse_failure) {
|
||||
// Skip errors for Decls within files that had a parse failure.
|
||||
// We'll try again once parsing succeeds.
|
||||
continue;
|
||||
// Skip errors for Decls within files that had a parse failure.
|
||||
// We'll try again once parsing succeeds.
|
||||
if (entry.key.namespace.file_scope.okToReportErrors()) {
|
||||
try AllErrors.add(module, &arena, &errors, entry.value.*);
|
||||
}
|
||||
try AllErrors.add(module, &arena, &errors, entry.value.*);
|
||||
}
|
||||
}
|
||||
for (module.failed_exports.items()) |entry| {
|
||||
|
||||
@ -1138,6 +1138,13 @@ pub const Scope = struct {
|
||||
const loc = std.zig.findLineColumn(file.source.bytes, src);
|
||||
std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 });
|
||||
}
|
||||
|
||||
pub fn okToReportErrors(file: File) bool {
|
||||
return switch (file.status) {
|
||||
.parse_failure, .astgen_failure => false,
|
||||
else => true,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/// This is the context needed to semantically analyze ZIR instructions and
|
||||
|
||||
@ -1225,7 +1225,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
{
|
||||
var case = ctx.obj("variable shadowing", linux_x64);
|
||||
case.addError(
|
||||
\\pub export fn _start() noreturn {
|
||||
\\export fn _start() noreturn {
|
||||
\\ var i: u32 = 10;
|
||||
\\ var i: u32 = 10;
|
||||
\\ unreachable;
|
||||
@ -1251,7 +1251,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
var case = ctx.obj("@compileLog", linux_x64);
|
||||
// The other compile error prevents emission of a "found compile log" statement.
|
||||
case.addError(
|
||||
\\pub export fn _start() noreturn {
|
||||
\\export fn _start() noreturn {
|
||||
\\ const b = true;
|
||||
\\ var f: u32 = 1;
|
||||
\\ @compileLog(b, 20, f, x);
|
||||
@ -1293,10 +1293,9 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ _ = foo;
|
||||
\\}
|
||||
\\extern var foo: i32;
|
||||
\\pub export fn _start() void {}
|
||||
, &[_][]const u8{":2:9: error: unable to resolve comptime value"});
|
||||
case.addError(
|
||||
\\pub export fn _start() void {
|
||||
\\export fn entry() void {
|
||||
\\ _ = foo;
|
||||
\\}
|
||||
\\extern var foo;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user