diff --git a/src/Sema.zig b/src/Sema.zig index 4936d52238..21cbd0cf35 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -10791,6 +10791,13 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r "'_' prong here", .{}, ); + try sema.errNote( + block, + src, + msg, + "consider using 'else'", + .{}, + ); break :msg msg; }; return sema.failWithOwnedErrorMsg(msg); diff --git a/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig b/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig index e3d09bc133..32aa446f9a 100644 --- a/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig +++ b/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig @@ -17,3 +17,4 @@ pub export fn entry() void { // // :7:5: error: '_' prong only allowed when switching on non-exhaustive enums // :10:11: note: '_' prong here +// :7:5: note: consider using 'else' diff --git a/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig b/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig index 5678102fc6..a88393b99f 100644 --- a/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig +++ b/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig @@ -40,3 +40,4 @@ pub export fn entry3() void { // :19:5: error: switch on non-exhaustive enum must include 'else' or '_' prong // :26:5: error: '_' prong only allowed when switching on non-exhaustive enums // :29:11: note: '_' prong here +// :26:5: note: consider using 'else'