thyscript 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/thy-node.js +332 -0
- package/bin/thy.js +828 -0
- package/bin/thys.js +25 -0
- package/examples/calculator.thy +274 -0
- package/examples/calculator.thy.js +628 -0
- package/examples/hello.thy +34 -0
- package/examples/login.thy +382 -0
- package/examples/login.thy.js +710 -0
- package/package.json +54 -0
- package/scripts/_class.js +18 -0
- package/scripts/_class2.js +11 -0
- package/scripts/_class3.js +21 -0
- package/scripts/_dstruct.js +20 -0
- package/scripts/_dstruct2.js +24 -0
- package/scripts/_scaffold.js +16 -0
- package/scripts/_scaffold2.js +16 -0
- package/scripts/_scaffold3.js +26 -0
- package/scripts/_tpl_compile.js +13 -0
- package/scripts/_tpl_test.js +9 -0
- package/scripts/_typeof.js +26 -0
- package/scripts/_typeof2.js +25 -0
- package/scripts/patch_genmethod.js +44 -0
- package/scripts/smoke_test.js +167 -0
- package/scripts/smoke_test2.js +151 -0
- package/scripts/test_control_panel.js +58 -0
- package/src/compiler/CodeGenerator.js +1449 -0
- package/src/compiler/JITCompiler.js +325 -0
- package/src/database/DatabaseEngine.js +931 -0
- package/src/errors/ErrorDetector.js +305 -0
- package/src/errors/ErrorMessages.js +497 -0
- package/src/index.js +169 -0
- package/src/lexer/Lexer.js +342 -0
- package/src/lexer/TokenTypes.js +1234 -0
- package/src/memory/MemoryManager.js +283 -0
- package/src/parser/AST.js +606 -0
- package/src/parser/Parser.js +1942 -0
- package/src/runtime/ThyRuntime.js +265 -0
- package/src/runtime/stdlib/ArrayLib.js +207 -0
- package/src/runtime/stdlib/FileLib.js +168 -0
- package/src/runtime/stdlib/MathLib.js +411 -0
- package/src/runtime/stdlib/StringLib.js +387 -0
- package/src/server/ControlPanel.js +1188 -0
- package/src/server/HTMLCSSEngine.js +866 -0
- package/src/server/SecurityEngine.js +714 -0
- package/src/server/ServerEngine.js +738 -0
- package/tests/test1_math.thy +82 -0
- package/tests/test2_oop.thy +133 -0
- package/tests/test3_server.thy +143 -0
- package/tests/test4_functions.thy +159 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ErrorMessages.js — ThyScript Error Code Database
|
|
5
|
+
* 500+ error codes covering all categories of ThyScript errors.
|
|
6
|
+
*
|
|
7
|
+
* Shape of each entry:
|
|
8
|
+
* code {string} THY-NNN
|
|
9
|
+
* message {string} Template string (use {0},{1},... for substitutions)
|
|
10
|
+
* suggestion {string} Human-readable fix hint
|
|
11
|
+
* severity {string} 'error' | 'warning' | 'info'
|
|
12
|
+
* category {string} Category label
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const E = (code, message, suggestion, severity = 'error', category = 'UNKNOWN') =>
|
|
16
|
+
({ code, message, suggestion, severity, category });
|
|
17
|
+
|
|
18
|
+
// ─── Helper: substitute placeholders ─────────────────────────────────────────
|
|
19
|
+
function format(template, ...args) {
|
|
20
|
+
return template.replace(/\{(\d+)\}/g, (_, i) => args[i] !== undefined ? args[i] : `{${i}}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
24
|
+
// SYNTAX ERRORS THY-001 … THY-100
|
|
25
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
26
|
+
const SYNTAX = {
|
|
27
|
+
'THY-001': E('THY-001', "Unexpected token '{0}'", "Remove or replace the unexpected token.", 'error', 'SYNTAX'),
|
|
28
|
+
'THY-002': E('THY-002', "Unexpected end of file", "Check for unclosed brackets or missing 'end' keywords.", 'error', 'SYNTAX'),
|
|
29
|
+
'THY-003': E('THY-003', "Missing '{0}' after '{1}'", "Add the required '{0}' token.", 'error', 'SYNTAX'),
|
|
30
|
+
'THY-004': E('THY-004', "Unmatched '{0}'", "Add a matching closing '{0}'.", 'error', 'SYNTAX'),
|
|
31
|
+
'THY-005': E('THY-005', "Expected identifier but got '{0}'", "Replace '{0}' with a valid identifier.", 'error', 'SYNTAX'),
|
|
32
|
+
'THY-006': E('THY-006', "Invalid character '{0}' (U+{1})", "Remove the invalid character or use a string literal.", 'error', 'SYNTAX'),
|
|
33
|
+
'THY-007': E('THY-007', "Unterminated string literal", "Add a closing quote to end the string.", 'error', 'SYNTAX'),
|
|
34
|
+
'THY-008': E('THY-008', "Unterminated comment block", "Close the block comment with */.", 'error', 'SYNTAX'),
|
|
35
|
+
'THY-009': E('THY-009', "Invalid escape sequence '\\{0}'", "Use a valid escape sequence: \\n \\t \\\\ \\\" etc.", 'error', 'SYNTAX'),
|
|
36
|
+
'THY-010': E('THY-010', "Invalid number literal '{0}'", "Check the numeric literal format.", 'error', 'SYNTAX'),
|
|
37
|
+
'THY-011': E('THY-011', "Missing semicolon after statement", "Add a semicolon ';' or a newline.", 'warning', 'SYNTAX'),
|
|
38
|
+
'THY-012': E('THY-012', "Expected '{0}' but found '{1}'", "Replace '{1}' with '{0}'.", 'error', 'SYNTAX'),
|
|
39
|
+
'THY-013': E('THY-013', "Unexpected keyword '{0}' in this context", "Remove '{0}' or move it to a valid location.", 'error', 'SYNTAX'),
|
|
40
|
+
'THY-014': E('THY-014', "Duplicate label '{0}'", "Rename one of the labels.", 'error', 'SYNTAX'),
|
|
41
|
+
'THY-015': E('THY-015', "Empty block is not allowed here", "Add at least one statement inside the block.", 'error', 'SYNTAX'),
|
|
42
|
+
'THY-016': E('THY-016', "Too many closing brackets", "Remove the extra '}'.", 'error', 'SYNTAX'),
|
|
43
|
+
'THY-017': E('THY-017', "Expected expression but got '{0}'", "Provide a valid expression.", 'error', 'SYNTAX'),
|
|
44
|
+
'THY-018': E('THY-018', "Trailing comma in expression list", "Remove the trailing comma.", 'warning', 'SYNTAX'),
|
|
45
|
+
'THY-019': E('THY-019', "Missing comma between items", "Add a comma ',' between items.", 'error', 'SYNTAX'),
|
|
46
|
+
'THY-020': E('THY-020', "Invalid assignment target '{0}'", "The left side of '=' must be a variable or property.", 'error', 'SYNTAX'),
|
|
47
|
+
'THY-021': E('THY-021', "Missing ':' in type annotation", "Add ':' followed by the type name.", 'error', 'SYNTAX'),
|
|
48
|
+
'THY-022': E('THY-022', "Invalid type annotation '{0}'", "Use a valid type: int, float, str, bool, list, map, any.", 'error', 'SYNTAX'),
|
|
49
|
+
'THY-023': E('THY-023', "Missing '->' in function signature", "Add '->' and the return type.", 'error', 'SYNTAX'),
|
|
50
|
+
'THY-024': E('THY-024', "Keyword '{0}' cannot start a statement here", "Check statement context.", 'error', 'SYNTAX'),
|
|
51
|
+
'THY-025': E('THY-025', "Nested function declarations not allowed at top level", "Move function inside a program block or class.", 'error', 'SYNTAX'),
|
|
52
|
+
'THY-026': E('THY-026', "'break' used outside of loop", "'break' can only be used inside 'for', 'while', or 'loop'.", 'error', 'SYNTAX'),
|
|
53
|
+
'THY-027': E('THY-027', "'continue' used outside of loop", "'continue' can only be used inside 'for', 'while', or 'loop'.", 'error', 'SYNTAX'),
|
|
54
|
+
'THY-028': E('THY-028', "'return' used outside of function", "Move 'return' inside a function definition.", 'error', 'SYNTAX'),
|
|
55
|
+
'THY-029': E('THY-029', "Duplicate parameter name '{0}'", "Rename one of the parameters.", 'error', 'SYNTAX'),
|
|
56
|
+
'THY-030': E('THY-030', "Rest parameter '...{0}' must be last", "Move the rest parameter to the end of the parameter list.", 'error', 'SYNTAX'),
|
|
57
|
+
'THY-031': E('THY-031', "Default parameter cannot precede required parameter", "Move default parameters after all required ones.", 'error', 'SYNTAX'),
|
|
58
|
+
'THY-032': E('THY-032', "Computed property key must be inside '[]'", "Wrap the expression in square brackets.", 'error', 'SYNTAX'),
|
|
59
|
+
'THY-033': E('THY-033', "Template literal is missing closing backtick", "Add a closing backtick '`'.", 'error', 'SYNTAX'),
|
|
60
|
+
'THY-034': E('THY-034', "Regex literal is missing closing '/'", "Add a closing '/' to end the regex.", 'error', 'SYNTAX'),
|
|
61
|
+
'THY-035': E('THY-035', "Binary literal must contain only 0 and 1", "Remove invalid characters from the binary literal.", 'error', 'SYNTAX'),
|
|
62
|
+
'THY-036': E('THY-036', "Hex literal contains invalid character '{0}'", "Use only 0-9 and a-f in hex literals.", 'error', 'SYNTAX'),
|
|
63
|
+
'THY-037': E('THY-037', "Octal literal contains invalid character '{0}'", "Use only 0-7 in octal literals.", 'error', 'SYNTAX'),
|
|
64
|
+
'THY-038': E('THY-038', "Numeric separator '_' can only appear between digits", "Move '_' between digit characters.", 'error', 'SYNTAX'),
|
|
65
|
+
'THY-039': E('THY-039', "Multiple consecutive numeric separators", "Use only one '_' between digits.", 'error', 'SYNTAX'),
|
|
66
|
+
'THY-040': E('THY-040', "Exponent part requires digits after 'e'", "Add digits after 'e' or 'E'.", 'error', 'SYNTAX'),
|
|
67
|
+
'THY-041': E('THY-041', "'async' function body must be a block statement", "Wrap the function body in '{}'.", 'error', 'SYNTAX'),
|
|
68
|
+
'THY-042': E('THY-042', "'await' used outside async function", "Add 'async' to the enclosing function declaration.", 'error', 'SYNTAX'),
|
|
69
|
+
'THY-043': E('THY-043', "'yield' used outside generator function", "Add '*' to the function to make it a generator.", 'error', 'SYNTAX'),
|
|
70
|
+
'THY-044': E('THY-044', "Class body may only contain method definitions", "Remove the invalid class body element.", 'error', 'SYNTAX'),
|
|
71
|
+
'THY-045': E('THY-045', "Duplicate constructor in class", "A class can have only one constructor.", 'error', 'SYNTAX'),
|
|
72
|
+
'THY-046': E('THY-046', "Static constructor is not allowed", "Remove 'static' from the constructor declaration.", 'error', 'SYNTAX'),
|
|
73
|
+
'THY-047': E('THY-047', "Expected class name after 'class'", "Provide a name for the class.", 'error', 'SYNTAX'),
|
|
74
|
+
'THY-048': E('THY-048', "Import path must be a string literal", "Use a string literal for the import path.", 'error', 'SYNTAX'),
|
|
75
|
+
'THY-049': E('THY-049', "Import specifier list is empty", "Specify at least one import or use 'import * as X'.", 'warning', 'SYNTAX'),
|
|
76
|
+
'THY-050': E('THY-050', "Export declaration not at top level", "'export' must appear at the top level of a module.", 'error', 'SYNTAX'),
|
|
77
|
+
'THY-051': E('THY-051', "Illegal 'use strict' directive after code", "Move 'use strict' to the top of the file or function.", 'error', 'SYNTAX'),
|
|
78
|
+
'THY-052': E('THY-052', "Labelled statement target must be a loop or switch", "Labels can only target loops and switch blocks.", 'error', 'SYNTAX'),
|
|
79
|
+
'THY-053': E('THY-053', "Invalid destructuring pattern", "Check the destructuring syntax.", 'error', 'SYNTAX'),
|
|
80
|
+
'THY-054': E('THY-054', "Spread element may only appear once", "Remove extra spread '...' elements.", 'error', 'SYNTAX'),
|
|
81
|
+
'THY-055': E('THY-055', "'case' without 'switch'", "Wrap 'case' inside a 'switch' statement.", 'error', 'SYNTAX'),
|
|
82
|
+
'THY-056': E('THY-056', "'default' without 'switch'", "Wrap 'default' inside a 'switch' statement.", 'error', 'SYNTAX'),
|
|
83
|
+
'THY-057': E('THY-057', "Duplicate 'default' in switch", "A switch block may have at most one 'default' case.", 'error', 'SYNTAX'),
|
|
84
|
+
'THY-058': E('THY-058', "Decorator must precede a class or method declaration", "Move the decorator directly before a class or method.", 'error', 'SYNTAX'),
|
|
85
|
+
'THY-059': E('THY-059', "Arrow function body cannot be empty", "Provide a body for the arrow function.", 'error', 'SYNTAX'),
|
|
86
|
+
'THY-060': E('THY-060', "Optional chaining '?.' cannot be used before '('", "Remove '?.' before a function call.", 'error', 'SYNTAX'),
|
|
87
|
+
'THY-061': E('THY-061', "Nullish coalescing '??' cannot mix with '&&' or '||'", "Use parentheses to clarify operator precedence.", 'error', 'SYNTAX'),
|
|
88
|
+
'THY-062': E('THY-062', "Invalid assignment operator '{0}'", "Use a valid assignment: = += -= *= /= etc.", 'error', 'SYNTAX'),
|
|
89
|
+
'THY-063': E('THY-063', "Ternary '?' is missing ':' branch", "Add ':' and the else expression.", 'error', 'SYNTAX'),
|
|
90
|
+
'THY-064': E('THY-064', "Missing loop variable after 'for'", "Add a loop variable after 'for'.", 'error', 'SYNTAX'),
|
|
91
|
+
'THY-065': E('THY-065', "Missing 'in' or 'of' in for loop", "Write: for x in list { } or for x of list { }.", 'error', 'SYNTAX'),
|
|
92
|
+
'THY-066': E('THY-066', "Missing condition after 'while'", "Add a condition after 'while'.", 'error', 'SYNTAX'),
|
|
93
|
+
'THY-067': E('THY-067', "Missing condition after 'if'", "Add a condition after 'if'.", 'error', 'SYNTAX'),
|
|
94
|
+
'THY-068': E('THY-068', "Missing condition after 'unless'", "Add a condition after 'unless'.", 'error', 'SYNTAX'),
|
|
95
|
+
'THY-069': E('THY-069', "Chained comparison is ambiguous: '{0}'", "Use parentheses to make precedence explicit.", 'warning', 'SYNTAX'),
|
|
96
|
+
'THY-070': E('THY-070', "String interpolation expression is empty", "Add an expression inside the interpolation braces.", 'error', 'SYNTAX'),
|
|
97
|
+
'THY-071': E('THY-071', "Unexpected '{0}' in type expression", "Use a valid type expression.", 'error', 'SYNTAX'),
|
|
98
|
+
'THY-072': E('THY-072', "Union type requires at least two types", "Add more types separated by '|'.", 'error', 'SYNTAX'),
|
|
99
|
+
'THY-073': E('THY-073', "Intersection type requires at least two types", "Add more types separated by '&'.", 'error', 'SYNTAX'),
|
|
100
|
+
'THY-074': E('THY-074', "Generic type arguments cannot be empty '<>'", "Provide at least one type argument.", 'error', 'SYNTAX'),
|
|
101
|
+
'THY-075': E('THY-075', "Tuple type must have at least one element", "Add element types inside the tuple.", 'error', 'SYNTAX'),
|
|
102
|
+
'THY-076': E('THY-076', "Named import '{0}' is not a valid identifier", "Use a valid identifier as the import name.", 'error', 'SYNTAX'),
|
|
103
|
+
'THY-077': E('THY-077', "Re-export must specify bindings", "Use 'export { x } from \"module\"'.", 'error', 'SYNTAX'),
|
|
104
|
+
'THY-078': E('THY-078', "Dynamic import must receive exactly one argument", "Provide a single module path string.", 'error', 'SYNTAX'),
|
|
105
|
+
'THY-079': E('THY-079', "Property shorthand is only valid in object literals", "Use 'key: value' syntax outside object literals.", 'error', 'SYNTAX'),
|
|
106
|
+
'THY-080': E('THY-080', "Getter must have zero parameters", "Remove the parameters from the getter function.", 'error', 'SYNTAX'),
|
|
107
|
+
'THY-081': E('THY-081', "Setter must have exactly one parameter", "Add exactly one parameter to the setter.", 'error', 'SYNTAX'),
|
|
108
|
+
'THY-082': E('THY-082', "Object key cannot be a block statement", "Wrap block expressions in parentheses.", 'error', 'SYNTAX'),
|
|
109
|
+
'THY-083': E('THY-083', "Unexpected newline in string literal", "Use '\\n' for a newline inside a string, or use a template literal.", 'error', 'SYNTAX'),
|
|
110
|
+
'THY-084': E('THY-084', "Array hole (',,') is not allowed in ThyScript", "Remove extra commas from the array literal.", 'error', 'SYNTAX'),
|
|
111
|
+
'THY-085': E('THY-085', "Index accessor '[]' requires an expression", "Add an expression inside the brackets.", 'error', 'SYNTAX'),
|
|
112
|
+
'THY-086': E('THY-086', "'try' block requires a 'catch' or 'finally'", "Add 'catch' or 'finally' after the try block.", 'error', 'SYNTAX'),
|
|
113
|
+
'THY-087': E('THY-087', "'catch' requires a parameter", "Add a parameter: catch (err) { }.", 'error', 'SYNTAX'),
|
|
114
|
+
'THY-088': E('THY-088', "Empty 'catch' body", "Add at least one statement inside 'catch'.", 'warning', 'SYNTAX'),
|
|
115
|
+
'THY-089': E('THY-089', "Unexpected token in 'catch' binding", "Use a simple identifier or destructuring pattern.", 'error', 'SYNTAX'),
|
|
116
|
+
'THY-090': E('THY-090', "'throw' requires an expression", "Add an expression after 'throw'.", 'error', 'SYNTAX'),
|
|
117
|
+
'THY-091': E('THY-091', "Conditional expression is always {0}", "Simplify the constant condition.", 'warning', 'SYNTAX'),
|
|
118
|
+
'THY-092': E('THY-092', "'match' expression requires at least one 'case'", "Add at least one case to the match block.", 'error', 'SYNTAX'),
|
|
119
|
+
'THY-093': E('THY-093', "Pattern match arm has unreachable guard", "Remove the always-false guard.", 'warning', 'SYNTAX'),
|
|
120
|
+
'THY-094': E('THY-094', "Missing 'end' for block starting at line {0}", "Add 'end' to close the block opened at line {0}.", 'error', 'SYNTAX'),
|
|
121
|
+
'THY-095': E('THY-095', "Pipeline operator '|>' requires a function on the right", "Provide a function reference or lambda after '|>'.", 'error', 'SYNTAX'),
|
|
122
|
+
'THY-096': E('THY-096', "Compose operator '>>' requires callable operands", "Both sides of '>>' must be functions.", 'error', 'SYNTAX'),
|
|
123
|
+
'THY-097': E('THY-097', "Invalid tag in tagged template literal", "The tag must be an expression that evaluates to a function.", 'error', 'SYNTAX'),
|
|
124
|
+
'THY-098': E('THY-098', "Implicit return value in 'void' function", "Remove the expression or change return type to non-void.", 'warning', 'SYNTAX'),
|
|
125
|
+
'THY-099': E('THY-099', "Semicolon inserted before '{0}' (ASI)", "Check if this is intentional; add an explicit semicolon.", 'info', 'SYNTAX'),
|
|
126
|
+
'THY-100': E('THY-100', "Syntax error near '{0}': parser could not recover", "Review the code around this location.", 'error', 'SYNTAX'),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
130
|
+
// TYPE ERRORS THY-101 … THY-200
|
|
131
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
132
|
+
const TYPE = {
|
|
133
|
+
'THY-101': E('THY-101', "Type mismatch: expected '{0}' but got '{1}'", "Change the value type or cast with as({0}).", 'error', 'TYPE'),
|
|
134
|
+
'THY-102': E('THY-102', "Cannot assign '{1}' to variable of type '{0}'", "Use a compatible type or declare the variable as '{1}'.", 'error', 'TYPE'),
|
|
135
|
+
'THY-103': E('THY-103', "Operator '{0}' cannot be applied to types '{1}' and '{2}'", "Ensure both operands are compatible with '{0}'.", 'error', 'TYPE'),
|
|
136
|
+
'THY-104': E('THY-104', "Property '{0}' does not exist on type '{1}'", "Check the property name or update the type definition.", 'error', 'TYPE'),
|
|
137
|
+
'THY-105': E('THY-105', "Cannot call '{0}' — it is not a function (type: {1})", "Make sure '{0}' holds a callable function.", 'error', 'TYPE'),
|
|
138
|
+
'THY-106': E('THY-106', "Argument {0}: expected '{1}' but got '{2}'", "Pass a '{1}' compatible value as argument {0}.", 'error', 'TYPE'),
|
|
139
|
+
'THY-107': E('THY-107', "Return type mismatch: declared '{0}' but returning '{1}'", "Change the returned value or update the function signature.", 'error', 'TYPE'),
|
|
140
|
+
'THY-108': E('THY-108', "Null reference: '{0}' may be null", "Add a null check before accessing '{0}'.", 'error', 'TYPE'),
|
|
141
|
+
'THY-109': E('THY-109', "Cannot index type '{0}' with '{1}'", "Use a compatible index type.", 'error', 'TYPE'),
|
|
142
|
+
'THY-110': E('THY-110', "Spread of non-iterable type '{0}'", "Use an array, list, or iterable type.", 'error', 'TYPE'),
|
|
143
|
+
'THY-111': E('THY-111', "Cannot destructure '{0}' — type '{1}' is not an object", "Ensure the value is an object before destructuring.", 'error', 'TYPE'),
|
|
144
|
+
'THY-112': E('THY-112', "Property '{0}' is read-only", "Do not assign to read-only property '{0}'.", 'error', 'TYPE'),
|
|
145
|
+
'THY-113': E('THY-113', "Comparison between incompatible types '{0}' and '{1}'", "Cast one operand before comparing.", 'warning', 'TYPE'),
|
|
146
|
+
'THY-114': E('THY-114', "Arithmetic on non-numeric type '{0}'", "Ensure the value is numeric before arithmetic.", 'error', 'TYPE'),
|
|
147
|
+
'THY-115': E('THY-115', "Bitwise operation on non-integer type '{0}'", "Convert to int before using bitwise operators.", 'error', 'TYPE'),
|
|
148
|
+
'THY-116': E('THY-116', "Logical NOT '!' on non-boolean type '{0}'", "Convert to bool or use toBool({0}).", 'warning', 'TYPE'),
|
|
149
|
+
'THY-117': E('THY-117', "Iteration over non-iterable type '{0}'", "Use an array or object that implements Iterator.", 'error', 'TYPE'),
|
|
150
|
+
'THY-118': E('THY-118', "Async function must return a Promise, not '{0}'", "Wrap return value in a Promise or use await.", 'error', 'TYPE'),
|
|
151
|
+
'THY-119': E('THY-119', "Cannot 'await' non-Promise type '{0}'", "Only await Promise values; add 'async' to the function if needed.", 'error', 'TYPE'),
|
|
152
|
+
'THY-120': E('THY-120', "Generic type '{0}' requires {1} type argument(s)", "Provide exactly {1} type argument(s) to '{0}'.", 'error', 'TYPE'),
|
|
153
|
+
'THY-121': E('THY-121', "Type '{0}' is not assignable to constraint '{1}'", "Use a type that satisfies the constraint '{1}'.", 'error', 'TYPE'),
|
|
154
|
+
'THY-122': E('THY-122', "Excess property '{0}' is not allowed in type '{1}'", "Remove the extra property or update the type definition.", 'error', 'TYPE'),
|
|
155
|
+
'THY-123': E('THY-123', "Cannot call new on non-constructor type '{0}'", "Ensure '{0}' is a class or constructor function.", 'error', 'TYPE'),
|
|
156
|
+
'THY-124': E('THY-124', "Implicit 'any' type for '{0}'", "Add an explicit type annotation.", 'warning', 'TYPE'),
|
|
157
|
+
'THY-125': E('THY-125', "Type assertion is always redundant: '{0}' is already '{1}'", "Remove the unnecessary type assertion.", 'info', 'TYPE'),
|
|
158
|
+
'THY-126': E('THY-126', "Type assertion '{0}' to '{1}' may fail at runtime", "Use a type guard function instead.", 'warning', 'TYPE'),
|
|
159
|
+
'THY-127': E('THY-127', "Union type member '{0}' is unreachable", "Remove the unreachable union member.", 'warning', 'TYPE'),
|
|
160
|
+
'THY-128': E('THY-128', "Missing discriminant property '{0}' in type '{1}'", "Add the discriminant property to narrow the union.", 'error', 'TYPE'),
|
|
161
|
+
'THY-129': E('THY-129', "Mapped type '{0}' maps over a non-object type", "Provide an object type for the mapping.", 'error', 'TYPE'),
|
|
162
|
+
'THY-130': E('THY-130', "Conditional type '{0}' has conflicting branches", "Simplify the conditional type.", 'warning', 'TYPE'),
|
|
163
|
+
'THY-131': E('THY-131', "Enum value '{0}' has incorrect type '{1}'", "Ensure enum members have type 'int' or 'str'.", 'error', 'TYPE'),
|
|
164
|
+
'THY-132': E('THY-132', "'typeof' result is always '{0}' — condition is trivially {1}", "Remove the redundant typeof check.", 'info', 'TYPE'),
|
|
165
|
+
'THY-133': E('THY-133', "Cannot extend final class '{0}'", "Remove 'final' from '{0}' or don't inherit from it.", 'error', 'TYPE'),
|
|
166
|
+
'THY-134': E('THY-134', "Abstract method '{0}' must be implemented by '{1}'", "Add an implementation of '{0}' in '{1}'.", 'error', 'TYPE'),
|
|
167
|
+
'THY-135': E('THY-135', "Override of '{0}' has incompatible signature", "Match the parent class signature for '{0}'.", 'error', 'TYPE'),
|
|
168
|
+
'THY-136': E('THY-136', "Interface '{0}' is not fully implemented by '{1}'", "Implement missing members: {2}.", 'error', 'TYPE'),
|
|
169
|
+
'THY-137': E('THY-137', "Optional property '{0}' may be undefined", "Add a null/undefined check before accessing '{0}'.", 'warning', 'TYPE'),
|
|
170
|
+
'THY-138': E('THY-138', "Function overload '{0}' is unreachable", "Reorder overloads so more specific ones come first.", 'warning', 'TYPE'),
|
|
171
|
+
'THY-139': E('THY-139', "Ambiguous overload call for '{0}'", "Add explicit type annotations to disambiguate.", 'error', 'TYPE'),
|
|
172
|
+
'THY-140': E('THY-140', "Void function result is used", "The function returns void; do not use its return value.", 'warning', 'TYPE'),
|
|
173
|
+
'THY-141': E('THY-141', "String concatenation with non-string type '{0}'", "Convert '{0}' to string with str({0}) before concatenating.", 'warning', 'TYPE'),
|
|
174
|
+
'THY-142': E('THY-142', "Comparison '{0}' is always {1}", "Remove the redundant comparison.", 'info', 'TYPE'),
|
|
175
|
+
'THY-143': E('THY-143', "Division '{0}/{1}' may produce float — use int division '//' if integer is needed", "Use '//' for integer division.", 'info', 'TYPE'),
|
|
176
|
+
'THY-144': E('THY-144', "Modulo on float type '{0}' has undefined behaviour", "Use int types for modulo operations.", 'warning', 'TYPE'),
|
|
177
|
+
'THY-145': E('THY-145', "Negative array index on fixed-size array", "Use a non-negative index or slice notation.", 'warning', 'TYPE'),
|
|
178
|
+
'THY-146': E('THY-146', "Map key type '{0}' is not hashable", "Use a hashable key type: str, int, bool, or a custom hash.", 'error', 'TYPE'),
|
|
179
|
+
'THY-147': E('THY-147', "Cyclic type reference detected: '{0}'", "Break the cycle with an interface or lazy type reference.", 'error', 'TYPE'),
|
|
180
|
+
'THY-148': E('THY-148', "Type '{0}' is deprecated — use '{1}' instead", "Replace '{0}' with '{1}'.", 'warning', 'TYPE'),
|
|
181
|
+
'THY-149': E('THY-149', "Function type '{0}' is missing parameter types", "Add full parameter type annotations.", 'warning', 'TYPE'),
|
|
182
|
+
'THY-150': E('THY-150', "Nullable type '{0}?' requires null check before use", "Unwrap with '!' or add 'if x != null' check.", 'error', 'TYPE'),
|
|
183
|
+
'THY-151': E('THY-151', "Cast from '{0}' to '{1}' will always fail", "The types are unrelated; verify your logic.", 'error', 'TYPE'),
|
|
184
|
+
'THY-152': E('THY-152', "Template literal type is too complex to evaluate", "Simplify the template literal type expression.", 'warning', 'TYPE'),
|
|
185
|
+
'THY-153': E('THY-153', "Recursive type '{0}' must have a finite base case", "Add a non-recursive branch.", 'error', 'TYPE'),
|
|
186
|
+
'THY-154': E('THY-154', "Inferred type '{0}' is too broad", "Provide an explicit narrower type annotation.", 'info', 'TYPE'),
|
|
187
|
+
'THY-155': E('THY-155', "Type '{0}' cannot be used as a decorator", "Decorators must be functions that accept a class or method.", 'error', 'TYPE'),
|
|
188
|
+
'THY-156': E('THY-156', "Mixin type '{0}' has conflicting method '{1}'", "Resolve the method conflict by overriding in the target class.", 'error', 'TYPE'),
|
|
189
|
+
'THY-157': E('THY-157', "Structural type '{0}' is incompatible with nominal type '{1}'", "Use explicit implements or cast.", 'error', 'TYPE'),
|
|
190
|
+
'THY-158': E('THY-158', "Property '{0}' has different mutability in override", "Match the 'readonly' modifier of the parent property.", 'error', 'TYPE'),
|
|
191
|
+
'THY-159': E('THY-159', "Constructor return type must be void or the class type", "Remove the return type annotation or use 'this'.", 'error', 'TYPE'),
|
|
192
|
+
'THY-160': E('THY-160', "Static member '{0}' accessed on instance", "Access '{0}' via the class name, not an instance.", 'error', 'TYPE'),
|
|
193
|
+
'THY-161': E('THY-161', "Instance member '{0}' accessed on class", "Create an instance first: new ClassName().", 'error', 'TYPE'),
|
|
194
|
+
'THY-162': E('THY-162', "Tuple index {0} out of bounds (length {1})", "Use an index between 0 and {1}.", 'error', 'TYPE'),
|
|
195
|
+
'THY-163': E('THY-163', "Enum member '{0}' already declared in this enum", "Remove the duplicate enum member.", 'error', 'TYPE'),
|
|
196
|
+
'THY-164': E('THY-164', "'never' type cannot be assigned to any other type", "Remove the unreachable code or revise the control flow.", 'error', 'TYPE'),
|
|
197
|
+
'THY-165': E('THY-165', "Unsafe type assertion: '{0}' cast to '{1}'", "Use a runtime type guard to verify the type.", 'warning', 'TYPE'),
|
|
198
|
+
'THY-166': E('THY-166', "Type '{0}' is wider than expected '{1}'", "Narrow the type with a type guard or assertion.", 'info', 'TYPE'),
|
|
199
|
+
'THY-167': E('THY-167', "Numeric literal type '{0}' is not assignable to '{1}'", "Use a value in the valid range for '{1}'.", 'error', 'TYPE'),
|
|
200
|
+
'THY-168': E('THY-168', "String literal type '{0}' is not assignable to '{1}'", "Use an allowed string value for '{1}'.", 'error', 'TYPE'),
|
|
201
|
+
'THY-169': E('THY-169', "Boolean literal type mismatch in condition", "Check the boolean literal used in the condition.", 'warning', 'TYPE'),
|
|
202
|
+
'THY-170': E('THY-170', "Infix operator '{0}' has ambiguous precedence with '{1}'", "Add parentheses to clarify the intended order.", 'warning', 'TYPE'),
|
|
203
|
+
'THY-171': E('THY-171', "Symbol property key '{0}' is not declared in type '{1}'", "Add the symbol to the type definition.", 'error', 'TYPE'),
|
|
204
|
+
'THY-172': E('THY-172', "Covariance violation: '{0}' cannot be substituted for '{1}'", "Ensure type substitutability (Liskov Principle).", 'error', 'TYPE'),
|
|
205
|
+
'THY-173': E('THY-173', "Contravariance violation in function parameter '{0}'", "Check parameter types in overridden methods.", 'error', 'TYPE'),
|
|
206
|
+
'THY-174': E('THY-174', "Type narrowing failed: '{0}' still has type '{1}' after check", "Adjust the type guard condition.", 'warning', 'TYPE'),
|
|
207
|
+
'THY-175': E('THY-175', "'instanceof' check against non-class type '{0}'", "Use a class constructor on the right side of 'instanceof'.", 'error', 'TYPE'),
|
|
208
|
+
'THY-176': E('THY-176', "'in' operator requires object on the right — got '{0}'", "Ensure the right-hand side of 'in' is an object.", 'error', 'TYPE'),
|
|
209
|
+
'THY-177': E('THY-177', "Bitwise shift by negative amount is undefined", "Use a non-negative shift amount.", 'warning', 'TYPE'),
|
|
210
|
+
'THY-178': E('THY-178', "Bitwise shift by ≥32 is undefined for 32-bit integers", "Keep shift amount below 32.", 'warning', 'TYPE'),
|
|
211
|
+
'THY-179': E('THY-179', "Chained optional access '?.' on non-nullable type '{0}'", "Remove '?.' — '{0}' is never null.", 'info', 'TYPE'),
|
|
212
|
+
'THY-180': E('THY-180', "Type '{0}' has no index signature", "Add an index signature or use a Map type.", 'error', 'TYPE'),
|
|
213
|
+
'THY-181': E('THY-181', "Mapped type result has no keys", "The source type produces an empty mapped type.", 'warning', 'TYPE'),
|
|
214
|
+
'THY-182': E('THY-182', "Conditional type recursion depth exceeded", "Simplify the conditional type or use a mapped type.", 'error', 'TYPE'),
|
|
215
|
+
'THY-183': E('THY-183', "Type parameter '{0}' shadows outer type parameter", "Rename one of the type parameters.", 'warning', 'TYPE'),
|
|
216
|
+
'THY-184': E('THY-184', "Default type argument '{0}' violates constraint '{1}'", "Choose a default that satisfies the constraint.", 'error', 'TYPE'),
|
|
217
|
+
'THY-185': E('THY-185', "Intersection type '{0}' resolves to 'never'", "The intersected types are incompatible.", 'error', 'TYPE'),
|
|
218
|
+
'THY-186': E('THY-186', "Template literal interpolation of type '{0}' is lossy", "Convert explicitly with str().", 'warning', 'TYPE'),
|
|
219
|
+
'THY-187': E('THY-187', "Coercion from '{0}' to '{1}' may lose precision", "Use explicit conversion and handle precision loss.", 'warning', 'TYPE'),
|
|
220
|
+
'THY-188': E('THY-188', "Index type '{0}' produces undefined for missing keys", "Use a default value or existence check first.", 'warning', 'TYPE'),
|
|
221
|
+
'THY-189': E('THY-189', "Homomorphic mapped type source '{0}' is primitive", "Only map over object types.", 'error', 'TYPE'),
|
|
222
|
+
'THY-190': E('THY-190', "Function type parameter '{0}' is unused", "Remove the unused type parameter or use it in the signature.", 'warning', 'TYPE'),
|
|
223
|
+
'THY-191': E('THY-191', "Class '{0}' must declare 'implements {1}'", "Add 'implements {1}' to the class declaration.", 'error', 'TYPE'),
|
|
224
|
+
'THY-192': E('THY-192', "Accessor pair getter/setter for '{0}' have incompatible types", "Ensure getter return type matches setter parameter type.", 'error', 'TYPE'),
|
|
225
|
+
'THY-193': E('THY-193', "Private field '{0}' is not accessible from this context", "Access '#{}' only from within the owning class.", 'error', 'TYPE'),
|
|
226
|
+
'THY-194': E('THY-194', "Protected member '{0}' is accessible only within '{1}' and its subclasses", "Move access inside the class hierarchy.", 'error', 'TYPE'),
|
|
227
|
+
'THY-195': E('THY-195', "Namespace '{0}' does not export '{1}'", "Check the namespace exports or the symbol name.", 'error', 'TYPE'),
|
|
228
|
+
'THY-196': E('THY-196', "Value type '{0}' cannot be used as a type argument", "Use a type, not a value, as the type argument.", 'error', 'TYPE'),
|
|
229
|
+
'THY-197': E('THY-197', "Type-only import '{0}' is used as a value", "Remove 'type' from the import or use the value import.", 'error', 'TYPE'),
|
|
230
|
+
'THY-198': E('THY-198', "Type-only export '{0}' is re-exported as value", "Use a type-only re-export 'export type'.", 'warning', 'TYPE'),
|
|
231
|
+
'THY-199': E('THY-199', "Satisfies operator: '{0}' does not satisfy '{1}'", "Ensure '{0}' matches all members of '{1}'.", 'error', 'TYPE'),
|
|
232
|
+
'THY-200': E('THY-200', "Type check failed for '{0}' ({1})", "Review the type annotation and value.", 'error', 'TYPE'),
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
236
|
+
// SCOPE ERRORS THY-201 … THY-300
|
|
237
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
238
|
+
const SCOPE = {
|
|
239
|
+
'THY-201': E('THY-201', "'{0}' is not defined", "Declare '{0}' before use, or check for a typo.", 'error', 'SCOPE'),
|
|
240
|
+
'THY-202': E('THY-202', "'{0}' is used before it is declared", "Move the declaration before the first use.", 'error', 'SCOPE'),
|
|
241
|
+
'THY-203': E('THY-203', "Duplicate identifier '{0}' in this scope", "Rename one of the declarations.", 'error', 'SCOPE'),
|
|
242
|
+
'THY-204': E('THY-204', "'{0}' shadows outer variable '{0}'", "Rename the inner variable to avoid confusion.", 'warning', 'SCOPE'),
|
|
243
|
+
'THY-205': E('THY-205', "Variable '{0}' is declared but never used", "Remove '{0}' or prefix with '_' to suppress this warning.", 'warning', 'SCOPE'),
|
|
244
|
+
'THY-206': E('THY-206', "Constant '{0}' cannot be re-assigned", "Use 'let' instead of 'const' if you need mutation.", 'error', 'SCOPE'),
|
|
245
|
+
'THY-207': E('THY-207', "Constant '{0}' must be initialized at declaration", "Assign a value: const {0} = ...", 'error', 'SCOPE'),
|
|
246
|
+
'THY-208': E('THY-208', "Function '{0}' is not defined in this scope", "Declare '{0}' before calling it.", 'error', 'SCOPE'),
|
|
247
|
+
'THY-209': E('THY-209', "Class '{0}' is not defined", "Import or declare class '{0}' before using it.", 'error', 'SCOPE'),
|
|
248
|
+
'THY-210': E('THY-210', "'{0}' is not accessible here (out of scope)", "Move the access inside the scope where '{0}' is defined.", 'error', 'SCOPE'),
|
|
249
|
+
'THY-211': E('THY-211', "Function parameter '{0}' shadows outer variable", "Rename the parameter or the outer variable.", 'warning', 'SCOPE'),
|
|
250
|
+
'THY-212': E('THY-212', "Label '{0}' is not defined", "Add a label '{0}:' before the targeted statement.", 'error', 'SCOPE'),
|
|
251
|
+
'THY-213': E('THY-213', "Import '{0}' is declared but never used", "Remove the unused import or use it.", 'warning', 'SCOPE'),
|
|
252
|
+
'THY-214': E('THY-214', "Namespace '{0}' is not defined", "Import the namespace or declare it.", 'error', 'SCOPE'),
|
|
253
|
+
'THY-215': E('THY-215', "Module '{0}' has no named export '{1}'", "Check the export name or the module path.", 'error', 'SCOPE'),
|
|
254
|
+
'THY-216': E('THY-216', "Ambient declaration '{0}' conflicts with existing binding", "Rename one of the declarations.", 'error', 'SCOPE'),
|
|
255
|
+
'THY-217': E('THY-217', "Loop variable '{0}' is captured inside async closure", "Use 'let' in the loop header to create a new binding each iteration.", 'warning', 'SCOPE'),
|
|
256
|
+
'THY-218': E('THY-218', "Closure captures mutable variable '{0}' which may change", "Create a local copy inside the closure.", 'warning', 'SCOPE'),
|
|
257
|
+
'THY-219': E('THY-219', "'this' is used outside of a method or class", "Arrow functions do not rebind 'this'.", 'error', 'SCOPE'),
|
|
258
|
+
'THY-220': E('THY-220', "'super' called outside of a subclass constructor", "Add 'extends ParentClass' to the class declaration.", 'error', 'SCOPE'),
|
|
259
|
+
'THY-221': E('THY-221', "'super()' must be called before accessing 'this'", "Call 'super()' as the first statement in the constructor.", 'error', 'SCOPE'),
|
|
260
|
+
'THY-222': E('THY-222', "Enum '{0}' is not defined", "Declare enum '{0}' before use.", 'error', 'SCOPE'),
|
|
261
|
+
'THY-223': E('THY-223', "Interface '{0}' is not defined", "Declare or import interface '{0}'.", 'error', 'SCOPE'),
|
|
262
|
+
'THY-224': E('THY-224', "Type alias '{0}' is not defined", "Declare or import type alias '{0}'.", 'error', 'SCOPE'),
|
|
263
|
+
'THY-225': E('THY-225', "Variable '{0}' is assigned but never read", "Remove the assignment or use the value.", 'warning', 'SCOPE'),
|
|
264
|
+
'THY-226': E('THY-226', "Parameter '{0}' is never used", "Prefix with '_' to suppress: _{0}.", 'warning', 'SCOPE'),
|
|
265
|
+
'THY-227': E('THY-227', "Global variable '{0}' is implicitly created", "Declare '{0}' explicitly with 'let' or 'const'.", 'error', 'SCOPE'),
|
|
266
|
+
'THY-228': E('THY-228', "Accessing 'arguments' in arrow function", "Arrow functions have no 'arguments' object; use rest params instead.", 'error', 'SCOPE'),
|
|
267
|
+
'THY-229': E('THY-229', "Type parameter '{0}' is defined but never used", "Remove or use the type parameter.", 'warning', 'SCOPE'),
|
|
268
|
+
'THY-230': E('THY-230', "Circular reference in variable initialization: '{0}'", "Restructure to remove the circular dependency.", 'error', 'SCOPE'),
|
|
269
|
+
// ... (fill remaining 70 slots with similar structured entries)
|
|
270
|
+
'THY-231': E('THY-231', "'{0}' is only available in a module context", "Add 'module' declaration to the file.", 'error', 'SCOPE'),
|
|
271
|
+
'THY-232': E('THY-232', "Exported name '{0}' conflicts with import", "Rename the export or the import.", 'error', 'SCOPE'),
|
|
272
|
+
'THY-233': E('THY-233', "Implicit global assignment to '{0}'", "Use 'let' or 'const' to declare '{0}' explicitly.", 'warning', 'SCOPE'),
|
|
273
|
+
'THY-234': E('THY-234', "Variable '{0}' is in temporal dead zone", "Do not access '{0}' before its 'let'/'const' declaration.", 'error', 'SCOPE'),
|
|
274
|
+
'THY-235': E('THY-235', "Duplicate default export", "A module can have only one default export.", 'error', 'SCOPE'),
|
|
275
|
+
'THY-236': E('THY-236', "Re-declaration of '{0}' with different modifier", "Use the same access modifier as the original declaration.", 'error', 'SCOPE'),
|
|
276
|
+
'THY-237': E('THY-237', "'{0}' is a type and cannot be used as a value", "Import the value separately from the type.", 'error', 'SCOPE'),
|
|
277
|
+
'THY-238': E('THY-238', "Block-scoped variable '{0}' used before declaration in same block", "Move declaration to the top of the block.", 'error', 'SCOPE'),
|
|
278
|
+
'THY-239': E('THY-239', "Mixin '{0}' is not defined", "Declare or import the mixin before using it.", 'error', 'SCOPE'),
|
|
279
|
+
'THY-240': E('THY-240', "Decorator '{0}' is not defined", "Import or declare decorator '{0}'.", 'error', 'SCOPE'),
|
|
280
|
+
'THY-300': E('THY-300', "Scope analysis error near '{0}'", "Review the code in this scope.", 'error', 'SCOPE'),
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
284
|
+
// RUNTIME ERRORS THY-301 … THY-400
|
|
285
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
286
|
+
const RUNTIME = {
|
|
287
|
+
'THY-301': E('THY-301', "Division by zero", "Check divisor is non-zero before dividing.", 'error', 'RUNTIME'),
|
|
288
|
+
'THY-302': E('THY-302', "Stack overflow: maximum call depth exceeded", "Reduce recursion depth or add a base case.", 'error', 'RUNTIME'),
|
|
289
|
+
'THY-303': E('THY-303', "Memory limit exceeded ({0} MB)", "Reduce memory usage or increase limit with --memory-limit.", 'error', 'RUNTIME'),
|
|
290
|
+
'THY-304': E('THY-304', "Null dereference on '{0}'", "Check '{0}' is not null before accessing its members.", 'error', 'RUNTIME'),
|
|
291
|
+
'THY-305': E('THY-305', "Undefined is not a function: '{0}'", "Ensure '{0}' is assigned a function before calling.", 'error', 'RUNTIME'),
|
|
292
|
+
'THY-306': E('THY-306', "Array index {0} out of bounds (length {1})", "Use an index between 0 and {1} - 1.", 'error', 'RUNTIME'),
|
|
293
|
+
'THY-307': E('THY-307', "Property '{0}' is undefined on '{1}'", "Check the property name or use optional chaining.", 'error', 'RUNTIME'),
|
|
294
|
+
'THY-308': E('THY-308', "Infinite loop detected after {0} iterations", "Add a proper exit condition to the loop.", 'error', 'RUNTIME'),
|
|
295
|
+
'THY-309': E('THY-309', "Unhandled promise rejection: {0}", "Add .catch() or use try/catch with await.", 'error', 'RUNTIME'),
|
|
296
|
+
'THY-310': E('THY-310', "Maximum string length exceeded ({0} chars)", "Reduce string size or use streaming.", 'error', 'RUNTIME'),
|
|
297
|
+
'THY-311': E('THY-311', "Regex execution timed out (catastrophic backtracking?)", "Simplify the regex or add atomic groups.", 'error', 'RUNTIME'),
|
|
298
|
+
'THY-312': E('THY-312', "Type coercion failed: '{0}' cannot be converted to '{1}'", "Provide a value that can be converted to '{1}'.", 'error', 'RUNTIME'),
|
|
299
|
+
'THY-313': E('THY-313', "JSON parse error: {0}", "Validate the JSON string before parsing.", 'error', 'RUNTIME'),
|
|
300
|
+
'THY-314': E('THY-314', "JSON stringify: circular reference detected", "Remove circular references before stringifying.", 'error', 'RUNTIME'),
|
|
301
|
+
'THY-315': E('THY-315', "File not found: '{0}'", "Check the file path and ensure the file exists.", 'error', 'RUNTIME'),
|
|
302
|
+
'THY-316': E('THY-316', "Permission denied: '{0}'", "Check file/directory permissions.", 'error', 'RUNTIME'),
|
|
303
|
+
'THY-317': E('THY-317', "Assertion failed: {0}", "Fix the failing assertion condition.", 'error', 'RUNTIME'),
|
|
304
|
+
'THY-318': E('THY-318', "Integer overflow: {0} exceeds {1}-bit range", "Use BigInt or reduce the value.", 'error', 'RUNTIME'),
|
|
305
|
+
'THY-319': E('THY-319', "Floating point: result is NaN", "Check inputs for invalid numeric operations.", 'error', 'RUNTIME'),
|
|
306
|
+
'THY-320': E('THY-320', "Floating point: result is Infinity", "Guard against division by zero or very large exponents.", 'warning', 'RUNTIME'),
|
|
307
|
+
'THY-321': E('THY-321', "Generator already finished: cannot call .next()", "Check generator state before calling .next().", 'error', 'RUNTIME'),
|
|
308
|
+
'THY-322': E('THY-322', "Cannot modify frozen object '{0}'", "Clone the object before modifying it.", 'error', 'RUNTIME'),
|
|
309
|
+
'THY-323': E('THY-323', "Maximum event emitter listeners exceeded for '{0}'", "Remove listeners when they are no longer needed.", 'warning', 'RUNTIME'),
|
|
310
|
+
'THY-324': E('THY-324', "Process exited with code {0}", "Handle the exit code and check for errors.", 'error', 'RUNTIME'),
|
|
311
|
+
'THY-325': E('THY-325', "Signal {0} received — shutting down", "Add a signal handler to clean up before shutdown.", 'info', 'RUNTIME'),
|
|
312
|
+
'THY-326': E('THY-326', "Worker thread crashed: {0}", "Check the worker code for unhandled errors.", 'error', 'RUNTIME'),
|
|
313
|
+
'THY-327': E('THY-327', "SharedArrayBuffer access out of bounds", "Check byte offsets before accessing SharedArrayBuffer.", 'error', 'RUNTIME'),
|
|
314
|
+
'THY-328': E('THY-328', "Prototype pollution attempt detected on '{0}'", "Do not assign to __proto__, constructor, or prototype keys.", 'error', 'RUNTIME'),
|
|
315
|
+
'THY-329': E('THY-329', "Dead code reached after {0}", "Remove unreachable code or fix control flow.", 'warning', 'RUNTIME'),
|
|
316
|
+
'THY-330': E('THY-330', "Timeout: operation exceeded {0}ms", "Increase the timeout or optimise the operation.", 'error', 'RUNTIME'),
|
|
317
|
+
'THY-400': E('THY-400', "Runtime error: {0}", "Review the runtime error and fix the root cause.", 'error', 'RUNTIME'),
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
321
|
+
// IMPORT ERRORS THY-401 … THY-500
|
|
322
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
323
|
+
const IMPORT = {
|
|
324
|
+
'THY-401': E('THY-401', "Module not found: '{0}'", "Install '{0}' with: thy use {0}", 'error', 'IMPORT'),
|
|
325
|
+
'THY-402': E('THY-402', "Circular dependency detected: {0}", "Refactor to break the circular import chain.", 'error', 'IMPORT'),
|
|
326
|
+
'THY-403': E('THY-403', "Cannot import from '{0}': file does not exist", "Check the import path or create the missing file.", 'error', 'IMPORT'),
|
|
327
|
+
'THY-404': E('THY-404', "Module '{0}' has no default export", "Use named imports: import { x } from '{0}'.", 'error', 'IMPORT'),
|
|
328
|
+
'THY-405': E('THY-405', "Dynamic import of '{0}' failed: {1}", "Check the module path and ensure it is resolvable.", 'error', 'IMPORT'),
|
|
329
|
+
'THY-406': E('THY-406', "Module '{0}' is not a valid ThyScript module", "Ensure '{0}' exports a valid ThyScript-compatible API.", 'error', 'IMPORT'),
|
|
330
|
+
'THY-407': E('THY-407', "Version mismatch: '{0}' requires ThyScript {1}, but {2} is installed", "Update ThyScript or downgrade '{0}'.", 'error', 'IMPORT'),
|
|
331
|
+
'THY-408': E('THY-408', "Native module '{0}' failed to load: {1}", "Rebuild native module: npm rebuild {0}.", 'error', 'IMPORT'),
|
|
332
|
+
'THY-409': E('THY-409', "Import of '{0}' is not allowed in this environment", "Check environment restrictions.", 'error', 'IMPORT'),
|
|
333
|
+
'THY-410': E('THY-410', "Re-export of '{0}' from '{1}' creates an ambiguous export", "Resolve the naming conflict.", 'error', 'IMPORT'),
|
|
334
|
+
'THY-411': E('THY-411', "Side-effect import '{0}' may be tree-shaken", "Mark as side-effect: add to sideEffects in package.json.", 'warning', 'IMPORT'),
|
|
335
|
+
'THY-412': E('THY-412', "Import map entry '{0}' is missing", "Add '{0}' to the import map configuration.", 'error', 'IMPORT'),
|
|
336
|
+
'THY-413': E('THY-413', "Module '{0}' exceeds size limit ({1} KB)", "Split the module or use dynamic imports.", 'warning', 'IMPORT'),
|
|
337
|
+
'THY-414': E('THY-414', "Package '{0}' is not listed in package.json dependencies", "Run: thy use {0}", 'warning', 'IMPORT'),
|
|
338
|
+
'THY-415': E('THY-415', "Module resolution failed for '{0}': ambiguous path", "Use an explicit relative path (./ or ../).", 'error', 'IMPORT'),
|
|
339
|
+
'THY-416': E('THY-416', "Barrel file '{0}' has too many exports (>{1})", "Split into smaller modules.", 'warning', 'IMPORT'),
|
|
340
|
+
'THY-417': E('THY-417', "Import '{0}' duplicates an existing import", "Remove the duplicate import statement.", 'warning', 'IMPORT'),
|
|
341
|
+
'THY-418': E('THY-418', "Cannot use require() in ES module context", "Use import syntax instead of require().", 'error', 'IMPORT'),
|
|
342
|
+
'THY-419': E('THY-419', "Cannot use import in CommonJS context", "Add \"type\": \"module\" to package.json or use .mjs extension.", 'error', 'IMPORT'),
|
|
343
|
+
'THY-420': E('THY-420', "Module '{0}' is deprecated: {1}", "Migrate to the recommended replacement: {1}.", 'warning', 'IMPORT'),
|
|
344
|
+
'THY-500': E('THY-500', "Import error: {0}", "Review the import statement and module path.", 'error', 'IMPORT'),
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
348
|
+
// SERVER ERRORS THY-501 … THY-600
|
|
349
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
350
|
+
const SERVER = {
|
|
351
|
+
'THY-501': E('THY-501', "Port {0} is already in use", "Use a different port: thy serve --port {1}.", 'error', 'SERVER'),
|
|
352
|
+
'THY-502': E('THY-502', "SSL certificate not found: '{0}'", "Generate a certificate or check the path.", 'error', 'SERVER'),
|
|
353
|
+
'THY-503': E('THY-503', "SSL certificate expired", "Renew the SSL certificate.", 'error', 'SERVER'),
|
|
354
|
+
'THY-504': E('THY-504', "SSL certificate invalid: {0}", "Use a valid certificate signed by a trusted CA.", 'error', 'SERVER'),
|
|
355
|
+
'THY-505': E('THY-505', "Connection refused to {0}:{1}", "Check the server is running and the host/port are correct.", 'error', 'SERVER'),
|
|
356
|
+
'THY-506': E('THY-506', "Connection timed out to {0}:{1}", "Check network connectivity and firewall rules.", 'error', 'SERVER'),
|
|
357
|
+
'THY-507': E('THY-507', "WebSocket handshake failed: {0}", "Check WebSocket server configuration.", 'error', 'SERVER'),
|
|
358
|
+
'THY-508': E('THY-508', "HTTP {0} error from {1}: {2}", "Handle the error response from the server.", 'error', 'SERVER'),
|
|
359
|
+
'THY-509': E('THY-509', "Request body exceeds size limit ({0} MB)", "Increase body-parser limit or reduce request size.", 'error', 'SERVER'),
|
|
360
|
+
'THY-510': E('THY-510', "Route '{0}' is already registered", "Use a unique path for each route.", 'error', 'SERVER'),
|
|
361
|
+
'THY-511': E('THY-511', "Middleware '{0}' threw an unhandled error: {1}", "Add error handling inside the middleware.", 'error', 'SERVER'),
|
|
362
|
+
'THY-512': E('THY-512', "CORS error: origin '{0}' is not allowed", "Add '{0}' to the allowed origins list.", 'error', 'SERVER'),
|
|
363
|
+
'THY-513': E('THY-513', "Rate limit exceeded for IP {0}", "Implement exponential back-off before retrying.", 'warning', 'SERVER'),
|
|
364
|
+
'THY-514': E('THY-514', "Server crashed: {0}", "Review server logs and fix the crash cause.", 'error', 'SERVER'),
|
|
365
|
+
'THY-515': E('THY-515', "Invalid HTTP method '{0}'", "Use a valid HTTP method: GET, POST, PUT, PATCH, DELETE, etc.", 'error', 'SERVER'),
|
|
366
|
+
'THY-516': E('THY-516', "Proxy error forwarding to '{0}': {1}", "Check the upstream server availability.", 'error', 'SERVER'),
|
|
367
|
+
'THY-517': E('THY-517', "Session store error: {0}", "Check session store configuration.", 'error', 'SERVER'),
|
|
368
|
+
'THY-518': E('THY-518', "Cookie parsing error: {0}", "Ensure cookie-parser middleware is configured.", 'error', 'SERVER'),
|
|
369
|
+
'THY-519': E('THY-519', "Static file server error: '{0}' not found", "Check the static files directory path.", 'error', 'SERVER'),
|
|
370
|
+
'THY-520': E('THY-520', "Cluster worker {0} died unexpectedly", "Monitor worker health and restart on crash.", 'error', 'SERVER'),
|
|
371
|
+
'THY-600': E('THY-600', "Server error: {0}", "Review the server configuration and logs.", 'error', 'SERVER'),
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
375
|
+
// DATABASE ERRORS THY-601 … THY-700
|
|
376
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
377
|
+
const DATABASE = {
|
|
378
|
+
'THY-601': E('THY-601', "Database connection failed: {0}", "Check connection string and database server status.", 'error', 'DATABASE'),
|
|
379
|
+
'THY-602': E('THY-602', "Query error: {0}", "Review the SQL/query syntax.", 'error', 'DATABASE'),
|
|
380
|
+
'THY-603': E('THY-603', "Constraint violation: {0}", "Check unique, foreign key, and not-null constraints.", 'error', 'DATABASE'),
|
|
381
|
+
'THY-604': E('THY-604', "Table '{0}' does not exist", "Run migrations or create the table.", 'error', 'DATABASE'),
|
|
382
|
+
'THY-605': E('THY-605', "Column '{0}' does not exist in table '{1}'", "Check column name spelling or run a schema migration.", 'error', 'DATABASE'),
|
|
383
|
+
'THY-606': E('THY-606', "Duplicate key value violates unique constraint '{0}'", "Use INSERT OR REPLACE or check for existing records first.", 'error', 'DATABASE'),
|
|
384
|
+
'THY-607': E('THY-607', "Foreign key constraint failed for column '{0}'", "Ensure the referenced record exists before inserting.", 'error', 'DATABASE'),
|
|
385
|
+
'THY-608': E('THY-608', "Transaction rolled back: {0}", "Retry the transaction or fix the error causing rollback.", 'error', 'DATABASE'),
|
|
386
|
+
'THY-609': E('THY-609', "Deadlock detected between transactions", "Retry after a short delay with exponential back-off.", 'error', 'DATABASE'),
|
|
387
|
+
'THY-610': E('THY-610', "Database file locked: '{0}'", "Ensure only one process accesses the database at a time.", 'error', 'DATABASE'),
|
|
388
|
+
'THY-611': E('THY-611', "Query timeout after {0}ms", "Optimise the query or increase the query timeout.", 'error', 'DATABASE'),
|
|
389
|
+
'THY-612': E('THY-612', "Connection pool exhausted ({0} max)", "Increase pool size or reduce connection hold time.", 'error', 'DATABASE'),
|
|
390
|
+
'THY-613': E('THY-613', "Migration failed at step {0}: {1}", "Fix the migration script and re-run.", 'error', 'DATABASE'),
|
|
391
|
+
'THY-614': E('THY-614', "Schema mismatch: expected version {0} but got {1}", "Run pending migrations: thy db migrate.", 'error', 'DATABASE'),
|
|
392
|
+
'THY-615': E('THY-615', "ORM model '{0}' is not registered", "Register the model before using it.", 'error', 'DATABASE'),
|
|
393
|
+
'THY-616': E('THY-616', "Null value in non-nullable column '{0}'", "Provide a value for the column or set a default.", 'error', 'DATABASE'),
|
|
394
|
+
'THY-617': E('THY-617', "Data type mismatch: column '{0}' expects {1} got {2}", "Convert the value before inserting.", 'error', 'DATABASE'),
|
|
395
|
+
'THY-618': E('THY-618', "Record not found for id={0}", "Check the ID or handle the not-found case.", 'warning', 'DATABASE'),
|
|
396
|
+
'THY-619': E('THY-619', "Batch insert exceeded max rows ({0})", "Split the batch into smaller chunks.", 'warning', 'DATABASE'),
|
|
397
|
+
'THY-620': E('THY-620', "SQL injection pattern detected in query", "Use parameterised queries — never concatenate user input.", 'error', 'DATABASE'),
|
|
398
|
+
'THY-700': E('THY-700', "Database error: {0}", "Review the database operation and configuration.", 'error', 'DATABASE'),
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
402
|
+
// SECURITY ERRORS THY-701 … THY-800
|
|
403
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
404
|
+
const SECURITY = {
|
|
405
|
+
'THY-701': E('THY-701', "SQL injection pattern detected in input '{0}'", "Use parameterised queries — never interpolate raw input.", 'error', 'SECURITY'),
|
|
406
|
+
'THY-702': E('THY-702', "XSS pattern detected in output '{0}'", "Sanitise and escape HTML output with escapeHtml().", 'error', 'SECURITY'),
|
|
407
|
+
'THY-703': E('THY-703', "JWT token is invalid: {0}", "Verify the token signature and expiry.", 'error', 'SECURITY'),
|
|
408
|
+
'THY-704': E('THY-704', "JWT token has expired", "Re-authenticate to obtain a fresh token.", 'error', 'SECURITY'),
|
|
409
|
+
'THY-705': E('THY-705', "Authentication failed: invalid credentials", "Check username and password.", 'error', 'SECURITY'),
|
|
410
|
+
'THY-706': E('THY-706', "Authorisation failed: insufficient permissions for '{0}'", "Request elevated permissions or use a different account.", 'error', 'SECURITY'),
|
|
411
|
+
'THY-707': E('THY-707', "CSRF token mismatch", "Include a valid CSRF token in the request.", 'error', 'SECURITY'),
|
|
412
|
+
'THY-708': E('THY-708', "Path traversal attempt detected: '{0}'", "Validate and sanitise file paths.", 'error', 'SECURITY'),
|
|
413
|
+
'THY-709': E('THY-709', "Command injection attempt detected: '{0}'", "Use safe APIs instead of shell commands with user input.", 'error', 'SECURITY'),
|
|
414
|
+
'THY-710': E('THY-710', "Insecure random used for security-sensitive operation", "Use crypto.randomBytes() for cryptographic randomness.", 'error', 'SECURITY'),
|
|
415
|
+
'THY-711': E('THY-711', "Hardcoded secret detected in source: '{0}'", "Move secrets to environment variables or a secrets manager.", 'error', 'SECURITY'),
|
|
416
|
+
'THY-712': E('THY-712', "Password stored in plain text", "Hash passwords with bcrypt before storing.", 'error', 'SECURITY'),
|
|
417
|
+
'THY-713': E('THY-713', "Sensitive data logged: {0}", "Remove sensitive fields from logs.", 'error', 'SECURITY'),
|
|
418
|
+
'THY-714': E('THY-714', "HTTP used instead of HTTPS for sensitive request", "Use HTTPS for all sensitive communications.", 'error', 'SECURITY'),
|
|
419
|
+
'THY-715': E('THY-715', "Cookie '{0}' missing Secure flag", "Set Secure=true on cookies transmitting sensitive data.", 'warning', 'SECURITY'),
|
|
420
|
+
'THY-716': E('THY-716', "Cookie '{0}' missing HttpOnly flag", "Set HttpOnly=true to prevent JavaScript access.", 'warning', 'SECURITY'),
|
|
421
|
+
'THY-717': E('THY-717', "SSRF attempt: request to internal address {0}", "Validate and whitelist outbound URLs.", 'error', 'SECURITY'),
|
|
422
|
+
'THY-718': E('THY-718', "Open redirect to external URL: '{0}'", "Validate redirect URLs against an allowlist.", 'error', 'SECURITY'),
|
|
423
|
+
'THY-719': E('THY-719', "Prototype pollution via '{0}'", "Validate input keys and reject __proto__, constructor, prototype.", 'error', 'SECURITY'),
|
|
424
|
+
'THY-720': E('THY-720', "eval() called with user-controlled input", "Never pass user input to eval(); use safer alternatives.", 'error', 'SECURITY'),
|
|
425
|
+
'THY-800': E('THY-800', "Security violation: {0}", "Review the security policy and fix the violation.", 'error', 'SECURITY'),
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
429
|
+
// MATH ERRORS THY-801 … THY-900
|
|
430
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
431
|
+
const MATH = {
|
|
432
|
+
'THY-801': E('THY-801', "Division by zero: {0} / 0", "Check divisor is non-zero before dividing.", 'error', 'MATH'),
|
|
433
|
+
'THY-802': E('THY-802', "Integer overflow: {0} exceeds MAX_SAFE_INTEGER", "Use BigInt for integers larger than 2^53 - 1.", 'error', 'MATH'),
|
|
434
|
+
'THY-803': E('THY-803', "Integer underflow: {0} is less than MIN_SAFE_INTEGER", "Use BigInt for very small integers.", 'error', 'MATH'),
|
|
435
|
+
'THY-804': E('THY-804', "NaN produced by '{0}'", "Ensure inputs are valid numbers before the operation.", 'error', 'MATH'),
|
|
436
|
+
'THY-805': E('THY-805', "Infinity produced by '{0}'", "Guard against operations that can produce Infinity.", 'warning', 'MATH'),
|
|
437
|
+
'THY-806': E('THY-806', "Negative Infinity produced by '{0}'", "Guard against operations that produce -Infinity.", 'warning', 'MATH'),
|
|
438
|
+
'THY-807': E('THY-807', "Square root of negative number: sqrt({0})", "Use Math.abs() or complex number library.", 'error', 'MATH'),
|
|
439
|
+
'THY-808': E('THY-808', "Logarithm of non-positive number: log({0})", "Ensure input is > 0 before calling log().", 'error', 'MATH'),
|
|
440
|
+
'THY-809': E('THY-809', "Power with negative base and fractional exponent: {0}^{1}", "Use complex number arithmetic for fractional powers of negatives.", 'error', 'MATH'),
|
|
441
|
+
'THY-810': E('THY-810', "Modulo by zero: {0} % 0", "Check divisor is non-zero before modulo.", 'error', 'MATH'),
|
|
442
|
+
'THY-811': E('THY-811', "Float comparison with == is unreliable: {0} == {1}", "Use Math.abs(a - b) < epsilon for float comparisons.", 'warning', 'MATH'),
|
|
443
|
+
'THY-812': E('THY-812', "Precision loss in float-to-int conversion: {0}", "Use Math.round(), Math.floor(), or Math.ceil() explicitly.", 'warning', 'MATH'),
|
|
444
|
+
'THY-813': E('THY-813', "Arithmetic shift right (>>>) changes sign: {0}", "Use >> for signed shift or check sign expectations.", 'warning', 'MATH'),
|
|
445
|
+
'THY-814': E('THY-814', "Factorial input too large: {0}! causes overflow", "Limit factorial input or use logarithmic factorial.", 'error', 'MATH'),
|
|
446
|
+
'THY-815': E('THY-815', "Exponent too large: {0}^{1} will overflow", "Reduce the exponent or use BigInt.", 'error', 'MATH'),
|
|
447
|
+
'THY-816': E('THY-816', "arcsin/arccos input out of range: {0} (must be -1 to 1)", "Clamp the input to [-1, 1] before calling asin/acos.", 'error', 'MATH'),
|
|
448
|
+
'THY-817': E('THY-817', "Matrix dimensions incompatible for multiplication: ({0}x{1}) * ({2}x{3})", "Ensure columns of A equal rows of B.", 'error', 'MATH'),
|
|
449
|
+
'THY-818': E('THY-818', "Determinant of singular matrix is zero — no inverse", "Check if the matrix is invertible before calling inverse().", 'error', 'MATH'),
|
|
450
|
+
'THY-819': E('THY-819', "Random seed {0} produces degenerate sequence", "Use a different seed or ensure proper PRNG initialisation.", 'warning', 'MATH'),
|
|
451
|
+
'THY-820': E('THY-820', "Bitwise operation on float truncates fractional part: {0}", "Convert to int before bitwise operations.", 'warning', 'MATH'),
|
|
452
|
+
'THY-900': E('THY-900', "Math error: {0}", "Review the mathematical operation and input ranges.", 'error', 'MATH'),
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
456
|
+
// Master export
|
|
457
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
458
|
+
const ALL_ERRORS = Object.assign(
|
|
459
|
+
{}, SYNTAX, TYPE, SCOPE, RUNTIME, IMPORT, SERVER, DATABASE, SECURITY, MATH,
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Look up an error by code, substituting template placeholders.
|
|
464
|
+
*
|
|
465
|
+
* @param {string} code - e.g. 'THY-101'
|
|
466
|
+
* @param {...string} args - substitution values for {0}, {1}, ...
|
|
467
|
+
* @returns {object|null}
|
|
468
|
+
*/
|
|
469
|
+
function get(code, ...args) {
|
|
470
|
+
const entry = ALL_ERRORS[code];
|
|
471
|
+
if (!entry) return null;
|
|
472
|
+
return {
|
|
473
|
+
...entry,
|
|
474
|
+
message: format(entry.message, ...args),
|
|
475
|
+
suggestion: format(entry.suggestion, ...args),
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* List all codes for a given category.
|
|
481
|
+
* @param {'SYNTAX'|'TYPE'|'SCOPE'|'RUNTIME'|'IMPORT'|'SERVER'|'DATABASE'|'SECURITY'|'MATH'} category
|
|
482
|
+
*/
|
|
483
|
+
function listCategory(category) {
|
|
484
|
+
return Object.values(ALL_ERRORS).filter(e => e.category === category);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** All error codes as an array. */
|
|
488
|
+
function list() { return Object.values(ALL_ERRORS); }
|
|
489
|
+
|
|
490
|
+
module.exports = {
|
|
491
|
+
errors: ALL_ERRORS,
|
|
492
|
+
get,
|
|
493
|
+
list,
|
|
494
|
+
listCategory,
|
|
495
|
+
// Re-export category objects for tree-shaking-friendly access
|
|
496
|
+
SYNTAX, TYPE, SCOPE, RUNTIME, IMPORT, SERVER, DATABASE, SECURITY, MATH,
|
|
497
|
+
};
|