Docs menu

E146: An annotation the declaration under it cannot carry

What compiler error E146 means, and how to fix it.

Example
@ownrship(acquires)pub extern fn malloc(size: int): void*;// ERROR [E146]: I do not know an annotation named `@ownrship`.//   Hint: Write `@ownership` instead, or use one of the known annotations: @ownership, @ffi.

An annotation, @name(arguments) written on the line before a function or an extern fn, tells the compiler a fact about that declaration. The compiler knows what a function does only because its declaration says so, never because of the function’s name: malloc is understood as an allocator because it says @ownership(acquires), and your own allocator is understood the same way when it says the same thing.

That is why a wrong annotation is an error rather than something quietly skipped. A misspelt one would otherwise switch off the very check it was written to turn on, and you would never find out.

There are three ways to get this error.

The name is not one the compiler knows. The message suggests the closest one and lists them all:

Example
@ownership(acquires)                  // the double-free / use-after-free check@ffi(macos: malloc_size)              // which C symbol an extern binds to, per platform

The arguments do not fit the declaration. The message says what is wrong:

Example
@ownership(acquires)fn count(): int { return 0; }// '@ownership(acquires)' says the function returns a fresh allocation,// but it does not return a pointer.@ownership(releases: q)pub extern fn free(p: void*): void;// 'q' is not a parameter of this function -- write 'releases: p'.@ffi(macos: malloc_size)fn helper(): int { return 0; }// '@ffi' can only sit on an 'extern fn'.

A @test is malformed. @test marks a top-level function as a test (see the language reference, @test): it takes no parameters, returns void or !void, and may start with an outcome (compile_error, warning, no_warnings, panic, exit, error), followed by options such as timeout: 2000. The message names the rule and the hint lists the outcomes and the options:

Example
@test(compile_eror, E041, "x")fn t(): void { }// 'compile_eror' is not an outcome of '@test'.@test(compile_error, E999, "x")fn t(): void { }// 'E999' is not a code the compiler has.@test(compile_error, E172, "x")fn t(): void { }// 'E172' is a warning's code, not an error's.@testfn t(n: int): void { }// A test takes no parameters.@testfn t(): int { return 1; }// A test returns 'void' or '!void', not 'int'.@test(exit, 256)fn t(): void { }// '256' is not an exit status.@test(error, ParseError::Gone)fn t(): !void { return; }// The error type `ParseError` has no variant `Gone`.@test(retries: 3)fn t(): void { }// `@test` has no option `retries:`.@test(timeout: 0)fn t(): void { }// `timeout:` takes a whole number of milliseconds greater than 0.

Also rejected: an outcome that is not the first argument, a method or main as a test, a second @test on one function, an option written twice, a timeout: or stdout: on a compile_error test, and an error outcome on a function that does not return !void. The options are skip:, timeout:, levels:, stdout:, tag: and serial, after the outcome. A @test function nested in another function is E038.

The fix is to correct the spelling, or to say what is actually true of the declaration, or to remove the annotation.

A malformed annotation – a missing ‘)’ or an expression such as 1 + 2 in the arguments – is a syntax error instead (E103), reported where the parser stopped. An argument may be a word, a string, a whole number or a Type::Variant path.

Run turf --explain E146 in a terminal to read this again.

Last updated: Oct 15, 2026Edit this page on GitHub

Esc

Type to search.