Attributes Reference

Declaration attributes currently recognized by analysis and tests.

Attributes are written with @name or @name(args...) before declarations. The current language has a closed attribute table: unknown source attributes are rejected, and user-defined decorators are not part of 0.0.0-dev.

@deprecated("use new_fn instead")
fn old_fn() {}

@discardable
fn side_effect() -> i32 {
    return 42;
}

Attribute Table

AttributeAllowed targetsArgumentsEffect
@export / exportTop-level declarations and globalsnoneExports the declaration from the module interface. See Visibility and Privacy.
@extern / externTop-level functions and globalsnoneDeclares a Zynx-linkage symbol whose body is provided by another object or module unit.
foreignTop-level functions and globalsABI string; optional library blockDeclares a non-Zynx ABI symbol. Only foreign "C" and foreign library "name" { abi "C"; ... } are accepted in 0.0.0-dev.
@symbolforeign declarationsone string literalUses the named foreign symbol while keeping the Zynx declaration name local.
@intrinsic / intrinsicFunctions and methodsnoneMarks a compiler/runtime intrinsic declaration. Normal source cannot define new intrinsic behavior.
@inlineFunctions and methodsnoneCodegen inline hint. Rejected with external declarations.
@discardableFunctions and methodsnoneSuppresses ignored-result warnings for calls.
@deprecatedFunctions and methodsoptional string literalEmits a deprecation warning on calls.
@weakFunctions and methodsnoneEmits weak linkage for generated definitions.
@sectionFunctions and methodsone string literalPlaces the generated function in an object section.
@noreturnFunctions and methods returning voidnoneMarks the generated function as not returning.
@unmangledFunctions, methods, and globalsnoneUses the source name as the emitted symbol name.
@packedStructs and unionsnoneUses packed source-order layout. Rejected with @strict.
@strictStructs and unionsnoneUses source-order layout with target ABI alignment and padding. Rejected with @packed.
@nativeStructs, unions, enums, and errorsnoneDeclares C-compatible aggregate or enum layout where supported by FFI rules.
@c_nameStructs, unions, enums, errors, and globalsone string literalRecords the C spelling used by bindgen/header emission.
@privateStruct fields and methodsnoneApplies the private field and method rules from Visibility and Privacy.
@readonlyStruct fieldsnoneRejects assignment to the field after initialization.
@bitsFields of @native structone integer literalDeclares a native bitfield width.
@derive(json)StructsjsonEnables typed std.json.decode<T> support for the struct.
@json_allow_unknownStructs with @derive(json)noneAllows typed JSON decoding to ignore object fields that do not map to struct fields.
@json_keyFields of structs with @derive(json)one string literalUses the named JSON object key for the field.
@json_optionalFields of structs with @derive(json)noneAllows the field to be absent and keeps the field default.
@json_skipFields of structs with @derive(json)noneIgnores the field during typed JSON decoding.
@suppressLocals and declarationswarning namesSuppresses supported warning kinds for that declaration.
@unusedLocal bindingsnoneMarks the binding as intentionally unused.
@abiTop-level declarations and methodsone string literalIncludes a declaration only for a matching target ABI.
@archTop-level declarations and methodsone string literalIncludes a declaration only for a matching target architecture.
@platformTop-level declarations and methodsone string literalIncludes a declaration only for a matching target platform.

Attribute validity depends on declaration kind and modifier ordering. The compiler reports duplicate or misplaced attributes. Duplicate attributes are rejected except for repeated @suppress(...).

export, extern, and intrinsic can also be parsed as declaration modifiers; the parser represents them internally as synthesized attributes. foreign is a separate declaration form for non-Zynx ABI boundaries.

Methods without a first self parameter are static methods. The old @static method attribute is not part of the current source surface.

Names beginning with __zynx_ are reserved for compiler-private generated code and are not a stable user extension mechanism.

LLVM hooks such as @llvm.memcpy and @llvm.uadd.with.overflow are compiler builtins used in expressions, not declaration attributes.