![]() |
|
Navigation |
Synopsis A function is called that has not been declared.
Description All functions, constructors and variables have to be declared before they can be used.
This error is generated when this rule is violated.
Remedies for functions:
Examples Calling the undeclared function
triple gives an error:
rascal>triple(5)
|stdin:///|(0,6,<1,0>,<1,6>): Undeclared variable: triple
We can remedy this by declaring the function:
rascal>int triple(int n) = 3 * n; int (int): int triple(int); rascal>triple(5) int: 15Calling the library function size gives an error if the proper library (in this case: List ) is not imported
rascal>size([20, 1, 77]);
|stdin:///|(0,4,<1,0>,<1,4>): Undeclared variable: size
The solution is:
rascal>import List; ok rascal>size([20, 1, 77]); int: 3Another solution is to import the complete Rascal library at once: rascal>import Prelude; ok rascal>size([20, 1, 77]); int: 3Using an undeclared variable gives an error: rascal>n + 1;
|stdin:///|(0,1,<1,0>,<1,1>): Undeclared variable: n
A variable is introduced by just assigning to it (with or without its expected type):
rascal>n = 3; int: 3 rascal>n + 1; int: 4Or equivalenty (with an expected type): rascal>int n = 3; int: 3 rascal>n + 1; int: 4 ![]() |