authorgravatar for git@l4.pmLuna <git@l4.pm> 2021-06-21 23:32:06-03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-06-22 16:38:18+03:00
logd1f99eabb745a3026b4bf0486ee542d38facee8b
tree2370c1c891ca38d85f111c7b0390952739daed29
parentc6844072ce440f581787bf97909261084a9edc6c

add compile error if root.log is not a function


1 files changed, 2 insertions(+), 0 deletions(-)

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