[Tutorial] Errors And Warning Messages
#1

Hello,
I wrote this tutorial when i saw many requests on "Scripting Discussion" saying "How To Fix Loose Indentations?"
I have taken this from Pawn-Language guide.

expected token: token, but found token
A required token is omitted.

only a single statement (or expression) can follow each 'case':
Every case in a switch statement can hold exactly one statement.
To put multiple statements in a case, enclose these statements
between braces (which creates a compound statement).

declaration of a local variable must appear in a compound block:
The declaration of a local variable must appear between braces
(“{. . .}”) at the active scope level.
When the parser flags this error, a variable declaration appears
as the only statement of a function or the only statement below
an if, else, for, while or do statement. Note that, since local
variables are accessible only from (or below) the scope that their
declaration appears in, having a variable declaration as the only
statement at any scope is useless.

function may not have arguments
The function main is the program entry point. It may not have
arguments.

must be assigned to an array
String literals or arrays must be assigned to an array. This error
message may also indicate a missing index (or indices) at the array
on the right side of the “=” sign.

operator cannot be redefined
Only a select set of operators may be redefined, this operator is not one of them.

function name is not implemented:
There is no implementation for the designated function. The
function may have been “forwardly” declared —or prototyped—
but the full function definition including a statement, or statement
block, is missing.

must be a constant expression; assumed zero
The size of arrays and the parameters of most directives must be
constant values.

invalid array size (negative, zero or out of bounds)
The number of elements of an array must always be 1 or more. In
addition, an array that big that it does exceeds the range of a cell
is invalid too.

illegal function or declaration
The compiler expects a declaration of a global variable or of a
function at the current location, but it cannot interpret it as such.

invalid outside functions
The instruction or statement is invalid at a global level. Local
labels and (compound) statements are only valid if used within
functions.

invalid function call, not a valid address
The symbol is not a function.

no entry point (no public functions)
The file does not contain a main function or any public function.
The compiled file thereby does not have a starting point for the
execution.

invalid statement; not in switch
The statements case and default are only valid inside a switch
statement.

“default” must be the last clause in switch statement
pawn requires the default clause to be the last clause in a switch
statement.

multiple defaults in “switch”
Each switch statement may only have one default clause.

undefined symbol symbol
The symbol (variable, constant or function) is not declared

initialization data exceeds declared size
An array with an explicit size is initialized, but the number of
initiallers exceeds the number of elements specified. For example,
in “arr[3]={1,2,3,4};” the array is specified to have three
elements, but there are four initiallers.

not a label: name
A goto statement branches to a symbol that is not a label.

invalid symbol name
A symbol may start with a letter, an underscore or an “at” sign
(“@”) and may be followed by a series of letters, digits, underscore
characters and “@” characters.

symbol already defined: identifier
The symbol was already defined at the current level.

must be lvalue (non-constant)
The symbol that is altered (incremented, decremented, assigned
a value, etc.) must be a variable that can be modified (this kind
of variable is called an lvalue). Functions, string literals, arrays
and constants are no lvalues. Variables declared with the “const”
attribute are no lvalues either.

array assignment must be simple assignment
When assigning one array to another, you cannot combine an
arithmetic operation with the assignment (e.g., you cannot use the
“+=” operator).

“break” or “continue” is out of context
The statements break and continue are only valid inside the
context of a loop (a do, for or while statement). Unlike the
languages C/C++ and Java, break does not jump out of a switch
statement.

function heading differs from prototype
The number of arguments given at a previous declaration of the
function does not match the number of arguments given at the
current declaration.

no matching “#if...”
The directive #else or #endif was encountered, but no matching
#if directive was found.

invalid character constant
One likely cause for this error is the occurrence of an unknown
escape sequence, like “\x”. Putting multiple characters between
single quotes, as in ’abc’ also issues this error message. A third
cause for this error is a situation where a character constant was
expected, but none (or a non-character expression) were provided.

invalid subscript (not an array or too many subscripts):
identifier

The subscript operators “[” and “]” are only valid with arrays.
The number of square bracket pairs may not exceed the number of
dimensions of the array.

invalid expression, assumed zero
The compiler could not interpret the expression.

compound statement not closed at the end of file (started
at line number)

An unexpected end of file occurred. One or more compound
statements are still unfinished (i.e. the closing brace “}” has not
been found). The line number where the compound statement
started is given in the message.

unknown directive
The character “#” appears first at a line, but no valid directive
was specified.

array index out of bounds
The array index is larger than the highest valid entry of the array.

array must be indexed (variable name)
An array as a whole cannot be used in a expression; you must
indicate an element of the array between square brackets.
argument does not have a default value (argument index)
You can only use the argument placeholder when the function
definition specifies a default value for the argument.

argument type mismatch (argument index)
The argument that you pass is different from the argument that the
function expects, and the compiler cannot convert the passed-in
argument to the required type. For example, you cannot pass the
literal value “1” as an argument when the function expects an
array or a reference.

empty statement
The line contains a semicolon that is not preceded by an expression.
pawn does not support a semicolon as an empty statement, use an
empty compound block instead.

invalid string (possibly non-terminated string)
A string was not well-formed; for example, the final quote that
ends a string is missing, or the filename for the #include directive
was not enclosed in double quotes or angle brackets.

extra characters on line
There were trailing characters on a line that contained a directive
(a directive starts with a # symbol, see page 116).

constant symbol has no size
A variable has a size (measured in a number of cells), a constant
has no size. That is, you cannot use a (symbolic) constant with
the sizeof operator, for example.

duplicate “case” label (value value)
A preceding “case label” in the list of the switch statement
evaluates to the same value.

041 invalid ellipsis, array size is not known
You used a syntax like “arr[] = { 1, ... };”, which is invalid,
because the compiler cannot deduce the size of the array from the
declaration.

invalid combination of class specifiers
A function or variable is denoted as both “public” and “native”,
which is unsupported. Other combinations may also be unsupported;
for example, a function cannot be both “public” and
“stock” (a variable may be declared both “public” and “stock”).

character constant value exceeds range for a packed string/array
When the error occurs on a literal string, it is usually an attempt
to store a Unicode character in a packed string where a packed
character is 8-bits. For a literal array, one of the constants does
not fit in the range for packed characters.
positional parameters must precede all named parameters
When you mix positional parameters and named parameters in a
function call, the positional parameters must come first.
too many function arguments
The maximum number of function arguments is currently limited
to 64.

unknown array size (variable name)
For array assignment, the size of both arrays must be explicitly
defined, also if they are passed as function arguments.

array sizes do not match, or destination array is too small
For array assignment, the arrays on the left and the right side of the
assignment operator must have the same number of dimensions.
In addition:
⋄ for multi-dimensional arrays, both arrays must have the same
size —note that an unpacked array does not fit in a packed array
with the same number of elements;
⋄ for single arrays with a single dimension, the array on the left
side of the assignment operator must have a size that is equal or
bigger than the one on the right side.
When passing arrays to a function argument, these rules also hold
for the array that is passed to the function (in the function call)
versus the array declared in the function definition.
When a function returns an array, all return statements must
specify an array with the same size and dimensions.

array dimensions do not match
For an array assignment, the dimensions of the arrays on both sides
of the “=” sign must match; when passing arrays to a function
argument, the arrays passed to the function (in the function call)
must match with the definition of the function arguments.
When a function returns an array, all return statements must
specify an array with the same size and dimensions.

invalid line continuation
A line continuation character (a backslash at the end of a line) is
at an invalid position, for example at the end of a file or in a single
line comment.

invalid range
A numeric range with the syntax “n1 .. n2”, where n1 and n2
are numeric constants, is invalid. Either one of the values in not a
valid number, or n1 is not smaller than n2.

invalid subscript, use “[ ]” operators on major dimensions
and for named indices

You can use the “character array index” operator (braces: “{ }”
only for the last dimension, and only when indexing the array with
a number. For other dimensions, and when indexing the array
with a “symbolic index” (one that starts with a “.”), you must use
the cell index operator (square brackets: “[ ]”).

multi-dimensional arrays must be fully initialized
If an array with more than one dimension is initialized at its
declaration, then there must be equally many literal vectors/subarrays
at the right of the equal sign (“=”) as specified for the major
dimension(s) of the array.

exceeding maximum number of dimensions
The current implementation of the pawn compiler only supports
arrays with one or two dimensions.

unmatched closing brace
A closing brace (“}”) was found without matching opening brace
(“{”).

start of function body without function header
An opening brace (“{”) was found outside the scope of a function.
This may be caused by a semicolon at the end of a preceding
function header.

arrays, local variables and function arguments cannot be public
A local variable or a function argument starts with the character
“@”, which is invalid.

Unfinished expression before compiler directive
Compiler directives may only occur between statements, not inside
a statement. This error typically occurs when an expression
statement is split over multiple lines and a compiler directive
appears between the start and the end of the expression. This is
not supported.

duplicate argument; same argument is passed twice
In the function call, the same argument appears twice, possibly
through a mixture of named and positional parameters

Thats it, will post more tomorrow morning.
Reply
#2

And anyone who wanted could just open the pawn-lang.pdf and read all that stuff, with proper formatting.
Reply
#3

Good tutorial. But you could put examples for every error and how to fix them if theres a fix, which would help alot of newbies. 8/10 Nice tutorial.
Reply
#4

I love how you just simply copied a part of errors list out of the Pawn guide. What's the fun in that? Can't people look in the guide for themselves?
Reply
#5

Great copy and paste.

Код:
operator cannot be redefined

Only a select set of operators may be redefined, this operator is
not one of them. See page 84 for details.
Reply
#6

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Great copy and paste.

Код:
operator cannot be redefined

Only a select set of operators may be redefined, this operator is
not one of them. See page 84 for details.
It is a copy-paste indeed, i already stated that in my thread..
And anyone who does not know about Pawn guide, what about them?
I just tried to simplify things for people tell me if you dont want me to include more fixes for errors and warnings?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)