Error
Emits a compiler error at every call site of the annotated function. The build fails at any point where the function is called. Use it to intentionally block usage of a function — for example, to enforce that a stub or unsupported path is never called.
Syntax
#Error("Function is not implemented")
func DoSomething() {
// Implementation
}
Examples
Unsupported-platform stub
Pair #Error with conditional compilation so a platform that lacks an implementation fails at the call site rather than at link time:
import Core::{ #target };
when #target.os == .Windows {
func OpenDisplay() -> *opaque {
// real Windows implementation
return null;
}
} else {
#Error("OpenDisplay is not supported on this platform")
func OpenDisplay() -> *opaque {
return null;
}
}
Calling OpenDisplay() on a non-Windows build produces:
error: OpenDisplay is not supported on this platform
Removed API
#Error("Connect() was removed; use ConnectAsync() instead")
func Connect(host: Slice<char8>, port: uint16) -> bool {
return false;
}
Any call to Connect() is a compile-time error, ensuring all callers are migrated before the code can build.
See Also
#Warn— flag usage without breaking the build- Conditional Compilation — selecting per-platform implementations
- Attributes — the full attribute set
Warn
Emits a compiler warning at every call site of the annotated function. The function remains callable; the warning is informational.
NoReturn
Declares that a function never returns to its caller — it ends the program, loops forever, or transfers control elsewhere. The compiler uses this to check control flow: code after a call to a #NoReturn function is known to be unreachable, and a branch that ends in one satisfies a function that must produce a value.