This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Errors, exactly as the compiler says them

The error messages are part of the language. Each one below is what the compiler prints, and the site's tests fail if a message changes. Run a cell to see its output beside the expected one.

A string is not changed in place

Strings are immutable, as in Python; build a new one instead.

Viv [1]

expected error: 'str' object does not support item assignment…

deriv cannot differentiate a call to a def

Write the expression inline in the fn instead of calling f.

Viv [2]

expected error: cannot differentiate through…

A def does not change a record it is given

A record is a value: change a copy and return it. An array inside it can still be written in place.

Viv [3]

expected error: `p` is a parameter, and a def does not change the values it is given…

Unknown function

Viv [4]

expected error: unknown function…

Arity is checked

Viv [5]

expected error: expects 2 argument…

Out of bounds says where

Viv [6]

expected error: index 5 out of bounds for dimension 0 (size 2)…

An index before the start stops

A negative index counts from the end, as in Python: -1 is the last element. Two elements have no element -3.

Viv [7]

expected error: index -3 out of bounds for dimension 0 (size 2)…

Shape mismatch

Viv [8]

expected error: array shape mismatch: [2] vs [3]…

break outside a loop

Viv [9]

expected error: `break`/`continue` outside a loop…

Undefined variable

Viv [10]

expected error: undefined variable…

plot wants arrays

Viv [11]

expected error: `plot` takes two arrays…

Keywords cannot name functions

record, test, show and the other keywords are reserved.

Viv [12]

expected error: expected function name…

A number is not a condition

if and while take a Bool. Write the comparison you mean.

Viv [13]

expected error: condition must be a boolean…

No arithmetic on a Bool

true is not 1. Every engine refuses this.

Viv [14]

expected error: boolean…

An array is not a condition

A comparison of two arrays is a mask, not a Bool; the note says to write all(a == b).

Viv [15]

expected error: condition must be a boolean, and this is an array…

% by zero stops the program

/ by zero gives inf, as IEEE floats do, but % and // by zero have no answer and stop.

Viv [16]

expected error: division by zero in `a % b`…