Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

03: Names and declarations

E0301

Unknown name. A name that nothing declares: a value, function, dim, domain or axis. When a name with a similar spelling exists, the help suggests it. In a return type or an as, a size name that isn’t in scope is reported as an unknown size; write ?k for a size the function chooses or that is only known at run time.

fn f(x: [b D]) -> [b D] = relu(x) |> gelo

See Names and scoping and Axis names.

E0302

Name defined twice. Two module-level declarations, two parameters of one function, or two fields of one model have the same name.

fn f(x: [n]) -> [n] = x
fn f(x: [n]) -> [n] = x

See Module scope.

E0303

Name used as the wrong kind of thing. A dim or value called as a function, a function or domain used as a value, a value used as a size, a value named like an axis or a dim, a dim used as a domain, and so on. The message says what the name is.

dim D = 768

fn f(x: [n D]) = D(x)

See Function scope and Name clashes.

E0304

Dim defined in terms of itself. Dims may refer to each other in any order, but not in a cycle.

dim A = B + 1
dim B = A * 2

See Dims.

E0305

Dim isn’t a positive whole number. A dim’s value must be at least 1, and a division in it must be exact. The diagnostic points at both dims when a division fails.

dim D = 768
dim H = 10
dim Dh = D / H

See Dims and Division.

E0306

Invalid function signature. A parameter with neither a type nor a default; ?k in a parameter type; in a fn, a default that isn’t a number, that uses the function’s parameters or axis names, or that is on a parameter with a shape or a model’s type; a default that isn’t a number on an untyped parameter of an extern fn; ..., Axis[..], Axes[..] or Size[..] in a fn, or ... twice in one type or inside a group; a call to a function without a return type from inside its own body.

fn f(x) -> [n] = x

See Parameters, Unknown sizes and Extern functions and the prelude.

E0307

Missing return. The signature declares a return type, but the body doesn’t return a value on every path, or has a bare return. A for loop may run no times, and an if without an else may not run, so a return in them doesn’t count; put one after the loop, or in both blocks of an if.

fn f(x: [n]) -> [n]:
    y = x

See Function declarations and Control flow.

E0308

Invalid extern fn. An extern fn without a return type; a string that isn’t a Python function’s dotted name (it needs a module and a function, each part a Python identifier and not a keyword); an Axis[..] or Axes[..] parameter with a default or without a first parameter with a shape; a Size[..] default that isn’t a number or an earlier size; a return type with ... when no parameter has it.

extern fn erfc(x: Real) = "torch.special.erfc"

See Extern functions and the prelude.