Error messages

# Compile errors and warnings

Q: What is the difference between a compile error and a warning.

A: A warning usually indicates that the fix may involve adding some more code, for example adding a definition for an unknown identifier. An error usually indicates that you will need to alter code to fix the error. But they are similar in that you will not be able to run your program until the issues are fixed. In all programming languages it is a good practice 'treat all compile warnings as errors' i.e. fix them as soon as you see them appear.

## Expression must be ...

An expression, when evaluated, results in a value of a type that is not compatible with its 'target', for example: if the result of the expression is being assigned to an existing variable, or if an expression is defined 'inline' as an argument into a method call.

## Cannot use 'this' outside class context

`thisthisthisthisthis` may only be used within an instance method on a class to refer to the current instance.

## Abstract class ... must be declared before it is used

If a class inherits from one or more abstract classes, then the latter must all have already been declared (defined) earlier in the code file.

## Member ... must be of type ...

This error occurs when a class is defined as inheriting from an abstract class, and has implemented an inherited member (method or property) with the correct name, but with different Types.

## Incompatible types. Expected: ... Provided: ...

## Cannot determine common type between ... and ...

## ... is not defined for type ...

Arises when 'dot calling' a member (method or property) that does not exist on the type of the named value or expression before the dot.

## Cannot call a function as a procedure

A function (or function method) is to be used within an expression, not via a procedure call.

## Cannot use a system method in a function

A 'system method' (defined in the Standard Library) returns a value like a function does. However, because a system method either makes changes to the system and/or depends on external inputs, it may be used only within a procedure or the main routine.

## Code change required ...

Indicates that a library method or class has been changed since the version in which your Elan code was written. The link in the message should take you directly to information in the Library Reference documentation on how to update your code to cope with the change.

## Cannot call procedure ... within an expression

A procedure may be used only within a procedure call instruction.

## Cannot invoke ... as a method

The code is attempting to use a free-standing method (function or procedure) as a 'dot method' on a named value or the result of an expression.

## Cannot ...index ...

An index (in square brackets) may be applied only to certain data structure Types: `StringstrstringStringString`, `ListlistListListList` and `DictionaryDictionaryDictionaryDictionaryDictionary`.

## Cannot range ...

A range may be applied only to certain data structure Types: `StringstrstringStringString` and `ListlistListListList`.

## Cannot new ...

The type specified cannot be instantiated. Either the type is a standard language value type, or it is a user-defined abstract class.

## May inherit from one abstract superclass only

The message is self explanatory.

## class ... cannot inherit from itself

The message is self explanatory.

## May inherit from one abstract superclass only.

The message is self explanatory.

## Cannot reference private member ...

A private member (method or property) may be accessed only by code within the class, or within subclasses of it. It may not be accessed by any code outside the class hierarchy.

## ... must implement ...

If a concrete class inherits from any abstract class it must implement all abstract methods defined in the abstract type (or in any super-type of the abstract class).

## ... must be concrete to new

You cannot create an instance of any abstract class: only of a concrete class.

## Cannot call extension method directly

A method that is defined within the Library as an extension method, such as toString, may be called on a named value or an expression only using dot syntax .

## Cannot prefix function with 'property'

The prefix property. may only be used before a property name: not a function name.

## Missing argument(s) ...

The method being called expects more arguments than have been provided.

## Too many argument(s) ...

A method has been passed more arguments than it expects.

## Argument types ...

One or more arguments provided to the method are of the wrong Type.

## ...<of Type>...

Certain data structure Types, including `ListlistListListList`, must specify the type of their members, for example `ListlistListListList`<of `IntintintIntegerint`>. Failure to specify the '<of Type>' on these Types will give an error, as will specifying 'of Type' where it is not required. Dictionaries require Types to be specified for both the keys and the values, for example: `DictionaryDictionaryDictionaryDictionaryDictionary`<of `StringstrstringStringString`, `FloatfloatdoubleDoubledouble`>.

## May not reassign the ...

Attempting to assign, or mutate, a named value that may not be assigned in the current context.

## Name ... not unique in scope ...

Attempting to create an identifier with the same name as one already defined within the same scope.

## May not set ... in a function

A property can be reassigned only within a procedure method, not within a function, because reassigning a property is a side effect.

## The identifier ... is already used for a ... and cannot be re-defined here.

An existing named value may not be defined again within the same scope.

## Duplicate Dictionary key(s)

Attempting to define a literal `DictionaryDictionaryDictionaryDictionaryDictionary` with one or more duplicated keys in the definition.

## a comment may not start with [ unless it is a recognised compiler directive

Compiler directives are a planned future capability. They will look like comments, but begin with an open square bracket. To avoid the possibility of ambiguity, you may not start your own comments with an open square bracket.

## Condition of 'if' expression does not evaluate to a Boolean.

## Cannot have any clause after unconditional 'else'.

## ... is a reserved word, and may not be used as an identifier.

Most programming languages define keywords, or other 'reserved words' that may not be used as identifiers - for technical reasons. Because Elan supports multiple programming languages and guarantees that any program written in one language will convert correctly to the other languages, it must disallow the use of keywords from any of the supported languages - not just the ones defined by the language you are writing. Fortunately many of the keywords are common to more than one of the languages.

If you see this message, just alter the identifier you have defined - by extending the word, perhaps even just by adding an underscore - or choose a different word altogether.

## Index cannot be negative.

An index into a list cannot have a negative value. If a negative is given in literal form e.g. a[−3] then this will generate a compile error. If you use a named value for an index and it is negative, then this will cause a runtime error.

## Cannot do equality operations on Procedures or Functions.

It is not possible to apply comparison operations to functions or procedures as themselves. It is, however, possible to compare the results of two function evaluations. You may see this message because you intended to evaluate a function but forgot to add the brackets after the name.

## ... cannot have key of type ...

The type of the key for any dictionary Dictionary  must be an immutable Type, and not itself an indexable Type.

## Wrong number of deconstructed variables.

## referencing a property requires a prefix.

If you are referring to a property of a class from code defined within the class then the property name must be preceded by property.

## 'out' parameters are only supported on procedures.

You cannot defined an out parameter in a function (because that would imply the possibility of creating a side effect).

## There can only be one main routine in a program.

## Unsupported operation.

You cannot chain two 'unary' operators (those that apply to a single value), such as − or not successively within an expression.

## Parameter ... may not have the same name as the method in which it is defined.

A function or procedure named e.g. 'foo' may not define a parameter with that same name.

## Code change suggested. Method was deprecated in v7.1.

# Runtime errors

## Tests timed out and were aborted

An error or infinite loop found in a test. Refer to ghosting tests .

## Overly complex expressions

Overly complex expressions, for example involving a sequence of open brackets, can result in very slow parsing. We strongly recommend that you you simplify the contents of this field, for example by breaking out parts of it into separate variable definition instructions; otherwise it might become impossible to add more text.

## ReferenceError: Cannot access '[name]' before initialisation

Elan Language Reference go to the top 