OxL Reference

data Decl

A declaration or a member of one. parent is the name of the enclosing declaration ("" at the top level).

Example:

oxl✓ checked in CI
use std.comptime { Decl, warn }

// lints/pub_needs_name.oxl: a rule named like the file; the level comes from `[lint]` in oxl.toml
comptime fn pub_needs_name(d: Decl) {
  if d.isPub && d.name.len() < 3 {
    warn(d.span, "public name `{d.name}` is too short")
  }
}
pub(api) data Decl

Since. 1.0.0-beta

Fields

pub(api) kind: str

Kind of the declaration, as lower-case text (fn, data, field, rpc, ...).

pub(api) name: str

Name of the declaration.

pub(api) parent: str

Name of the enclosing declaration; empty at the top level.

pub(api) isPub: bool

Whether the declaration is public.

pub(api) span: Span

Where the declaration is written.

pub(api) attrs: List<Attr>

The attributes of the declaration.

pub(api) exprs: List<Expr>

The expressions of its body in pre-order.

Defined in: std/comptime/comptime.oxl:149

See also