Skip to content

Commit 974c684

Browse files
feat: enable abort for native backend
1 parent 8459084 commit 974c684

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

abort/abort.mbt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,32 @@
2323
///
2424
/// Returns a value of type `T`. However, this function never actually returns a
2525
/// value as it always causes a panic.
26+
#cfg(not(target="native"))
2627
pub fn[T] abort(msg : String) -> T {
2728
let _ = msg
2829
panic_impl()
2930
}
3031

32+
///|
33+
#cfg(target="native")
34+
fn println(s : String) -> Unit = "%println"
35+
36+
///|
37+
/// Aborts the program with an error message. Always causes a panic, regardless
38+
/// of the message provided.
39+
///
40+
/// Parameters:
41+
///
42+
/// * `message` : A string containing the error message to be displayed when
43+
/// aborting.
44+
///
45+
/// Returns a value of type `T`. However, this function never actually returns a
46+
/// value as it always causes a panic.
47+
#cfg(target="native")
48+
pub fn[T] abort(msg : String) -> T {
49+
println(msg)
50+
panic_impl()
51+
}
52+
3153
///|
3254
fn[T] panic_impl() -> T = "%panic"

0 commit comments

Comments
 (0)