add compile error if root.log is not a function

This commit is contained in:
Luna 2021-06-21 23:32:06 -03:00 committed by Veikka Tuominen
parent c6844072ce
commit d1f99eabb7

View file

@ -142,6 +142,8 @@ fn log(
if (@enumToInt(message_level) <= @enumToInt(effective_log_level)) { if (@enumToInt(message_level) <= @enumToInt(effective_log_level)) {
if (@hasDecl(root, "log")) { if (@hasDecl(root, "log")) {
if (@typeInfo(@TypeOf(root.log)) != .Fn)
@compileError("Expected root.log to be a function");
root.log(message_level, scope, format, args); root.log(message_level, scope, format, args);
} else if (std.Target.current.os.tag == .freestanding) { } else if (std.Target.current.os.tag == .freestanding) {
// On freestanding one must provide a log function; we do not have // On freestanding one must provide a log function; we do not have