Skip to main content
Version: Next

Diagnostics

Vapour checks your code before transpiling it, and reports what it finds as diagnostics. You see them in your editor through the LSP, and in the terminal when you use the CLI. This chapter explains how to read them, and lists every check.

Reading a diagnostic​

In the terminal, each diagnostic is one line:

[SEVERITY]	file:line:column message

For example:

[WARN]	script.vp:6:23 `n` might be missing
✓ files successfully transpiled!

This says: in script.vp, line 6, column 23, the argument n might be missing. It's a warning, so the file was still transpiled.

Severities​

SeverityMeaningStops transpilation
ERRORThe code is invalid, or will failYes
WARNThe code will probably failNo
INFOSomething is likely a mistakeNo
HINTThe code could be improvedNo

Only errors stop transpilation. Don't ignore the rest: a warning usually means an error at run time.

To only run the checks, without transpiling, use -check-only (see CLI). You can choose which severities your editor shows, see customise.

Errors​

Declarations​

CheckLearn more
variable is already declaredvariables
function or type is already definedfunctions
functions and types cannot share a namefunctions
function shares its name with a base R functionfunctions
type is not declaredcustom types
constant without a value, or with several typesvariables
assigning to a constantvariables
assigning to a parent variable (<-) that does not existvariables

Types​

CheckLearn more
assigning a value of the wrong type, including nested attributes, e.g.: a$b$ctypes
loop variable whose type does not match the elementscontrol flow
non-numeric value in a range, e.g.: "a"..3control flow
returning a value of the wrong type, or not returning (except null functions)functions
vector mixing types, e.g.: (1, "a")types
using $ on a vector typecontrol flow
unknown attribute, or attribute of the wrong typecustom types
looping over a type that cannot be iteratedcustom types
break or next outside of a loopcontrol flow

Functions and methods​

CheckLearn more
argument of the wrong typefunctions
unknown named argument, or too many argumentsfunctions
duplicated argumentfunctions
method on any without @generic or @defaultmethods
callback with the wrong arguments or return typefunctions
the same method is defined twice on a typemethods

Custom types​

CheckLearn more
object, struct, and environment attributes must be namedcustom types
struct expects one unnamed first argumentcustom types
list, factor, and vectors expect unnamed argumentscustom types
unexpected decorator argument, e.g.: @matrix(foo = 1)custom types

Warnings​

CheckLearn more
variable not found, e.g.: print(x) where x is not declaredvariables
argument might be missingfunctions

Info​

CheckLearn more
variable or type is never usedvariables
comparison between types that are not comparable, e.g.: "a" > 1control flow

Hints​

CheckLearn more
package is not installedcontrol flow
function is not exported by the package, e.g.: dplyr::foo()control flow
use of library() or require(), prefer pkg::fn()control flow