Compiler Error Messages


A Compiler Error is the term used to describe a mistake in the syntax of your script. A syntax error is discovered by the Lua compiler and results in a message being printed in the Mira Script Messages window. These errors are discovered when Lua is in the process of converting your script into a sequence of machine instructions. In comparison, a run-time error occurs when a script having correct syntax is executing the machine instructions.

This topic describes the compiler error messages you may get from the Lua compiler. Since Mira allows you to directly run a script from the Script Editor, a good way to learn about scripting errors is by interactively corrupting and running a script. Just insert a mistake into the script, click btnexecute.png to run it, and examine the resulting error message. You can do this repeatedly to learn about how different kinds of errors result in specific error messages—just be sure not to save the corrupted script files!

Also see typical compiler error messages.

Message Format

Lua error messages list the module name ("chunk"), the line number, and the error that was encountered. Notice that the named chunk may not be the same as the main script you are running. The line number can lead you directly to the error, or it may indicate an error that actually began many lines earlier. This happens because the compiler discovers the error when it can no longer follow a pattern of allowed tokens. When the compiler reaches this "dead end", it raises the error. Such problems usually result from a misplaced " or ' which the compiler interpreted as the beginning of a string.

For example, here is an example of a typical compiler message. The important parts are outlined in red:

           

From this message, we see that the error occurred in the source file CMyClass.lua, which is the main source file for the script. We also see that a string begun on line 23 was not terminated before the compiler reached the end of this chunk. The string would have been terminated when another " was reached.

Most well written scripts will include other source files, or "chunks" of code. In case there is a bug in an included chunk, the compiler lists an error message in a different format, listing both the calling module and the include module in the error message:

Notice that the offending module is listed with a path to the file containing the offending chunk (here, we have shortened the file path by inserting ... into the name). Notice that this error message does not list the line number in the current file. You have to get the included chunk working correctly first, then the compiler will tell you about any errors that may exist in the calling module.

Note

When correcting a message in the source file of an included chunk, be sure to save the changes, otherwise the script will simply re-load the original file containing the same error.

Related Topics

Typical Compiler Error Messages, Overview of Mira Pro x64 Script Language


Mira Pro x64 Script User's Guide, Copyright â’¸ 2023 Mirametrics, Inc. All Rights Reserved.