Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vlib/log/default.v
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ pub fn set_level(level Level) {
}

// fatal logs a `fatal` message, using the default Logger instance
@[noreturn]
pub fn fatal(s string) {
default_logger.fatal(s)
// the compiler currently has no way to mark functions in an interface
// as @[noreturn], so we need to make sure this is never returning ourselves
exit(1)
}

// error logs an `error` message, using the default Logger instance
Expand Down
8 changes: 8 additions & 0 deletions vlib/log/log_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,11 @@ fn test_log_time_format() {
assert true
println(@FN + ' end')
}

fn make_error() ?string {
return 'ok'
}

fn test_log_default_fatal_has_noreturn() {
_ := make_error() or { fatal('error') }
}