Errors#

Every error has a code, a reason and a fix.

Every error of the compiler has a stable code, shown as error[E0423]. A code keeps its meaning across versions; the wording of a message may improve. vision explain-error CODE prints the entry. Every wrong example below raises exactly its code and every corrected one compiles: the tests check both.

E01xx: Lexical#

E0101: string without a closing quote#

A string (a file name) must close on the same line.

canvas c[8, 8] { t }
run { save c.t "out.png }

Corrected:

canvas c[8, 8] { t }
run { save c.t "out.png" }

E0102: unexpected character#

The character is not part of the language. Comments start with //, there is no # comment and no $.

canvas c[8, 8] { t }
kernel k on c { t = 1 $ }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k }

E02xx: Syntax#

E0201: unexpected token#

The parser expected something else here; the message says what.

canvas c[8 8] { t }
run { }

Corrected:

canvas c[8, 8] { t }
run { }

E0202: more than one run block#

A program has one run block, the last part of the program; put every command in it.

canvas c[8, 8] { t }
run { }
run { }

Corrected:

canvas c[8, 8] { t }
run { }

E0203: unexpected top-level item#

At the top of a program only param, canvas, kernel, measure and run may appear.

canvas c[8, 8] { t }
t = 1
run { }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k }

E0204: unknown edge#

The edge of a canvas is clamp (the nearest border cell), wrap (the opposite side) or zero.

canvas c[8, 8] edge mirror { t }
run { }

Corrected:

canvas c[8, 8] edge wrap { t }
run { }

E0205: unknown channel type#

A channel is f32 (the default) or i32.

canvas c[8, 8] { n: int }
run { }

Corrected:

canvas c[8, 8] { n: i32 }
run { }

E0206: channel declared twice#

Every channel of a canvas has its own name.

canvas c[8, 8] { t  t }
run { }

Corrected:

canvas c[8, 8] { t  u }
run { }

E0207: not a reduction#

A measure reduces the canvas with sum, mean, min, max or count.

canvas c[8, 8] { t }
measure m = total(t) on c
run { m }

Corrected:

canvas c[8, 8] { t }
measure m = sum(t) on c
run { m }

E0208: block not closed#

Every { needs its }.

canvas c[8, 8] { t }
kernel k on c { t = 1

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k }

E0209: write to another canvas#

A kernel writes only the cells of the canvas it runs on, by the name of the channel.

canvas c[8, 8] { t }
kernel k on c { c.t = 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k }

E0210: write to another cell (pixel rule)#

A kernel writes only its own cell: writing t[x + 1, y] would be a data race between cells. Each cell reads its neighbours and writes itself.

canvas c[8, 8] { t }
kernel k on c { t[x + 1, y] = 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = t[x - 1, y] }
run { k }

E0211: statement expected#

Inside a kernel: let, var, if, for or an assignment to a channel or a variable.

canvas c[8, 8] { t }
kernel k on c { t + 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = t + 1 }
run { k }

E0212: command expected#

The run block holds kernels and measures by name, repeat, scenarios, load, save and print.

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k() }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k }

E0213: chained comparison#

Comparisons do not chain: write 0 < v and v < 1.

canvas c[8, 8] { t }
kernel k on c { t = select(0 < t < 1, 1, 0) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = select(0 < t and t < 1, 1, 0) }
run { k }

E0214: a channel of another canvas needs the cell#

Another canvas is read at a cell: other.channel[x, y].

canvas c[8, 8] { t }
canvas d[8, 8] { u }
kernel k on c { t = d.u }
run { k }

Corrected:

canvas c[8, 8] { t }
canvas d[8, 8] { u }
kernel k on c { t = d.u[x, y] }
run { k }

E0215: expression expected#

A value is missing here.

canvas c[8, 8] { t }
kernel k on c { t = }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 0 }
run { k }

E03xx: Names#

E0301: reserved name#

x, y, width, height, scenario, the names of functions (and z and depth in a program with a 3-D canvas) belong to the language.

canvas c[8, 8] { x }
run { }

Corrected:

canvas c[8, 8] { px }
run { }

E0302: name already declared#

Params, canvases, kernels and measures share one space of names.

param c = 1
canvas c[8, 8] { t }
run { }

Corrected:

param k = 1
canvas c[8, 8] { t }
run { }

E0303: kernel declared twice#

Every kernel has its own name.

canvas c[8, 8] { t }
kernel k on c { t = 1 }
kernel k on c { t = 2 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
kernel k2 on c { t = 2 }
run { k k2 }

E0304: a kernel and a measure with the same name#

Kernels and measures are both called by name in the run block, so their names differ.

canvas c[8, 8] { t }
kernel m on c { t = 1 }
measure m = sum(t) on c
run { m }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
measure m = sum(t) on c
run { k m }

E0305: unknown canvas#

The canvas has not been declared (the message suggests a close name).

canvas c[8, 8] { t }
kernel k on plate { t = 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k }

E0306: the canvas has no such channel#

The channel is not in the canvas (the message suggests a close name).

canvas c[8, 8] { t }
kernel k on c { t = c.u[x, y] }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = c.t[x, y] }
run { k }

E0307: unknown name#

Not a channel of the canvas, a param, a variable or a name of the language (the message suggests one).

canvas c[8, 8] { t }
kernel k on c { t = temp }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = t + 1 }
run { k }

E0308: a channel of another canvas read without the canvas#

Channels of another canvas are read with canvas.channel[x, y].

canvas c[8, 8] { t }
canvas d[8, 8] { u }
kernel k on c { t = u }
run { k }

Corrected:

canvas c[8, 8] { t }
canvas d[8, 8] { u }
kernel k on c { t = d.u[x, y] }
run { k }

E0309: a canvas used as a value#

A canvas is not a number; read one of its channels: canvas.channel[x, y].

canvas c[8, 8] { t }
kernel k on c { t = c }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = c.t[x, y] }
run { k }

E0310: a function used without parentheses#

Functions are called: sqrt(v).

canvas c[8, 8] { t }
kernel k on c { t = sqrt }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = sqrt(t) }
run { k }

E0311: a variable with the name of a channel#

A local variable cannot have the name of a channel of the canvas.

canvas c[8, 8] { t }
kernel k on c { let t = 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { let v = 1
 t = v }
run { k }

E0312: a variable with a name of the language or of the program#

Locals cannot take the name of a param, a canvas, a coordinate or a function.

canvas c[8, 8] { t }
kernel k on c { let sqrt = 1
 t = sqrt }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { let s = 1
 t = s }
run { k }

E0313: variable already declared here#

A variable is declared once in its block; use var and assign it again.

canvas c[8, 8] { t }
kernel k on c { let v = 1
 let v = 2
 t = v }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { var v = 1
 v = 2
 t = v }
run { k }

E0314: z or depth in a 2-D canvas#

The third coordinate exists only in a 3-D canvas: canvas name[w, h, d].

canvas c[8, 8] { t }
kernel k on c { t = float(z) }
run { k }

Corrected:

canvas c[8, 8, 4] { t }
kernel k on c { t = float(z) }
run { k }

E0315: unknown function#

Not one of the built-in functions (the message suggests a close one). Inside a kernel there is no sum or mean: add the neighbours, or write a measure.

canvas c[8, 8] { t }
kernel k on c { t = sum(t[x - 1, y], t[x + 1, y]) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = t[x - 1, y] + t[x + 1, y] }
run { k }

E0316: no such kernel or measure#

The run block calls kernels and measures declared in the program.

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { diffuse }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { k }

E0317: no such measure#

print and save of a measure need a declared measure.

canvas c[8, 8] { t }
run { print total }

Corrected:

canvas c[8, 8] { t }
measure total = sum(t) on c
run { total print total }

E04xx: Types and rules#

E0401: count needs a condition#

count(…) counts the cells where a condition holds, e.g. count(state == 2).

canvas c[8, 8] { t }
measure m = count(t) on c
run { m }

Corrected:

canvas c[8, 8] { t }
measure m = count(t > 0) on c
run { m }

E0402: a reduction needs a number#

sum, mean, min and max reduce numbers; for a condition, use count.

canvas c[8, 8] { t }
measure m = sum(t > 0) on c
run { m }

Corrected:

canvas c[8, 8] { t }
measure m = count(t > 0) on c
run { m }

E0403: the where of a measure is a condition#

where filters the cells with a true/false condition, e.g. where kind == 1.

canvas c[8, 8] { t }
measure m = sum(t) on c where t
run { m }

Corrected:

canvas c[8, 8] { t }
measure m = sum(t) on c where t > 0
run { m }

E0404: the condition of an if is true/false#

Compare the number: if v > 0 { … }.

canvas c[8, 8] { t }
kernel k on c { if t { t = 1 } }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { if t > 0 { t = 1 } }
run { k }

E0405: the bounds of a for are uniform integers#

for bounds are the same in every cell: numbers, params, width, height and expressions of them.

canvas c[8, 8] { t }
kernel k on c {
 var s = 0.0
 for i in 0 to x { s += 1 }
 t = s }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c {
 var s = 0.0
 for i in 0 to 3 { s += 1 }
 t = s }
run { k }

E0406: a loop variable cannot change#

The variable of a for takes each value of the range; use another variable.

canvas c[8, 8] { t }
kernel k on c { for i in 0 to 3 { i = 1 } }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c {
 var j = 0
 for i in 0 to 3 { j = i }
 t = float(j) }
run { k }

E0407: let is immutable#

A variable made with let keeps its value; make it with var to change it.

canvas c[8, 8] { t }
kernel k on c { let v = 1
 v = 2
 t = v }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { var v = 1
 v = 2
 t = v }
run { k }

E0408: a variable keeps its type#

A variable holds the type of its first value; an int variable cannot receive a float.

canvas c[8, 8] { t }
kernel k on c { var n = 1
 n = 0.5
 t = n }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { var n = 1.0
 n = 0.5
 t = n }
run { k }

E0409: channels hold numbers#

A condition is not a number; convert it, e.g. select(cond, 1.0, 0.0).

canvas c[8, 8] { t }
kernel k on c { t = t > 0 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = select(t > 0, 1.0, 0.0) }
run { k }

E0410: an i32 channel takes integers#

Convert explicitly with int(…), which truncates towards zero.

canvas c[8, 8] { n: i32 }
kernel k on c { n = 0.5 }
run { k }

Corrected:

canvas c[8, 8] { n: i32 }
kernel k on c { n = int(0.5) }
run { k }

E0411: params are read-only#

A param is a constant of the program; change it from outside (–param NAME=VALUE) or keep the value in a channel.

param a = 1
canvas c[8, 8] { t }
kernel k on c { a = 2 }
run { k }

Corrected:

param a = 1
canvas c[8, 8] { t }
kernel k on c { t = a }
run { k }

E0412: coordinates and sizes are read-only#

x, y, z, width, height, depth and scenario come from the canvas.

canvas c[8, 8] { t }
kernel k on c { x = 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = float(x) }
run { k }

E0413: a kernel writes only its own canvas#

The channel belongs to another canvas; write it with a kernel on that canvas.

canvas c[8, 8] { t }
canvas d[8, 8] { u }
kernel k on c { u = 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
canvas d[8, 8] { u }
kernel k on d { u = 1 }
run { k }

E0414: ‘not’ needs true/false#

not negates a condition: not (v > 0).

canvas c[8, 8] { t }
kernel k on c { t = select(not t, 1, 0) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = select(not (t > 0), 1, 0) }
run { k }

E0415: ‘-’ needs a number#

Negate a number, not a condition.

canvas c[8, 8] { t }
kernel k on c { t = select(-(t > 0), 1, 0) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = -t }
run { k }

E0416: the canvas is 3-D: give the cell as [x, y, z]#

Every read of a 3-D canvas gives three coordinates.

canvas v[8, 8, 4] { t }
kernel k on v { t = t[x, y] }
run { k }

Corrected:

canvas v[8, 8, 4] { t }
kernel k on v { t = t[x, y, z] }
run { k }

E0417: the canvas is 2-D: give the pixel as [x, y]#

A 2-D canvas is read with two coordinates.

canvas c[8, 8] { t }
kernel k on c { t = t[x, y, 0] }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = t[x, y] }
run { k }

E0418: coordinates are integers#

Convert with int(…), which truncates towards zero.

canvas c[8, 8] { t }
kernel k on c { t = t[x + 0.5, y] }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = t[x + 1, y] }
run { k }

E0419: ‘and’ and ‘or’ combine conditions#

Both sides are true/false: v > 0 and w > 0.

canvas c[8, 8] { t }
kernel k on c { t = select(t and t > 0, 1, 0) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = select(t > 0 and t < 9, 1, 0) }
run { k }

E0420: a number compared with true/false#

== and != compare two numbers or two conditions.

canvas c[8, 8] { t }
kernel k on c { t = select((t > 0) == 1, 1, 0) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = select(t > 0, 1, 0) }
run { k }

E0421: the operator needs numbers#

Arithmetic and <, <=, >, >= take numbers; a condition becomes a number with select(cond, 1, 0).

canvas c[8, 8] { t }
kernel k on c { t = (t > 0) + 1 }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = select(t > 0, 1, 0) + 1 }
run { k }

E0422: wrong number of arguments#

The message gives the arity of the function; see the list of functions.

canvas c[8, 8] { t }
kernel k on c { t = min(t) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = min(t, 1) }
run { k }

E0423: the first argument of select is a condition#

select(cond, a, b) gives a where cond holds and b elsewhere; to test a number, compare it: select(n == 1, 1, 0).

canvas c[8, 8] { n: i32 }
kernel k on c { n = select(n, 1, 0) }
run { k }

Corrected:

canvas c[8, 8] { n: i32 }
kernel k on c { n = select(n == 1, 1, 0) }
run { k }

E0424: select needs two values of the same kind#

Both choices are numbers, or both are conditions.

canvas c[8, 8] { t }
kernel k on c { t = select(t > 0, 1, t > 1) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = select(t > 0, 1, 0) }
run { k }

E0425: flux takes integers#

flux(d, s) moves d / 2^s (rounded half away from zero) between integer channels.

canvas c[8, 8] { t }
kernel k on c { t = float(flux(t, 2)) }
run { k }

Corrected:

canvas c[8, 8] { n: i32 }
kernel k on c { n += flux(n[x - 1, y] - n, 2) }
run { k }

E0426: rand takes integers#

rand(ix, iy, seed) takes integers and gives a number in [0, 1).

canvas c[8, 8] { t }
kernel k on c { t = rand(t, y, 1) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = rand(x, y, 1) }
run { k }

E0427: rgb takes integers from 0 to 255#

rgb(r, g, b) is r * 65536 + g * 256 + b, the number of a colour of a loaded PNG.

canvas c[8, 8] { kind: i32 }
kernel k on c { kind = rgb(300, 0, 0) }
run { k }

Corrected:

canvas c[8, 8] { kind: i32 }
kernel k on c { kind = rgb(255, 0, 0) }
run { k }

E0428: the function needs numbers#

Mathematical functions take numbers, not conditions.

canvas c[8, 8] { t }
kernel k on c { t = sqrt(t > 0) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = sqrt(t) }
run { k }

E05xx: Constants and limits#

E0501: does not fit in float32#

Every value of Vision is a finite float32: the largest is 3.4028235e38.

param big = 1e39
canvas c[8, 8] { t }
run { }

Corrected:

param big = 1e38
canvas c[8, 8] { t }
run { }

E0502: integer too large#

Integers are 32 bits: at most 2147483647.

canvas c[8, 8] { t }
kernel k on c { t = float(3000000000) }
run { k }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 3000000000.0 }
run { k }

E0503: division by zero in a constant#

Sizes and counts are computed when the program is compiled.

canvas c[8 / 0, 8] { t }
run { }

Corrected:

canvas c[8 / 2, 8] { t }
run { }

E0504: a constant is needed#

Sizes of canvases, repeat counts and the like use numbers and params only.

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { repeat t { k } }

Corrected:

param n = 3
canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { repeat n { k } }

E0505: an integer constant is needed#

Sizes and counts are integers.

canvas c[8.5, 8] { t }
run { }

Corrected:

canvas c[8, 8] { t }
run { }

E0506: constant too large#

The constant does not fit in 32 bits.

canvas c[2147483648, 1] { t }
run { }

Corrected:

canvas c[64, 1] { t }
run { }

E0507: the resolution must be positive#

Every size of a canvas is at least 1.

canvas c[0, 8] { t }
run { }

Corrected:

canvas c[1, 8] { t }
run { }

E0508: depth up to 65535#

A 3-D canvas has at most 65535 layers.

canvas c[2, 2, 70000] { t }
run { }

Corrected:

canvas c[2, 2, 7000] { t }
run { }

E0509: repeat count cannot be negative#

repeat 0 runs nothing; a negative count has no meaning.

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { repeat -1 { k } }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { repeat 1 { k } }

E0510: at least one scenario#

scenarios n needs n >= 1.

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { scenarios 0 { k } }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { scenarios 1 { k } }

E0511: scenarios blocks do not nest#

One level of scenarios; combine the indices inside the kernels instead.

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { scenarios 2 { scenarios 2 { k } } }

Corrected:

canvas c[8, 8] { t }
kernel k on c { t = 1 }
run { scenarios 4 { k } }

E0512: cell outside the canvas#

print canvas.channel[x, y] needs a cell inside the canvas.

canvas c[8, 8] { t }
run { print c.t[8, 0] }

Corrected:

canvas c[8, 8] { t }
run { print c.t[7, 0] }

E06xx: Run block and files#

E0601: a measure printed before it is taken#

Call the measure in the run block (it takes one value) before printing or saving it.

canvas c[8, 8] { t }
measure m = sum(t) on c
run { print m }

Corrected:

canvas c[8, 8] { t }
measure m = sum(t) on c
run { m print m }

E0602: the series of a measure is saved as .csv#

save measure “file.csv” writes every value taken.

canvas c[8, 8] { t }
measure m = sum(t) on c
run { m save m "m.txt" }

Corrected:

canvas c[8, 8] { t }
measure m = sum(t) on c
run { m save m "m.csv" }

E0603: unsupported output format#

save writes .png (a colour map), .npy (raw values) or .vti (VTK, for ParaView).

canvas c[8, 8] { t }
run { save c.t "t.jpg" }

Corrected:

canvas c[8, 8] { t }
run { save c.t "t.png" }

E0604: a 3-D canvas is saved as .npy or .vti#

A .png is a 2-D picture.

canvas v[8, 8, 4] { t }
run { save v.t "t.png" }

Corrected:

canvas v[8, 8, 4] { t }
run { save v.t "t.vti" }

E0605: a whole canvas is saved as .vti#

save canvas “file.vti” writes every channel in one VTK file.

canvas c[8, 8] { t }
run { save c "all.npy" }

Corrected:

canvas c[8, 8] { t }
run { save c "all.vti" }

E0606: unsupported input format#

load reads .npy, .csv, .txt, .asc (Esri ASCII grid) and .png.

canvas c[8, 8] { t }
run { load c.t "t.tif" }

E0607: the number of coordinates does not match the canvas#

print of a cell gives [x, y] for a 2-D canvas and [x, y, z] for a 3-D one.

canvas v[8, 8, 4] { t }
run { print v.t[1, 1] }

Corrected:

canvas v[8, 8, 4] { t }
run { print v.t[1, 1, 1] }

E07xx: Data files#

E0701: data file not found#

The path of load is relative to the directory where Vision runs.

E0702: unsupported data format#

Use .npy, .csv, .txt, .asc or .png.

E0703: the data is not a grid#

A 2-D grid (rows x columns), or a 3-D .npy [depth, height, width].

E0704: cells without data#

NaN cells, or the NODATA_value of an .asc, need a replacement: load c.t “dem.asc” nodata 0.

E0705: NaN values#

Vision only works with finite values; replace NaN with numbers.

E0706: invalid .npy#

The file could not be read as a numpy array, or it does not contain numbers.

E0707: invalid text grid#

A .csv or .txt is a grid of numbers, the same number of columns on every line.

E0708: invalid ASCII grid#

The header of the .asc (ncols, nrows, …) or its values are invalid.

E0709: invalid PNG#

Not a PNG, incomplete, interlaced or of a type that Vision does not read.

E0710: the resolution of the file differs from the canvas#

The file and the canvas have the same size; the message says which canvas to declare.

E0711: an i32 channel takes integers#

The values loaded into an i32 channel are integers that fit in 32 bits.

E08xx: Parameters from the command line#

E0801: no such param#

–param NAME=VALUE names a param of the program.

E0802: invalid param value#

The value of –param is a number; an integer param takes an integer.