// Generated from spec/errors.json by scripts/generate-error-catalogue.mjs. // What each code says: its severity, its stage, its message and its fix. // Edit the catalogue, not this file. It is not kept in version control, because // a checked-in copy is a second source of truth waiting to drift. import type { CatalogueEntry, Stage } from './types.js'; /** The shape of spec/errors.json that this file was generated from. */ export const CATALOGUE_SCHEMA_VERSION = 1; /** The language version the catalogue describes. */ export const CATALOGUE_LANGUAGE_VERSION = 1; /** The word each stage is printed as, so a reader is told which part of the compiler spoke. */ export const STAGE_LABELS = { lex: "lexer", parse: "parser", check: "checker", runtime: "engine", host: "host", import: "importer", } as const satisfies Readonly>; export const ENTRIES = { OS1001: { code: "OS1001", title: "Unexpected character", severity: "error", stage: "lex", since: 1, autofix: true, message: "Unexpected character {char}. {suggestion}", fix: "Delete the character or replace it with the plain ASCII spelling the message names: a plain space for a non-breaking space, a straight quote for a typographic one, not for !, and for &&, or for ||, pow(a, b) for ^.", placeholders: ["char", "suggestion"] }, OS1002: { code: "OS1002", title: "Tab in indentation", severity: "error", stage: "lex", since: 1, autofix: true, message: "This line is indented with a tab.", fix: "Replace the leading tabs with spaces. Four spaces per level is the convention and the formatter's output.", placeholders: [] }, OS1003: { code: "OS1003", title: "Indentation does not match this block", severity: "error", stage: "lex", since: 1, autofix: true, message: "This line is indented {found} spaces; the block opened at line {line} is indented {expected}.", fix: "Indent this line to {expected} spaces to keep it in the block, or to {line}'s own indentation to end the block here.", placeholders: ["found", "expected", "line"] }, OS1004: { code: "OS1004", title: "Unterminated string literal", severity: "error", stage: "lex", since: 1, autofix: false, message: "This string literal opens with {quote} and the line ends before a matching {quote}.", fix: "Close the string with a matching {quote} before the end of the line, and join text across lines with + and a continuation.", placeholders: ["quote"] }, OS1005: { code: "OS1005", title: "Unknown escape sequence", severity: "error", stage: "lex", since: 1, autofix: true, message: "{sequence} is not an escape sequence.", fix: "Double the backslash to write one literally, or use one of the escapes the language defines.", placeholders: ["sequence"] }, OS1006: { code: "OS1006", title: "Assignment used as a condition", severity: "error", stage: "parse", since: 1, autofix: true, message: "= assigns a value, and a condition needs a comparison.", fix: "Write == to compare, or move the assignment to its own line above the if.", placeholders: [] }, OS1007: { code: "OS1007", title: "Semicolon", severity: "error", stage: "lex", since: 1, autofix: true, message: "; is not part of the language.", fix: "Delete the ; and put the second statement on its own line.", placeholders: [] }, OS1008: { code: "OS1008", title: "Chained comparison", severity: "error", stage: "parse", since: 1, autofix: false, message: "A comparison cannot be chained: {op1} is already applied before {op2}.", fix: "Split it with and, naming the middle value twice: a < b and b < c.", placeholders: ["op1", "op2"] }, OS1009: { code: "OS1009", title: "break or continue outside a loop", severity: "error", stage: "parse", since: 1, autofix: false, message: "{word} is only valid inside a for or a while body.", fix: "Move it inside the loop body, or write return to leave a function early.", placeholders: ["word"] }, OS1010: { code: "OS1010", title: "Block header with no body", severity: "error", stage: "parse", since: 1, autofix: true, message: "{header} opens a block, and the next line is not indented more deeply.", fix: "Indent the body under the header, or delete the header line if the body is genuinely empty.", placeholders: ["header"] }, OS1011: { code: "OS1011", title: "var with no initial value", severity: "error", stage: "parse", since: 1, autofix: true, message: "var {name} has no initial value.", fix: "Give it a starting value; var {name} = none is the empty start.", placeholders: ["name"] }, OS1012: { code: "OS1012", title: "Bracket is never closed", severity: "error", stage: "parse", since: 1, autofix: false, message: "The {bracket} opened at line {line} is never closed.", fix: "Add the matching closer at the end of the argument list on line {line}.", placeholders: ["bracket", "line"] }, OS1013: { code: "OS1013", title: "Mismatched closing bracket", severity: "error", stage: "parse", since: 1, autofix: true, message: "Found {found} where {expected} was expected, closing the {opener} opened at line {line}.", fix: "Change {found} to {expected}, which is what closes the {opener} opened at line {line}.", placeholders: ["found", "expected", "opener", "line"] }, OS1014: { code: "OS1014", title: "Missing comma between arguments", severity: "error", stage: "parse", since: 1, autofix: true, message: "Two arguments run together; a comma is missing before {token}.", fix: "Put a comma between the two arguments.", placeholders: ["token"] }, OS1015: { code: "OS1015", title: "Ternary with no second arm", severity: "error", stage: "parse", since: 1, autofix: false, message: "This ? has no matching :", fix: "Give the ternary both arms, and use none for the arm that should draw nothing.", placeholders: [] }, OS1016: { code: "OS1016", title: "else does not follow an if", severity: "error", stage: "parse", since: 1, autofix: true, message: "This else is indented {found} spaces and the nearest if is indented {expected}.", fix: "Line the else up with its if, at {expected} spaces.", placeholders: ["found", "expected"] }, OS1017: { code: "OS1017", title: "case or default in the wrong place", severity: "error", stage: "parse", since: 1, autofix: false, message: "{word} is only valid inside a switch, and default must be its last arm.", fix: "Move the arm inside the switch block, and put default after every case.", placeholders: ["word"] }, OS1018: { code: "OS1018", title: "More than one statement on a line", severity: "error", stage: "parse", since: 1, autofix: false, message: "Unexpected {token} after the end of this statement.", fix: "Put {token} and what follows it on its own line, or supply the operator that was meant to join them.", placeholders: ["token"] }, OS1019: { code: "OS1019", title: "Reserved word used as a name", severity: "error", stage: "parse", since: 1, autofix: false, message: "{word} is a reserved word and cannot be used as a name.", fix: "Rename it; {suggestion} keeps the meaning and is not reserved.", placeholders: ["word", "suggestion"] }, OS1020: { code: "OS1020", title: "Incomplete for header", severity: "error", stage: "parse", since: 1, autofix: false, message: "A for header needs = start to end or in array; found {token}.", fix: "Write for i = 0 to size(values) - 1 for a counted loop, or for v in values to visit elements.", placeholders: ["token"] }, OS1021: { code: "OS1021", title: "The version declaration is not first", severity: "error", stage: "parse", since: 1, autofix: true, message: "version must be the first line that is not blank and not a comment; line {line} came before it.", fix: "Move the version line to the top of the file, above the study or strategy declaration.", placeholders: ["line"] }, OS1022: { code: "OS1022", title: "Expression expected", severity: "error", stage: "parse", since: 1, autofix: false, message: "An expression was expected after {token}.", fix: "Supply the missing operand, or delete the trailing {token}.", placeholders: ["token"] }, OS1023: { code: "OS1023", title: "A function declared inside a block", severity: "error", stage: "parse", since: 1, autofix: false, message: "fn {name} is declared inside a block, and a function is declared at the top level of the file.", fix: "Move the whole declaration out to the top level of the file, and call {name} from inside the block.", placeholders: ["name"] }, OS1024: { code: "OS1024", title: "Assignment to an indexed element", severity: "error", stage: "parse", since: 1, autofix: false, message: "An assignment writes to a name, and this target is an index into {name}.", fix: "Change an array element with set({name}, i, v), or assign to a plain name: the past of a series is computed and never written.", placeholders: ["name"] }, OS1025: { code: "OS1025", title: "Assignment to a member", severity: "error", stage: "parse", since: 1, autofix: false, message: "An assignment writes to a name, and this target is the member {member} of {name}.", fix: "Assign to a plain name. Version 1 has no member assignment: a dot reads a member, and the members a script can reach are facts and functions the library and the host supply.", placeholders: ["name", "member"] }, OS1026: { code: "OS1026", title: "Block comment", severity: "error", stage: "lex", since: 1, autofix: false, message: "{marker} does not open or close a comment. A comment is written // and runs to the end of its line.", fix: "Write // instead, and give every line of a commented region its own //, which every editor does with one keystroke.", placeholders: ["marker"] }, OS1027: { code: "OS1027", title: "Malformed colour literal", severity: "error", stage: "lex", since: 1, autofix: false, message: "{written} is not a colour: a colour literal is # and six or eight hexadecimal digits.", fix: "Give it six hexadecimal digits, or eight where the last two are the alpha byte. A named colour or rgb(r, g, b) says the same thing without the digits.", placeholders: ["written"] }, OS1028: { code: "OS1028", title: "A continuation line is not indented past its statement", severity: "error", stage: "lex", since: 1, autofix: true, message: "A continuation line must be indented more deeply than the line its statement began on; line {line} is indented {statement} and this line is indented {found}.", fix: "Indent this line further than the {statement} spaces on line {line}. Four more is the convention and the formatter's output.", placeholders: ["found", "statement", "line"] }, OS1029: { code: "OS1029", title: "A name written against a number", severity: "error", stage: "lex", since: 1, autofix: false, message: "{written} is neither a number nor a name: the number literal ends at {number}, and a name cannot begin with a digit.", fix: "Write the value in a form the language has: a decimal literal, or 0x and hexadecimal digits. There is no binary form and no octal form, and an underscore separates digit groups only where a digit follows it. Where a number and a name were meant as two things, put an operator between them.", placeholders: ["written", "number"] }, OS2001: { code: "OS2001", title: "Name is not defined here", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is not defined at this point in the file.", fix: "Assign {name} above this line, move this line below its assignment, or correct the spelling to {suggestion}.", placeholders: ["name", "suggestion"] }, OS2002: { code: "OS2002", title: "The name already exists in an enclosing scope", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is already declared at line {line}, so a second one cannot be declared here.", fix: "Rename this one, or drop the inner declaration and let the assignment update the {name} at line {line}.", placeholders: ["name", "line"] }, OS2003: { code: "OS2003", title: "Types do not match", severity: "error", stage: "check", since: 1, autofix: false, message: "{leftType} and {rightType} do not mix here.", fix: "Convert explicitly: text(x) for a string, or text(x, decimals) to fix the decimals. Where no conversion applies, write the value in the type the line needs, or give the second value a name of its own. A plot, fill or level handle converts to nothing: leave it named at the top level, pass it to fill(), and use draw.line() or draw.box() where the script needs something it can keep.", placeholders: ["leftType", "rightType"] }, OS2004: { code: "OS2004", title: "This value has no history", severity: "error", stage: "check", since: 1, autofix: false, message: "{expr} has no history, so [] cannot read a past value of it.", fix: "If the value is a per-bar number computed inside a block or left as a temporary, assign it at the top level of the file and read the history of that top level name. If it is a declaration handle, a runtime object or a library fact that is not a series, no name gives it a history: assign what you want to look back at to a top level name of its own, and read that.", placeholders: ["expr"] }, OS2005: { code: "OS2005", title: "Recursive call", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} calls itself: {cycle}.", fix: "Rewrite it as a loop, or split the work into two functions that do not call each other.", placeholders: ["name", "cycle"] }, OS2006: { code: "OS2006", title: "Assignment to a loop variable", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is this loop's variable and cannot be assigned inside the body.", fix: "Use break to leave early, or keep a separate name for the value the body changes.", placeholders: ["name"] }, OS2007: { code: "OS2007", title: "The file has no declaration", severity: "error", stage: "check", since: 1, autofix: false, message: "A file needs one study() or strategy() declaration before any other statement.", fix: "Add study(\"Name\") as the first statement, or strategy(\"Name\") if the file places orders.", placeholders: [] }, OS2008: { code: "OS2008", title: "More than one declaration", severity: "error", stage: "check", since: 1, autofix: false, message: "This file already declares {kind} at line {line}.", fix: "Delete this declaration and move the options you wanted onto the one at line {line}.", placeholders: ["kind", "line"] }, OS2009: { code: "OS2009", title: "Unknown member of a namespace", severity: "error", stage: "check", since: 1, autofix: false, message: "{namespace} has no member named {member}.", fix: "Use one of {namespace}'s members; {suggestion} is the closest match to what was written.", placeholders: ["namespace", "member", "suggestion"] }, OS2010: { code: "OS2010", title: "This name is not a function", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is {type}, not a function, so it cannot be called.", fix: "Remove the argument list to read the value, or call the function that was meant: {suggestion}.", placeholders: ["name", "type", "suggestion"] }, OS2011: { code: "OS2011", title: "A condition must be a bool", severity: "error", stage: "check", since: 1, autofix: false, message: "This condition is {type}; a condition must be bool or none.", fix: "Write the test out: {name} > 0 for a count, isNone({name}) for absence, {name} != \"\" for a string.", placeholders: ["type", "name"] }, OS2012: { code: "OS2012", title: "The two arms of the ternary have different types", severity: "error", stage: "check", since: 1, autofix: false, message: "The arms of this ? : are {leftType} and {rightType}.", fix: "Make both arms the same type with text() or toNumber(), or use none for the empty arm.", placeholders: ["leftType", "rightType"] }, OS2013: { code: "OS2013", title: "An array literal mixes types", severity: "error", stage: "check", since: 1, autofix: false, message: "This array holds {firstType} at index 0 and {otherType} at index {index}.", fix: "Make every element {firstType}, or keep two arrays and index them together.", placeholders: ["firstType", "otherType", "index"] }, OS2014: { code: "OS2014", title: "A function cannot be used as a value", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is a function, and version 1 has no function values.", fix: "Call {name} with its arguments and use the value it returns.", placeholders: ["name"] }, OS2015: { code: "OS2015", title: "The element type of this empty array is unknown", severity: "error", stage: "check", since: 1, autofix: false, message: "An empty array literal needs its element type from an annotation or from a first use.", fix: "Annotate the declaration, var hits: array = [], or put the first element in with push(), unshift(), insert() or set() and let the type be read from that call.", placeholders: [] }, OS2016: { code: "OS2016", title: "Unknown type in an annotation", severity: "error", stage: "check", since: 1, autofix: false, message: "{type} is not a type.", fix: "Use number, string, bool, color, array, or an object type (line, label, box, polyline, table), with series in front for a per-bar value.", placeholders: ["type"] }, OS2017: { code: "OS2017", title: "A function with this name is already declared", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is already declared as a function at line {line}.", fix: "Rename one of them, or give the one function a default argument that covers both uses.", placeholders: ["name", "line"] }, OS2018: { code: "OS2018", title: "Duplicate parameter name", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} appears twice in this parameter list.", fix: "Rename the second parameter, so every name in the list appears once.", placeholders: ["name"] }, OS2019: { code: "OS2019", title: "This type cannot be an array element", severity: "error", stage: "check", since: 1, autofix: false, message: "array<{type}> is not a type: {type} cannot be an array element.", fix: "Use an element type an array holds: number, string, bool, color, line, label, box, polyline or table. A plot cannot be kept anywhere, so declare each plot at the top level and give it its own name.", placeholders: ["type"] }, OS2020: { code: "OS2020", title: "Name is planned, not implemented", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is planned and is not implemented in this version.", fix: "Compute what {name} would give from names the library implements today, or take the line out until a version implements it. Do not reach for the nearest name that compiles: a neighbour computes something else, and a plot that quietly changes meaning is worse than one that refuses to compile.", placeholders: ["name"] }, OS3001: { code: "OS3001", title: "Wrong number of arguments", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} takes {expected} arguments and {found} were given.", fix: "Pass the arguments the signature names: {signature}.", placeholders: ["name", "expected", "found", "signature"] }, OS3002: { code: "OS3002", title: "Unknown named argument", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} has no argument called {argument}.", fix: "Use one of {names}; {suggestion} is the closest to what was written.", placeholders: ["name", "argument", "names", "suggestion"] }, OS3003: { code: "OS3003", title: "This option must be a constant", severity: "error", stage: "check", since: 1, autofix: false, message: "{option} is read once, before the first bar, so it cannot depend on bar data.", fix: "Use a literal, or make it tunable with an input(): {option} = input(2, \"{option}\").", placeholders: ["option"] }, OS3004: { code: "OS3004", title: "Argument is not a valid whole number", severity: "error", stage: "check", since: 1, autofix: false, message: "{name}'s {argument} must be a whole number {range}; {found} was given.", fix: "Pass a whole number inside {range}, and wrap a computed value in floor() or round().", placeholders: ["name", "argument", "range", "found"] }, OS3005: { code: "OS3005", title: "Positional argument after a named one", severity: "error", stage: "check", since: 1, autofix: false, message: "A positional argument cannot follow a named one.", fix: "Name this argument too, or move it in front of the first named argument.", placeholders: [] }, OS3006: { code: "OS3006", title: "This call must be at the top level", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} defines part of the study's fixed shape and cannot appear inside {construct}.", fix: "Move the call to the top level and hide it per bar by passing none: plot(cond ? value : none, ...). Inside a request expression, read the value first and draw with it afterwards. A leg is not hidden by passing none: declare it at the top level and decide per bar whether to send it an order.", placeholders: ["name", "construct"] }, OS3007: { code: "OS3007", title: "input() must be at the top level", severity: "error", stage: "check", since: 1, autofix: false, message: "input() builds one row of the settings dialog, which is read once before the first bar.", fix: "Move the input() to the top level and use the name it assigns inside the block.", placeholders: [] }, OS3008: { code: "OS3008", title: "The value is not valid for this parameter", severity: "error", stage: "check", since: 1, autofix: false, message: "{argument} accepts {values}; {found} is not one of them.", fix: "Use one of {values}; {suggestion} is the closest to what was written.", placeholders: ["argument", "values", "found", "suggestion"] }, OS3009: { code: "OS3009", title: "This option needs another option to be set", severity: "error", stage: "check", since: 1, autofix: false, message: "{option} = {value} requires {required}.", fix: "Set {required} in the declaration, or choose a value of {option} that stands on its own.", placeholders: ["option", "value", "required"] }, OS3010: { code: "OS3010", title: "Two arguments that cannot both be given", severity: "error", stage: "check", since: 1, autofix: false, message: "{first} and {second} set the same thing two ways.", fix: "Keep one of the two: an absolute price or a distance from the entry, one colour for the whole band or a colour for each side, and on a leg described as a future neither right nor strikeOffset.", placeholders: ["first", "second"] }, OS3011: { code: "OS3011", title: "Argument has the wrong type", severity: "error", stage: "check", since: 1, autofix: false, message: "{name}'s {argument} is {expected}; {found} was given.", fix: "Convert the value with text(), toNumber() or toBool(), or pass an expression of type {expected}.", placeholders: ["name", "argument", "expected", "found"] }, OS3012: { code: "OS3012", title: "A required argument is missing", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} requires {argument}, which has no default.", fix: "Pass {argument} at the call site, as the example shows: {example}.", placeholders: ["name", "argument", "example"] }, OS3013: { code: "OS3013", title: "Argument given twice", severity: "error", stage: "check", since: 1, autofix: false, message: "{argument} is given twice at this call site.", fix: "Delete one of the two, keeping the value that was meant.", placeholders: ["argument"] }, OS3014: { code: "OS3014", title: "limits() is in the wrong place", severity: "error", stage: "check", since: 1, autofix: false, message: "limits() appears at most once, immediately after the declaration; this one is at line {line}.", fix: "Move the limits() line directly under study(...) or strategy(...), and merge two calls into one.", placeholders: ["line"] }, OS3015: { code: "OS3015", title: "limits() takes literal numbers", severity: "error", stage: "check", since: 1, autofix: false, message: "limits() is read before the first bar, so {option} must be a literal number.", fix: "Write the number: limits(loops = 50_000_000).", placeholders: ["option"] }, OS3016: { code: "OS3016", title: "range must be a low and a high", severity: "error", stage: "check", since: 1, autofix: false, message: "range is [{low}, {high}]; it takes two numbers and the first must be below the second.", fix: "Write two numbers, lowest first: range = [0, 100].", placeholders: ["low", "high"] }, OS3017: { code: "OS3017", title: "Two of these share a name", severity: "error", stage: "check", since: 1, autofix: false, message: "{kind} names must be unique in a file; {name} is also used at line {line}.", fix: "Rename one of them so each name appears once.", placeholders: ["kind", "name", "line"] }, OS3018: { code: "OS3018", title: "The default is not in the options list", severity: "error", stage: "check", since: 1, autofix: false, message: "This input's default {default} is not one of options {values}.", fix: "Add {default} to options, or make the default one of the listed values.", placeholders: ["default", "values"] }, OS3019: { code: "OS3019", title: "A declaration handle in an object argument", severity: "error", stage: "check", since: 1, autofix: false, message: "{name}'s {argument} is {expected}; {found} is a declaration handle, which has no value at run time.", fix: "Pass an object the script created with draw.line(), draw.box() or draw.label(), and change a plot's own appearance through the arguments of the plot call instead.", placeholders: ["name", "argument", "expected", "found"] }, OS3020: { code: "OS3020", title: "fill needs two declared plots", severity: "error", stage: "check", since: 1, autofix: false, message: "fill's {argument} is {found}; it takes a plot declared by plot() or plotCandles().", fix: "Plot both edges at the top level, name each one, and pass the two names to fill().", placeholders: ["argument", "found"] }, OS3021: { code: "OS3021", title: "An input written in place has no title", severity: "error", stage: "check", since: 1, autofix: false, message: "An input() assigned to no name is named by its title, and this one has no title written as a string literal.", fix: "Give it a title written as a string literal: input(2, \"Precision\").", placeholders: [] }, OS3022: { code: "OS3022", title: "Two inputs share a settings key", severity: "error", stage: "check", since: 1, autofix: false, message: "This input is keyed by its title {name}, which is already the name of the input at line {line}.", fix: "Give this one a title of its own, or rename the input at line {line}.", placeholders: ["name", "line"] }, OS3023: { code: "OS3023", title: "An order names a leg this file does not declare", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} was given a {argument}, and this file declares none.", fix: "Leave {argument} out. A file that declares no leg has exactly one, and every order acts on it.", placeholders: ["name", "argument"] }, OS3024: { code: "OS3024", title: "An input written in place has an empty title", severity: "error", stage: "check", since: 1, autofix: false, message: "An input() assigned to no name is named by its title, and this one's title is empty.", fix: "Give the title something to say: input(2, \"Precision\").", placeholders: [] }, OS3025: { code: "OS3025", title: "A setting is part of a larger expression here", severity: "error", stage: "check", since: 1, autofix: false, message: "{option} is fixed before the first bar and holds an input() only as the whole of its value, so it cannot hold an expression over one.", fix: "Declare the setting as the value itself, with an input() written as the whole of {option}, or write the value out as a literal.", placeholders: ["option"] }, OS3026: { code: "OS3026", title: "This option cannot be a setting", severity: "error", stage: "check", since: 1, autofix: false, message: "{option} is written into the compiled program as a plain value, so a setting cannot choose it in this format version.", fix: "Write the option out as a string literal and drop the input(): style = \"step\", for instance, is one of the values OS3008 names.", placeholders: ["option"] }, OS4001: { code: "OS4001", title: "History index is not usable", severity: "error", stage: "runtime", since: 1, autofix: false, message: "[{index}] is not a whole number of bars at or above zero.", fix: "Wrap the index in floor() or round(), and clamp a computed index with max(0, n).", placeholders: ["index"] }, OS4002: { code: "OS4002", title: "History index is deeper than the retained depth", severity: "error", stage: "runtime", since: 1, autofix: false, message: "[{index}] reaches past the retained depth of {depth} bars.", fix: "Raise the depth in one place: limits(history = {suggested}).", placeholders: ["index", "depth", "suggested"] }, OS4003: { code: "OS4003", title: "A whole number was required here", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{name}'s {argument} was {found} on this bar; a whole number was required.", fix: "Round the value before passing it: floor() towards zero, round() to nearest.", placeholders: ["name", "argument", "found"] }, OS4004: { code: "OS4004", title: "Array index out of range", severity: "error", stage: "runtime", since: 1, autofix: false, message: "Index {index} is outside {name}, which holds {size} elements.", fix: "Guard the read with size({name}), and index from size({name}) - 1 for the last element.", placeholders: ["index", "name", "size"] }, OS4005: { code: "OS4005", title: "The drawing object no longer exists", severity: "error", stage: "runtime", since: 1, autofix: false, message: "This {kind} was deleted on bar {bar} and cannot be changed.", fix: "Assign none to the name on the same path as the delete, and test isNone() on it before changing the object.", placeholders: ["kind", "bar"] }, OS4006: { code: "OS4006", title: "The array is empty", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{name} cannot take an element from an empty array.", fix: "Test size(arr) > 0 before the call.", placeholders: ["name"] }, OS4007: { code: "OS4007", title: "Slice range is invalid", severity: "error", stage: "runtime", since: 1, autofix: false, message: "slice({from}, {to}) is not a range inside an array of {size} elements.", fix: "Clamp the bounds: from = max(0, from) and to = min(size(arr), to), with from at or below to.", placeholders: ["from", "to", "size"] }, OS4008: { code: "OS4008", title: "Table cell is outside the table", severity: "error", stage: "runtime", since: 1, autofix: false, message: "Cell ({row}, {column}) is outside a table of {rows} rows and {columns} columns.", fix: "Declare the table with the shape the script writes: table(\"Summary\", {rows}, {columns}).", placeholders: ["row", "column", "rows", "columns"] }, OS4009: { code: "OS4009", title: "Colour channel is out of range", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{name}'s {argument} is {found}; channels run 0 to 255 and alpha runs 0 to 1.", fix: "Clamp the value where it is computed: rgb(min(255, max(0, r)), g, b).", placeholders: ["name", "argument", "found"] }, OS4010: { code: "OS4010", title: "Calendar field is out of range", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{field} is {found}; it runs {range}.", fix: "Pass a value inside {range}, carrying the overflow into the field above it as the example does.", placeholders: ["field", "found", "range"] }, OS4011: { code: "OS4011", title: "String position is outside the string", severity: "error", stage: "runtime", since: 1, autofix: false, message: "Position {index} is outside a string of {length} characters.", fix: "Guard with str.length(s), or clamp the position with min() before the call.", placeholders: ["index", "length"] }, OS4012: { code: "OS4012", title: "That value is not one of the accepted names", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{argument} accepts {values}; {found} was computed on this bar.", fix: "Produce the value from an input() with an options list, so only accepted names can reach the call.", placeholders: ["argument", "values", "found"] }, OS4013: { code: "OS4013", title: "A loop bound is absent", severity: "error", stage: "runtime", since: 1, autofix: false, message: "This loop's {bound} is absent on this bar.", fix: "Give the bound a value with orElse(), or guard the loop with isNone() so a warmup bar skips it deliberately.", placeholders: ["bound"] }, OS5001: { code: "OS5001", title: "Loop budget exhausted", severity: "error", stage: "runtime", since: 1, autofix: false, message: "This bar used its {budget} loop iterations, and the loop at line {line} was still running.", fix: "Fix the exit condition, or raise the budget in one line: limits(loops = {suggested}).", placeholders: ["budget", "line", "suggested"] }, OS5002: { code: "OS5002", title: "The array is too large", severity: "error", stage: "runtime", since: 1, autofix: false, message: "An array holds at most {max} elements; {name} reached {size}.", fix: "Drop the oldest element as you append: if size(arr) > 500, shift(arr).", placeholders: ["max", "name", "size"] }, OS5003: { code: "OS5003", title: "The host refused this limits() value", severity: "error", stage: "host", since: 1, autofix: false, message: "This host allows {option} up to {max}; the file asks for {found}.", fix: "Lower {option} to {max} or below, or run the file on a host that allows more.", placeholders: ["option", "max", "found"] }, OS5004: { code: "OS5004", title: "The program needs more state regions than the engine allows", severity: "error", stage: "host", since: 1, autofix: false, message: "This program needs {found} state regions and the engine allows {max}; {first} calls {second} on several paths.", fix: "Call the inner function once at the top level, give its result a name, and pass that name down.", placeholders: ["found", "max", "first", "second"] }, OS5005: { code: "OS5005", title: "Nesting is too deep", severity: "error", stage: "parse", since: 1, autofix: false, message: "{construct} is nested {found} deep and the ceiling is {max}.", fix: "Flatten it: give the inner expression a name at the top level and use the name.", placeholders: ["construct", "found", "max"] }, OS5006: { code: "OS5006", title: "Too many outstanding data requests", severity: "error", stage: "host", since: 1, autofix: false, message: "This file makes {found} data requests and the host allows {max}.", fix: "Keep one request per symbol and timeframe, reuse the name it assigns, and delete the requests whose results are unused.", placeholders: ["found", "max"] }, OS5007: { code: "OS5007", title: "The bar took too long", severity: "error", stage: "host", since: 1, autofix: false, message: "Bar {bar} ran for {ms} ms and the host allows {max} ms.", fix: "Keep a running value in a var and update it per bar instead of recomputing over the whole history.", placeholders: ["bar", "ms", "max"] }, OS5008: { code: "OS5008", title: "The string is too long", severity: "error", stage: "runtime", since: 1, autofix: false, message: "A string holds at most {max} characters; this one reached {found}.", fix: "Keep the pieces in an array, trim it to the rows you display, and join only those.", placeholders: ["max", "found"] }, OS5009: { code: "OS5009", title: "The program is too large", severity: "error", stage: "host", since: 1, autofix: false, message: "This file compiles to {found} instructions and the ceiling is {max}.", fix: "Move the repeated block into a fn and call it, and delete branches the script no longer uses.", placeholders: ["found", "max"] }, OS5010: { code: "OS5010", title: "Too many drawing objects", severity: "error", stage: "runtime", since: 1, autofix: false, message: "A script holds at most {max} drawing objects; this one would be number {found}.", fix: "Delete each object when it stops being wanted, and bound the set: keep the objects in an array, and when it is longer than you want, delete the oldest object and remove the element.", placeholders: ["max", "found"] }, OS6001: { code: "OS6001", title: "Unknown timeframe", severity: "error", stage: "check", since: 1, autofix: false, message: "{value} is not a timeframe.", fix: "Write a count and a unit, or a bare number of minutes: \"5m\", \"1h\", \"1D\", \"1W\", \"60\".", placeholders: ["value"] }, OS6002: { code: "OS6002", title: "The requested timeframe is lower than the chart's", severity: "error", stage: "host", since: 1, autofix: false, message: "The chart is {chart} and the request asks for {requested}.", fix: "Request {chart} or higher, or change the chart's interval to the lower one and fold upwards instead.", placeholders: ["chart", "requested"] }, OS6003: { code: "OS6003", title: "A per-bar name inside a request expression", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is computed on this chart's bars, so it has no meaning on the requested ones.", fix: "Move the calculation inside the request expression, or pass a constant: a literal or an input().", placeholders: ["name"] }, OS6004: { code: "OS6004", title: "The library manifest disagrees with the program", severity: "error", stage: "host", since: 1, autofix: false, message: "Entry {index} of the program names {name} with {arity} arguments; this engine's manifest has {manifest}.", fix: "Recompile the script against this engine's library, or run the program on an engine with the library version it was compiled against.", placeholders: ["index", "name", "arity", "manifest"] }, OS6005: { code: "OS6005", title: "Unknown timezone", severity: "error", stage: "host", since: 1, autofix: false, message: "{value} is not a timezone this host knows.", fix: "Use a full area and location name from the host's list, or leave the argument out to use the chart's own timezone.", placeholders: ["value"] }, OS6006: { code: "OS6006", title: "The engine lacks a capability the program requires", severity: "error", stage: "host", since: 1, autofix: false, message: "This program requires {tag} and this engine does not have it.", fix: "Run the program on an engine that has {tag}, or remove the feature that needs it: the tag names it.", placeholders: ["tag"] }, OS6007: { code: "OS6007", title: "Unknown symbol or exchange", severity: "error", stage: "host", since: 1, autofix: false, message: "The host does not know {symbol} on {exchange}.", fix: "Correct the symbol, and name the exchange it trades on when it is not the chart's: req.symbol(\"SYMBOL\", \"1D\", close, exchange = \"EXCHANGE\").", placeholders: ["symbol", "exchange"] }, OS6008: { code: "OS6008", title: "The request returned no bars", severity: "error", stage: "host", since: 1, autofix: false, message: "{symbol} at {timeframe} returned no bars over the range this chart covers.", fix: "Move the chart's range into the period the instrument traded, or request a symbol that covers it.", placeholders: ["symbol", "timeframe"] }, OS6009: { code: "OS6009", title: "The request failed", severity: "error", stage: "host", since: 1, autofix: false, message: "The host could not fetch {symbol} at {timeframe}: {reason}.", fix: "Act on {reason} in the host: it is a connection, permission or quota problem. Where the value can be derived from the chart's own bars, derive it and drop the request.", placeholders: ["symbol", "timeframe", "reason"] }, OS6010: { code: "OS6010", title: "The engine was given no bars", severity: "error", stage: "host", since: 1, autofix: false, message: "There are no bars for {symbol} at {timeframe}, so the script cannot run.", fix: "Choose an instrument and interval that have history, or widen the chart's date range until bars exist.", placeholders: ["symbol", "timeframe"] }, OS6011: { code: "OS6011", title: "The bars are not in order", severity: "error", stage: "host", since: 1, autofix: false, message: "Bar {index} is dated {time}, which is not after bar {previous}.", fix: "Reload the history; if the same bar repeats, the feed is sending duplicates and the host has to sort and deduplicate the bars before the engine runs.", placeholders: ["index", "time", "previous"] }, OS6012: { code: "OS6012", title: "An instrument fact is not known", severity: "error", stage: "host", since: 1, autofix: false, message: "The host did not supply {fact} for {symbol}.", fix: "Supply {fact} in the host's instrument record for {symbol}, or leave the session out of the record, which makes every session read absent rather than wrong.", placeholders: ["fact", "symbol"] }, OS6013: { code: "OS6013", title: "The request changed after the first bar", severity: "error", stage: "runtime", since: 1, autofix: false, message: "This request asked for {first} on bar 0 and for {found} on bar {bar}.", fix: "Compute the symbol and the timeframe from literals or inputs, not from bar data.", placeholders: ["first", "found", "bar"] }, OS6014: { code: "OS6014", title: "The feed does not offer this timeframe", severity: "error", stage: "host", since: 1, autofix: false, message: "The host has no {timeframe} data for {symbol}; it offers {available}.", fix: "Request one of {available}, or derive the interval you want from a lower one the host does serve.", placeholders: ["timeframe", "symbol", "available"] }, OS6015: { code: "OS6015", title: "The requested timeframe does not fold into the chart's", severity: "error", stage: "host", since: 1, autofix: false, message: "{requested} is not a whole multiple of {chart}.", fix: "Request a multiple of {chart}, for example {suggestion}.", placeholders: ["requested", "chart", "suggestion"] }, OS6016: { code: "OS6016", title: "The compiled format version is not one this engine implements", severity: "error", stage: "host", since: 1, autofix: false, message: "This program is in compiled format {found} and this engine implements format {max}; a different major number is a different format, whether it is higher or lower.", fix: "Run the program on an engine that implements format {found}, or recompile the source with a compiler that emits format {max}.", placeholders: ["found", "max"] }, OS6017: { code: "OS6017", title: "The program's language version is not one this engine implements", severity: "error", stage: "host", since: 1, autofix: false, message: "This program was compiled from language version {found}, and this engine implements {versions}.", fix: "Upgrade the engine to one that implements language version {found}, or recompile the source against a version it has.", placeholders: ["found", "versions"] }, OS6018: { code: "OS6018", title: "The compiled program is malformed", severity: "error", stage: "host", since: 1, autofix: false, message: "The program failed verification at {location}: {reason}.", fix: "Recompile the script from its source; a program that fails verification came from a broken compiler or was edited after it was written, and neither is repairable by hand.", placeholders: ["location", "reason"] }, OS6019: { code: "OS6019", title: "A host setting fails the input's validation", severity: "error", stage: "host", since: 1, autofix: false, message: "The host supplied {value} for {key}, and {validation}.", fix: "Correct the value in the settings dialog, or widen the input's own min, max or options so the value is allowed.", placeholders: ["value", "key", "validation"] }, OS6020: { code: "OS6020", title: "The report window holds no bars", severity: "error", stage: "host", since: 1, autofix: false, message: "The window from {from} to {to} holds none of the {count} bars supplied.", fix: "Widen the window until it covers bars, or supply the bars it covers. Both bounds are inclusive and are compared against the times of the bars supplied rather than against a calendar, so a window that falls inside a gap in the data is empty however wide it looks.", placeholders: ["from", "to", "count"] }, OS6021: { code: "OS6021", title: "A run setting cannot be applied as stated", severity: "error", stage: "host", since: 1, autofix: false, message: "{setting} cannot be applied: {problem}.", fix: "State the setting so it can be carried out: declare a charge line after every line it is levied on, supply the tick size a slippage in ticks is measured in, write down the reason a tolerance needs a bound, or bring a bound past the cap back inside it. Nothing has been computed at the point this is refused, so correcting the setting and running again costs one run.", placeholders: ["setting", "problem"] }, OS6022: { code: "OS6022", title: "The bars are not the bars the record was made from", severity: "error", stage: "host", since: 1, autofix: false, message: "The bars supplied hash to {found}, and the record was made from {expected}.", fix: "Replay against the bars the record names. Where the revision is the point, make a second record over the revised bars and compare the two runs, rather than overwriting one run with the other under one name.", placeholders: ["found", "expected"] }, OS6023: { code: "OS6023", title: "Two cost models are stated at once", severity: "error", stage: "host", since: 1, autofix: false, message: "A charge schedule was supplied, and the declaration states a commission of {commission} in {commissionType}.", fix: "Supply the schedule and leave the declaration's commission at its default of zero, or state the commission in the declaration and supply no schedule. A schedule is the one of the two that can carry a floor, a cap, a charge levied on a charge, and a cost that falls on one side of the trade only.", placeholders: ["commission", "commissionType"] }, OS6024: { code: "OS6024", title: "The host cannot draw something this study declares", severity: "error", stage: "host", since: 1, autofix: false, message: "This host cannot draw {what}: {limit}.", fix: "Declare what this host draws, or run the study on a host that draws {what}.", placeholders: ["what", "limit"] }, OS6025: { code: "OS6025", title: "A bar has no time", severity: "error", stage: "host", since: 1, autofix: false, message: "Bar {index} was handed over with no time.", fix: "State the bar's open instant in whole milliseconds since the Unix epoch, UTC, and leave out a bar the host cannot date rather than handing it over without a time.", placeholders: ["index"] }, OS7001: { code: "OS7001", title: "Only a strategy can do that", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} is available only in a file declared with strategy().", fix: "Change study(...) on line {line} to strategy(...), or replace {name} with signal(\"...\") to mark the bar without trading.", placeholders: ["name", "line"] }, OS7002: { code: "OS7002", title: "An order argument is absent", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{name}'s {argument} is absent on this bar.", fix: "Guard the call with isNone({argument}), or supply a fallback with orElse() where one is genuinely correct.", placeholders: ["name", "argument"] }, OS7003: { code: "OS7003", title: "An order function inside a request expression", severity: "error", stage: "check", since: 1, autofix: false, message: "{name} inside a request expression would place an order from another instrument's bars.", fix: "Read the value with the request, and place the order at the top level from the result.", placeholders: ["name"] }, OS7004: { code: "OS7004", title: "Order quantity is zero or negative", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{name} was given a quantity of {qty}.", fix: "Pass a positive quantity, guard the call with a size test, and use sell() to go the other way.", placeholders: ["name", "qty"] }, OS7005: { code: "OS7005", title: "Quantity is not a multiple of the lot size", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{symbol} trades in lots of {lot}, and {qty} is not a multiple of it.", fix: "Size in lots: declare qtyType = \"lots\" and pass the lot count, or round a computed size with order.roundToLot().", placeholders: ["symbol", "lot", "qty"] }, OS7006: { code: "OS7006", title: "Price is not on a tick", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{symbol} ticks at {tick}, and {price} does not fall on one.", fix: "Round to the tick before passing the price: round(price / chart.tickSize) * chart.tickSize.", placeholders: ["symbol", "tick", "price"] }, OS7007: { code: "OS7007", title: "A resting order has no price", severity: "error", stage: "runtime", since: 1, autofix: false, message: "A {type} order needs {argument}, and none was given.", fix: "Pass {argument}, or leave the type as market and let the order fill at the next price.", placeholders: ["type", "argument"] }, OS7008: { code: "OS7008", title: "The entry was refused by pyramiding", severity: "error", stage: "runtime", since: 1, autofix: false, message: "This strategy allows {max} entries in one direction and already holds {found}.", fix: "Raise pyramiding in the declaration, or test pos.size before entering again.", placeholders: ["max", "found"] }, OS7009: { code: "OS7009", title: "Unknown order tag", severity: "error", stage: "runtime", since: 1, autofix: false, message: "There is no working order tagged {tag}.", fix: "Use the tag the order was placed with, or cancelAll() where the script means every order it has working.", placeholders: ["tag"] }, OS7010: { code: "OS7010", title: "A bracket price is on the wrong side of the entry", severity: "error", stage: "runtime", since: 1, autofix: false, message: "A {side} entry at {entry} cannot take a {leg} at {price}.", fix: "Put the stop below a long entry and the limit above it, and swap the two for a short.", placeholders: ["side", "entry", "leg", "price"] }, OS7011: { code: "OS7011", title: "The order needs more capital than the strategy has", severity: "error", stage: "runtime", since: 1, autofix: false, message: "This order needs {required} and the strategy has {available}.", fix: "Size from equity with qtyType = \"equityPercent\", or test pos.equity before entering.", placeholders: ["required", "available"] }, OS7012: { code: "OS7012", title: "The instrument is outside its session", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{symbol} is outside its trading session at {time}.", fix: "Guard entries with session.isOpen, and set closeOnSessionEnd = true to flatten at the close.", placeholders: ["symbol", "time"] }, OS7013: { code: "OS7013", title: "Two opposite orders on one bar", severity: "error", stage: "runtime", since: 1, autofix: false, message: "{first} and {second} were both placed on bar {bar}.", fix: "Make the conditions exclusive with else if, or place the exit on this bar and the entry on the next.", placeholders: ["first", "second", "bar"] }, OS7014: { code: "OS7014", title: "The destination rejected the order", severity: "error", stage: "host", since: 1, autofix: false, message: "The order destination rejected {name}: {reason}.", fix: "Act on {reason}: it comes from the destination, not from the script, and the same order will be rejected again until the account or the order changes.", placeholders: ["name", "reason"] }, OS7015: { code: "OS7015", title: "The strategy has no order destination", severity: "error", stage: "host", since: 1, autofix: false, message: "This strategy placed an order and the host supplied no destination.", fix: "Connect a destination in the host, or run the file as a study(): replace buy() with signal(\"BUY\").", placeholders: [] }, OS7016: { code: "OS7016", title: "A close names a tag nothing places", severity: "error", stage: "check", since: 1, autofix: false, message: "No order in this file is placed with the tag {tag}.", fix: "Use the tag the entry was placed with, or leave the tag out to flatten the whole leg.", placeholders: ["tag"] }, OS7017: { code: "OS7017", title: "A close states more than it is closing", severity: "error", stage: "runtime", since: 1, autofix: false, message: "close was given a quantity of {qty}, and {part} has {held} left to close.", fix: "Leave the quantity out and close() flattens what is left, or size the part from pos.size and keep the quantity at or under {held}.", placeholders: ["qty", "part", "held"] }, OS7018: { code: "OS7018", title: "A frame names an order this strategy did not place", severity: "error", stage: "host", since: 1, autofix: false, message: "The frame names intent {intent}, and this strategy holds no such order.", fix: "Answer with the intent id the engine sent. A destination's own reference is carried in the frame's reference field, where the engine records it and never parses it, and it is not what an answer is addressed by.", placeholders: ["intent"] }, OS7019: { code: "OS7019", title: "A fill was reported with no price", severity: "error", stage: "host", since: 1, autofix: false, message: "The frame reports {qty} filled for intent {intent}, and no average fill price.", fix: "Report the average fill price the destination computed over the cumulative quantity, on every frame that reports a quantity greater than the last one. A frame carrying no new quantity needs no price.", placeholders: ["qty", "intent"] }, OS8001: { code: "OS8001", title: "A stateful call inside a branch", severity: "warning", stage: "check", since: 1, autofix: false, message: "{name} advances only on the bars where this branch runs, and is absent on the rest.", fix: "Compute it unconditionally at the top level and use the result inside the branch.", placeholders: ["name"] }, OS8002: { code: "OS8002", title: "A higher timeframe read with onUnconfirmed", severity: "warning", stage: "check", since: 1, autofix: false, message: "This file sets onUnconfirmed = true and reads {timeframe}; together they repaint.", fix: "Drop onUnconfirmed = true, or guard every use of the read with bar.isConfirmed.", placeholders: ["timeframe"] }, OS8003: { code: "OS8003", title: "No version declaration", severity: "warning", stage: "check", since: 1, autofix: true, message: "This file declares no language version; it was compiled as version {version}.", fix: "Add version {version} as the first line of the file.", placeholders: ["version"] }, OS8004: { code: "OS8004", title: "A branch on an absent condition changes a value used later", severity: "warning", stage: "check", since: 1, autofix: false, message: "{condition} can be absent, and this block assigns {name}, which is read at line {line}.", fix: "Decide what warmup means: test isNone({condition}) explicitly, or give {name} a starting value above the if.", placeholders: ["condition", "name", "line"] }, OS8005: { code: "OS8005", title: "A lookahead read", severity: "warning", stage: "check", since: 1, autofix: false, message: "This read uses {mode}, so the study shows values the bar it is drawn on could not have known.", fix: "Drop the mode to take the default, which never repaints, unless the study is deliberately a study of what the higher bar went on to do.", placeholders: ["mode"] }, OS8006: { code: "OS8006", title: "A session average on a session-length bar", severity: "warning", stage: "check", since: 1, autofix: false, message: "A session anchored average resets each session, and each bar of {interval} is a whole session, so it equals its source.", fix: "Use an intraday interval for a session anchored average, or plot the source directly and delete the call.", placeholders: ["interval"] }, OS8007: { code: "OS8007", title: "A plot sets the price pane's own formatting", severity: "warning", stage: "check", since: 1, autofix: false, message: "{title} sets {option} while drawing over the price pane, which reformats the instrument's own axis.", fix: "Set precision and format in the declaration, for the whole study, or drop them from a plot drawn over the price pane.", placeholders: ["title", "option"] }, OS8008: { code: "OS8008", title: "An alert with no fixed id", severity: "warning", stage: "check", since: 1, autofix: false, message: "This alert has no fixed id, so its identity is derived from its position at line {line}.", fix: "Give the alert a stable id of your own: alert(\"text\", id = \"emaCross\").", placeholders: ["line"] }, OS8009: { code: "OS8009", title: "This plot can never draw", severity: "warning", stage: "check", since: 1, autofix: false, message: "{title} plots a value that is absent on every bar.", fix: "Plot the value that was meant, or delete the plot and its settings row.", placeholders: ["title"] }, OS8010: { code: "OS8010", title: "A name is never read", severity: "warning", stage: "check", since: 1, autofix: false, message: "{name} is assigned at line {line} and never read.", fix: "Use the value, or delete the line.", placeholders: ["name", "line"] }, OS8011: { code: "OS8011", title: "live var makes live and backtest differ", severity: "warning", stage: "check", since: 1, autofix: false, message: "{name} is a live var, so it keeps its value across the updates of the moving bar.", fix: "Use var unless counting intrabar updates is the actual intent; keep live var only for that.", placeholders: ["name"] }, OS8012: { code: "OS8012", title: "An ordered comparison against none is always absent", severity: "warning", stage: "check", since: 1, autofix: false, message: "This {op} has none on one side, so it is absent on every bar.", fix: "Test absence with isNone(x), or with x == none, both of which are always true or false.", placeholders: ["op"] }, OS8013: { code: "OS8013", title: "Deprecated", severity: "warning", stage: "check", since: 1, autofix: true, message: "{name} is deprecated since language version {version}; {replacement} does the same thing.", fix: "Replace {name} with {replacement}; the two compute the same values.", placeholders: ["name", "version", "replacement"] }, OS8014: { code: "OS8014", title: "A persistent value holds a bar index", severity: "warning", stage: "check", since: 1, autofix: false, message: "{name} keeps a bar index across bars, and every index shifts when more history loads.", fix: "Store time instead and compare timestamps; the bar's time does not move.", placeholders: ["name"] }, OS8015: { code: "OS8015", title: "This loop never runs", severity: "warning", stage: "check", since: 1, autofix: false, message: "The loop starts at {start}, ends at {end} and steps {step}, so the body never runs.", fix: "Add step -1 to count down, or swap the bounds to count up.", placeholders: ["start", "end", "step"] }, OS8016: { code: "OS8016", title: "Unreachable code", severity: "warning", stage: "check", since: 1, autofix: false, message: "Line {line} follows a return that always runs, so it never executes.", fix: "Delete the unreachable lines, or move them above the return.", placeholders: ["line"] }, OS8017: { code: "OS8017", title: "The condition is constant", severity: "warning", stage: "check", since: 1, autofix: false, message: "This condition is {value} on every bar.", fix: "Restore the test that was meant, or delete the branch that never runs.", placeholders: ["value"] }, OS8018: { code: "OS8018", title: "An input is never used", severity: "warning", stage: "check", since: 1, autofix: false, message: "The input {title} is declared at line {line} and never read.", fix: "Use the name the input assigns, or delete the input() and its dialog row.", placeholders: ["title", "line"] }, OS8019: { code: "OS8019", title: "A deleted object is still held", severity: "warning", stage: "check", since: 1, autofix: false, message: "{name} still holds the {kind} deleted at line {line}.", fix: "Assign none to the name on the same path as the delete, and where the object came out of an array, remove the element as well as deleting the object.", placeholders: ["name", "kind", "line"] }, OS9001: { code: "OS9001", title: "Version not read by the importer", severity: "error", stage: "import", since: 1, autofix: false, message: "The importer reads scripts written for version 5 or 6 of the source dialect, and this one {found}.", fix: "Bring the script up to version 5 or 6 in the source dialect, or translate it by hand, and import it again.", placeholders: ["found"] }, OS9002: { code: "OS9002", title: "Construct with no equivalent", severity: "error", stage: "import", since: 1, autofix: false, message: "The importer cannot translate {construct}, so the statement holding it was kept as a comment.", fix: "Translate that statement by hand from the comment that holds it: the rest of the script was translated around it.", placeholders: ["construct"] }, OS9003: { code: "OS9003", title: "Built-in with no mapping", severity: "error", stage: "import", since: 1, autofix: false, message: "{name} is not one of the built-ins the importer maps, so the statement holding it was kept as a comment.", fix: "Find the OpenScript library call that does the same job, check how it treats its first bars and absent values, and write the statement by hand.", placeholders: ["name"] }, OS9004: { code: "OS9004", title: "Declaration the importer cannot place", severity: "error", stage: "import", since: 1, autofix: false, message: "The importer writes the declaration from one indicator or strategy call at the top level, and this script {found}.", fix: "Give the source script exactly one indicator or strategy declaration at the top level, and import it again.", placeholders: ["found"] }, OS9005: { code: "OS9005", title: "Reads a statement that was not translated", severity: "error", stage: "import", since: 1, autofix: false, message: "{name} is declared by the statement at line {line}, which was not translated, so this statement that reads it was kept as a comment too.", fix: "Translate the statement at line {line} by hand first, then this one, which was kept as a comment only because it reads {name}.", placeholders: ["name", "line"] }, OS9006: { code: "OS9006", title: "Argument with no equivalent", severity: "error", stage: "import", since: 1, autofix: false, message: "{argument} changes what {call} computes or trades, and OpenScript has no equivalent the importer can write.", fix: "Translate the call by hand, deciding what OpenScript should do in place of {argument}, or remove {argument} from the source script if the script does not depend on it.", placeholders: ["argument", "call"] }, OS9007: { code: "OS9007", title: "Warmup and absent bars follow OpenScript", severity: "warning", stage: "import", since: 1, autofix: false, message: "{call} became {target} here and wherever else the script calls it, and {target} follows OpenScript's own warmup, arithmetic and handling of absent values, which the original is not guaranteed to share.", fix: "Compare the first bars of the translation with the original, and where the script depends on them, write the value as an explicit recurrence held in var, seeded the way the original seeds it.", placeholders: ["call", "target"] }, OS9008: { code: "OS9008", title: "Whole-number division in version 5", severity: "warning", stage: "import", since: 1, autofix: false, message: "Both sides of this division are whole-number constants, which version 5 of the source dialect divides without a fractional part, and OpenScript keeps the fraction.", fix: "If the script relied on the whole-number result, wrap the translated division in trunc(); otherwise leave it as it is.", placeholders: [] }, OS9009: { code: "OS9009", title: "Presentation argument left out", severity: "warning", stage: "import", since: 1, autofix: false, message: "{argument} changes how {call} is displayed or what it may allocate, not what it computes, and OpenScript has no equivalent, so the translation leaves it out.", fix: "Nothing needs to change unless the display mattered; where it did, restyle the translated call with the arguments OpenScript does have, such as its colour, width and style.", placeholders: ["argument", "call"] }, OS9010: { code: "OS9010", title: "Order placed under OpenScript's order model", severity: "warning", stage: "import", since: 1, autofix: false, message: "{call} was translated into OpenScript's order calls here and wherever else the script uses it, and OpenScript decides when an order fills, how a reversal and a repeated entry are handled and when an exit level starts to apply by its own order model.", fix: "Backtest the translation beside the original and compare the two trade lists before relying on it, and adjust the order calls by hand where they part.", placeholders: ["call"] }, OS9011: { code: "OS9011", title: "Equality over two absent values", severity: "warning", stage: "import", since: 1, autofix: false, message: "Both sides of {operator} can be absent on the same bar, and OpenScript counts two absent values as equal, which the original is not guaranteed to do.", fix: "If the original relied on two absent values never comparing equal, guard the translated comparison with isNone() on either side.", placeholders: ["operator"] }, OS9012: { code: "OS9012", title: "The translation does not compile", severity: "error", stage: "import", since: 1, autofix: false, message: "The OpenScript compiler refused the translation of this statement with {code}, so the statement was kept as a comment.", fix: "Look up {code} in this catalogue and translate the statement by hand in the form that code's fix describes.", placeholders: ["code"] }, } as const satisfies Readonly>; /** Every code the compiler and the engines may emit. Nothing else is one. */ export type DiagnosticCode = keyof typeof ENTRIES;