> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Compiler messages

> The messages a Lipi writer meets most, grouped by cause, with what each means and how to fix it.

A message names the line and column; names in backticks stand for the name in your script. Fix the first error and check again: a script with several syntax errors reports only the last, and after a clean syntax most checks stop at the first error.

The **editor's check** reports syntax, names, types and scope. **Adding to the chart** also applies the compile-only rules below. **Running** raises the runtime errors, on a bar.

## Syntax

| Message | Meaning and fix |
| - | - |
| `no viable alternative at input '\n+'` | A line starts with an operator, so the line before already ended the statement. End that line with the operator. |
| `extraneous input ';' expecting {<EOF>, NEWLINE}` | A token that cannot follow a complete statement: `;`, `^`, a second statement on the line. One statement per line; `math.pow` for a power. |
| `mismatched input 'x' expecting {'}', NEWLINE}` | A block on one line, or a token out of place. Put each statement of a block on its own line. |
| `token recognition error at: '@'` | A character that is not part of Lipi. Remove it. |
| `var` is not a valid type in variable declaration. | `var`, `varip`, `map<...>` and other unknown types. Use `static`, or `array<float>`. |
| Type Function should have at least one parameter. | A `def` with no parameter. Use `func`. |
| Break statement can only be used inside a loop. | Likewise `Continue statement ...` and `Return statement can only be used inside a function.` Move the statement into the loop or function. |
| `if` conditional expression must be of a bool type! | The condition is a string. Use a comparison (`while` has the same message). |
| Script must declare exactly one of `indicator()`, `strategy()`, or `library()`; found 2 (indicator(), indicator()). | No declaration (`found 0 ((none))`), or two. Keep one. |

## Names

| Message | Meaning and fix |
| - | - |
| No variable with name `clsoe` found. | Misspelt, undeclared or out of scope (a block's variables end with the block); or a namespace Lipi lacks (`request`, `timeframe`). |
| Undeclared variable `x`. | `:=` on a name never declared. Declare it with `=`. |
| Variable `x` is already defined. Use `:=` to assign a new value. | `=` on a name already in this scope. |
| Namespace `talib` has no function `foo`. Did you mean `cmo()`? | Not in the namespace; take the hint. Same form for variables: Namespace `color` has no variable `pink`. Did you mean `lime`? |
| Function `g` is not available here. Functions must be defined before use, and cannot call themselves. | Declare a function above its first call; there is no recursion. |

## Types and qualifiers

| Message | Meaning and fix |
| - | - |
| Declared type `int` is not compatible with assigned type `const float`. | The value does not fit the type. Use `math.floor()`, `math.round()` or `math.ceil()` to get an `int`. |
| Cannot call `plot` with argument `linewidth`=`bar_index`. An argument of `series int` type was used but a `input int` is expected. | The parameter wants a fixed value (`const`, `input`, `simple`), the argument changes per bar. Use a literal or an input. |
| Argument `defval` of `input.int()` cannot be `na`. | An input default must be a value. |
| `volume` is not a valid source variable. Expected: open/high/low/close/hl2/hlc3/ohlc4/hlcc4 | The default of `input.source` is one of those eight. |

## Arguments and scope

| Message | Meaning and fix |
| - | - |
| The `plot()` function does not accept a named argument `colour`. Did you mean `color`? | Misspelt argument name. |
| The `talib.sma()` function is missing required argument(s): `length`. | A required argument is missing. |
| Cannot modify global variable `g` in function. | A function cannot reassign a global. Pass it in and return the result; pushing to a global array or setting a field of a global object is allowed. |
| `plot()` must be called in the global scope. | `plot`, `plotshape`, `plotchar`, `plotarrow`, `plotbar`, `plotcandle`, `hline`, `fill`, `bgcolor`, `barcolor`, `alertcondition` cannot sit in a function, `if`, loop or `switch`. Put the condition in an argument: `bgcolor(c ? color.green : na)`. |
| internal validator error | No line: the compiler stopped. Known cause: a size string that is not a size name (`size="enormous"`; `text_size` on `box.new` and `table.cell`) on `label.new`, `box.new`, `table.cell`, `plotchar` or `plotshape`. Use `size.tiny` ... `size.huge`. |
| History Indexing not allowed on tuple expression. | `[]` cannot follow a tuple, a void call or a literal. Assign it to a variable first. |

## Compile-path-only rules

These pass the editor's check and fail when the script is added to the chart (the phases are in [The editor](https://gocharting.com/docs/scripting/getting-started/editor.md)).

`indicator("Mintick", format=format.mintick)` gives, when adding to the chart: The `format` argument of `indicator()` only accepts format.inherit, format.price, format.volume, or format.percent. Got `format.mintick`. The same phase refuses a `plot` or `hline` `format` other than `format.price`, `format.percent`, `format.volume`; any `display` but `display.none` and `display.all` on `fill`, `barcolor`, `bgcolor`; an `indicator()` title over 128 characters; and `input.time(timestamp("2024-01-01"))`, since `timestamp()` is `na` there (Argument `defval` of `input.time()` cannot be `na`.): give milliseconds; and a length above 500 in `talib.ema`, `macd`, `bbw`, `kc` or `kcw` (the history message on Limits); and a `switch` inside a called function, which is refused with only Not Implemented (use `if`).

## Runtime errors

These stop the script on a bar. The limit messages (history range 0 to 500, array size 10000, 45 seconds) are on [Limits](https://gocharting.com/docs/scripting/distribution/limits.md).

| Message | Cause |
| - | - |
| Index out of bounds: 5, array length: 3. | An array index below 0 or past the last element. Test `array.length` first. |
| Invalid order quantity | `strategy.exit` with `qty` of zero or less, or a default size that cannot be worked out (`default_qty_value` of zero or less; `cash`/`percent_of_equity` with no price). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.