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