Diagnostics
Vapour checks your code before transpiling it, these checks are reported as diagnostics, in your editor via the LSP or in the terminal when using the CLI.
Format
In the terminal, diagnostics are printed as:
[SEVERITY] file:line:column message
e.g.:
[WARN] script.vp:4:23 `n` might be missing
✓ files successfully transpiled!
info
Line numbers currently start at 0 in the terminal output.
Severities
| Severity | Meaning | Prevents transpilation |
|---|---|---|
ERROR | The code is invalid, or will fail | Yes |
WARN | The code will probably fail | No |
INFO | Something is likely a mistake | No |
HINT | The code could be improved | No |
Use -check-only to only run the checks, see CLI.
You can choose which severities are shown in your editor,
see customise.
Errors
Errors prevent transpilation.
Declarations
- variable is already declared
- function or type is already defined
- functions and types cannot share a name
- function shares its name with a base R function
- type is not declared
- constants without a value, or with multiple types
- assigning to a constant
- assigning to a parent variable (
<-) that does not exist
Types
- assigning a value of the wrong type
- returning a value of the wrong type, or not returning (except
nullfunctions) - vectors mixing types, e.g.:
(1, "a") - using
$on a vector type - unknown attribute on an object, or attribute of the wrong type
- looping over a type that cannot be iterated
Functions & methods
- argument of the wrong type
- unknown named argument, or too many arguments
- duplicated parameter
- callback that does not match its signature
- method on
anyoutside of@genericand@default
Objects
object,structandenvironmentattributes must be namedstructexpects an unnamed first argumentlist,factor, and vectors expect unnamed arguments- unexpected decorator argument, e.g.:
@matrix(foo = 1)
Warnings
- variable not found, e.g.:
print(x)wherexis not declared - argument might be missing, see missing check
Info
- variable or type is never used
- comparison between types that are not comparable, e.g.:
"a" > 1 - the same method is defined twice on a type
Hints
- package is not installed
- function is not exported by the package, e.g.:
dplyr::foo() - use of
library()orrequire(), prefernamespace::foo