Difference between revisions of "Compiler error message"
From Dragon Age Toolset Wiki
m (Fixed rogue comment tag.) |
m (Added some new messages) |
||
Line 1: | Line 1: | ||
When the compiler encounters a syntax error it aborts the process for that script and displays a '''compiler error message''' in the [[Log window panel|Log window]]. | When the compiler encounters a syntax error it aborts the process for that script and displays a '''compiler error message''' in the [[Log window panel|Log window]]. | ||
− | There are a couple of guidelines to remember when trying compiler error message: | + | There are a couple of guidelines to remember when trying to understand compiler error message: |
* The compiler reports the error when it can no longer make sense of the script: this often occurs on the line '''after'' the line containing the error. | * The compiler reports the error when it can no longer make sense of the script: this often occurs on the line '''after'' the line containing the error. | ||
* If the script has one or more include files the error may have "'''while compiling <include>.nss'''" appended to it, however the error may be in the script being compiled rather than an include file. | * If the script has one or more include files the error may have "'''while compiling <include>.nss'''" appended to it, however the error may be in the script being compiled rather than an include file. | ||
+ | == Messages == | ||
+ | The following is a list of compiler error messages that have been encountered and what caused them. It is important to be aware that these may not be the only cause for a particular error and therefore should be viewed as examples rather than definitions. | ||
{{TOC}} | {{TOC}} | ||
Line 14: | Line 16: | ||
=== <span id="B">B</span> === | === <span id="B">B</span> === | ||
; Break outside of loop or case statement | ; Break outside of loop or case statement | ||
− | : [ | + | : [example]. |
<!-- | <!-- | ||
Line 27: | Line 29: | ||
=== <span id="E">E</span> === | === <span id="E">E</span> === | ||
; Equality test has invalid operands | ; Equality test has invalid operands | ||
− | : [ | + | : [example]. |
+ | |||
+ | === <span id="F">F</span> === | ||
+ | ;Function definition missing parameter list | ||
+ | :The brackets were omitted when defining a function. | ||
<!-- | <!-- | ||
− | |||
=== <span id="G">G</span> === --><!-- | === <span id="G">G</span> === --><!-- | ||
=== <span id="H">H</span> === --> | === <span id="H">H</span> === --> | ||
Line 36: | Line 41: | ||
# An include file does not exist or has not been saved. | # An include file does not exist or has not been saved. | ||
# The wrong file name used or the ".nss" extension included in an [[#include]] directive. | # The wrong file name used or the ".nss" extension included in an [[#include]] directive. | ||
− | : NOTE: include files cannot not be compiled (attempting to do so will generate a [[#S|Script must contain either a main or StartingConditional]] error). | + | : NOTE: include files cannot not be compiled directly (attempting to do so will generate a [[#S|Script must contain either a main or StartingConditional]] error). |
+ | |||
+ | ;Invalid declaration type | ||
+ | :The brackets were omitted when declaring a function. | ||
<!-- | <!-- | ||
=== <span id="J">J</span> === --><!-- | === <span id="J">J</span> === --><!-- | ||
Line 52: | Line 60: | ||
=== <span id="N">N</span> === | === <span id="N">N</span> === | ||
; No colon after case label | ; No colon after case label | ||
− | : [ | + | : [example]. |
; No left bracket on arg list | ; No left bracket on arg list | ||
Line 60: | Line 68: | ||
# The statement terminator (;) is missing from the end of an expression. | # The statement terminator (;) is missing from the end of an expression. | ||
# A keyword in an expression contains a typo. | # A keyword in an expression contains a typo. | ||
+ | |||
+ | ;No semicolon after structure | ||
+ | # The statement terminator (;) is missing from the end of a structure definition. | ||
; Not all control paths return a value | ; Not all control paths return a value | ||
Line 86: | Line 97: | ||
;Undefined structure | ;Undefined structure | ||
− | : A [[ | + | : A [[struct keyword|struct]] is being used before it is defined. |
;Unknown state in compiler | ;Unknown state in compiler | ||
Line 99: | Line 110: | ||
# A value is being assigned to a variable before it has been declared. | # A value is being assigned to a variable before it has been declared. | ||
# A variable is being assigned or passed into a function before it has been declared. | # A variable is being assigned or passed into a function before it has been declared. | ||
+ | |||
+ | ;Void expression where non void required | ||
+ | : Assigned a member of a [[vector]] which was itself a member of a [[struct keyword|struct]] to a variable. | ||
<!-- | <!-- | ||
=== <span id="W">W</span> === --><!-- | === <span id="W">W</span> === --><!-- |
Revision as of 13:39, 13 April 2020
When the compiler encounters a syntax error it aborts the process for that script and displays a compiler error message in the Log window.
There are a couple of guidelines to remember when trying to understand compiler error message:
- The compiler reports the error when it can no longer make sense of the script: this often occurs on the line 'after the line containing the error.
- If the script has one or more include files the error may have "while compiling <include>.nss" appended to it, however the error may be in the script being compiled rather than an include file.
Messages
The following is a list of compiler error messages that have been encountered and what caused them. It is important to be aware that these may not be the only cause for a particular error and therefore should be viewed as examples rather than definitions.
Contents |
---|
A
- After compound statement at end
- The double quote before the file name is missing from an #include directive.
B
- Break outside of loop or case statement
- [example].
D
- Declaration does not match parameters
- The wrong type of argument used when calling a function, e.g. a string passed into a int argument.
- Declaration does not match parameters (<function>)
- Too few or too many arguments used when calling a function.
E
- Equality test has invalid operands
- [example].
F
- Function definition missing parameter list
- The brackets were omitted when defining a function.
I
- Included file not found
- An include file does not exist or has not been saved.
- The wrong file name used or the ".nss" extension included in an #include directive.
- NOTE: include files cannot not be compiled directly (attempting to do so will generate a Script must contain either a main or StartingConditional error).
- Invalid declaration type
- The brackets were omitted when declaring a function.
M
- Mismatched types
- A value or variable is assigned to a variable of a different type, e.g. a string value assigned to an int varaible.
- A function is assigned to a variable of a different type, e.g. a [[string] function to assigned to an int variable.
- A function returns a different type from its declared return type.
- A void function is assigned to a variable.
N
- No colon after case label
- [example].
- No left bracket on arg list
- The brackets were omitted when calling a function (without arguments).
- No semicolon after expression
- The statement terminator (;) is missing from the end of an expression.
- A keyword in an expression contains a typo.
- No semicolon after structure
- The statement terminator (;) is missing from the end of a structure definition.
- Not all control paths return a value
- A function does not have a return statement.
- A logic branch in a function does not have a return statement.
- A function does not have an else or default case with a return function.
P
- Parsing variable list
- The statement terminator (;) is missing from the on previous line.
- A line contains a rogue double-quotes mark.
S
- Script must contain either a main or StartingConditional
- Compiled an include file directly (instead of the script including it).
- Used the incorrect case i.e. Main instead of main.
U
- Undefined identifier (<identifier>)
- A variable is being used before it is defined.
- A string is missing its opening double-quotes mark.
- Undefined structure
- A struct is being used before it is defined.
- Unknown state in compiler
- Invalid syntax e.g. an extra comma in a list of arguments.
- Unterminated string constant
- A string is missing its closing double-quotes mark.
- A line contains a rogue double-quotes mark.
V
- Variable defined without type
- A value is being assigned to a variable before it has been declared.
- A variable is being assigned or passed into a function before it has been declared.