-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sema: more validation for builtin decl types
Also improve the source locations when this validation fails. Resolves: #22465
- Loading branch information
Showing
3 changed files
with
121 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
pub const Panic = struct { | ||
pub const call = badPanicSignature; | ||
pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch; | ||
pub const unwrapError = std.debug.FormattedPanic.unwrapError; | ||
pub const outOfBounds = std.debug.FormattedPanic.outOfBounds; | ||
pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd; | ||
pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField; | ||
pub const messages = std.debug.FormattedPanic.messages; | ||
}; | ||
|
||
fn badPanicSignature(msg: []const u8, bad1: usize, bad2: void) noreturn { | ||
_ = msg; | ||
_ = bad1; | ||
_ = bad2; | ||
@trap(); | ||
} | ||
|
||
export fn foo(a: u8) void { | ||
@setRuntimeSafety(true); | ||
_ = a + 1; // safety check to reference the panic handler | ||
} | ||
|
||
const std = @import("std"); | ||
|
||
// error | ||
// | ||
// :2:9: error: expected type 'fn ([]const u8, ?*builtin.StackTrace, ?usize) noreturn', found 'fn ([]const u8, usize, void) noreturn' | ||
// :2:9: note: parameter 1 'usize' cannot cast into '?*builtin.StackTrace' |