mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
log: tag log.fatal with @[noreturn] (#22986)
This commit is contained in:
parent
844d89fd09
commit
aeaf607259
@ -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
|
||||
|
@ -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') }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user