Skip to content

Errores y diagnósticos ​

Los diagnósticos de tyrus usan códigos estables, rangos de origen precisos, labels relacionados y ayuda accionable cuando existe una corrección concreta. El mismo análisis del compilador alimenta la CLI y el Language Server.

Lee el rango primero

Los diagnósticos deben apuntar al token, expresión, declaración o inicializador que causó el problema. Cuando el editor muestra un squiggle, empieza por el rango resaltado.

Errores del compilador ​

Los errores de tipo detienen la compilación antes de la generación de código LLVM.

error

tyrus
const maxUsers: u32 = "100"; 

error

text
error[E0308]: type mismatch for `maxUsers`: expected `u32`, found `string`
at /src/main.tyr:1:7
const maxUsers: u32 = "100";
      ^^^^^^^^
help: change the value or the annotation so their types match; convert numbers explicitly with `value as <type>`

Errores de borrow y move ​

Los valores non-Copy se mueven por default. Después de un move, el binding anterior queda inválido.

error

tyrus
const name: string = "Ada";
const moved: string = name;
print(name); 

error

text
error[E0382]: use of moved value: `name`
at /src/main.tyr:3:13
print(name);
            ^^^^
at /src/main.tyr:2:23
const moved: string = name;
                      ^^^^ value moved here; borrow `name` instead if it must remain usable
help: borrow `name` at the move site if it must remain usable later
help: for example: `const moved: &string = &name;`

Ownership se aplica antes del runtime

Los errores de move y borrow son fallas de compilación. El binario generado nunca necesita un garbage collector para recuperarse de estos errores.

Warnings del linter ​

Los warnings de lint reportan código válido, pero riesgoso, ruidoso o inconsistente con la arquitectura del proyecto.

error

tyrus
let retries: u32 = 3; 
print(retries); // 3

error

text
warning[prefer-const]: `retries` is never reassigned
  --> src/main.tyr:1:1
   |
 1 | let retries: u32 = 3;
   | ^^^
   |
help: use `const` for `retries`

Cuando la corrección es determinística, el Language Server expone la misma edición como Quick Fix.

Fallas de runtime ​

Los programas generados escriben fallas de runtime en stderr y terminan con status distinto de cero. La salida normal de print permanece en stdout.

error

tyrus
const divisor: i32 = 0;
const value: i32 = 10 / divisor;
// runtime error: division by zero

error

text
runtime error: division by zero

Las fallas de runtime incluyen comprobaciones de seguridad insertadas por el compilador, como overflow, división por cero, narrowing inválido, unwrap forzado de optional y fallas de validación.

Fallas de validación ​

Validator decorations pueden fallar en tiempo de compilación para literales y en runtime para valores dinámicos.

error

tyrus
interface UserInput {
    @minLength(3)
    name: string;
}

const input: UserInput = { name: "Al" }; 

error

text
error[validator-decorations-failed]: `@minLength(3)` failed for `name`: value must contain at least 3 characters
at /src/main.tyr:6:34
const input: UserInput = { name: "Al" };
                                 ^^^^

Aborts de validación usan stderr

Las fallas de validación en runtime llaman al helper de panic de validación del runtime, imprimen el diagnóstico en stderr y terminan el proceso con status distinto de cero.

Diagnósticos en el editor ​

VS Code, Neovim, Zed e IntelliJ/WebStorm deben recibir diagnósticos desde tyrus lsp. Los clientes específicos de editor no deben reimplementar reglas de tipo.

Códigos de error ​

La tabla lista todos los diagnósticos públicos del compilador con el formato E####. Usa tyrus explain <código> para una referencia concisa en la terminal; los mensajes, labels y Quick Fixes disponibles siguen dependiendo del contexto.

CodeTitleCategory
E0001Unexpected tokenParse
E0002Invalid syntaxParse
E0003Reserved keywordParse
E0004Non-exhaustive matchPatterns
E0034Multiple applicable itemsName resolution
E0057Wrong callback parameter countType checking
E0061Wrong argument countType checking
E0063Missing object fieldType checking
E0069Invalid returnControl flow
E0107Wrong generic argument countType checking
E0268Invalid continueControl flow
E0269Invalid breakControl flow
E0277Trait or capability requirement not satisfiedType checking
E0282Type annotations neededType checking
E0308Mismatched typesType checking
E0309Invalid regular expression flagValidation
E0310Object literal needs an interface annotationType checking
E0315Invalid assignment targetType checking
E0316Invalid destructuring assignmentType checking
E0368Invalid compound assignmentType checking
E0369Unsupported binary operationType checking
E0381Use of possibly uninitialized variableControl flow
E0382Use of moved valueOwnership
E0384Assignment to immutable bindingOwnership
E0412Unknown typeName resolution
E0425Unknown nameName resolution
E0428Duplicate definitionName resolution
E0432Unresolved importModules
E0433Unresolved module or typeModules
E0434Test framework outside a test fileModules
E0435Invalid value in a constant expressionValidation
E0436Functional array operation has no return valueType checking
E0500Assignment to immutable captured valueOwnership
E0502Conflicting borrowOwnership
E0505Move while borrowedOwnership
E0506Assignment while borrowedOwnership
E0529Invalid patternPatterns
E0571Invalid break valueControl flow
E0572Invalid continue targetControl flow
E0580Invalid function declarationType checking
E0583Module file not foundModules
E0599Unknown methodName resolution
E0601Missing entry pointModules
E0605Invalid type castType checking
E0606Index out of boundsRuntime safety
E0608Cannot index this valueType checking
E0609Unknown fieldName resolution
E0618Called non-function valueType checking
E0658Unsupported language featureType checking
E0701Invalid enum representationEnums
E0702Mixed enum member typesEnums
E0703Mixed automatic and explicit enum valuesEnums
E0705Enum member value out of rangeEnums
E0706Value does not fit its typeType checking
E0707Invalid numeric limitType checking
E0708Invalid character literalType checking
E0716Forced optional unwrapType checking
E0717Invalid template format specifierType checking
E0747Invalid compile-time array argumentType checking
E0790Invalid array match patternPatterns
E0791Multiple array rest patternsPatterns
E0792Array rest pattern is not lastPatterns
E0793Invalid array rest bindingPatterns
E0794Value not representable as unknownType checking
E0795Invalid typeof categoryType checking
E1355Invalid compile-time evaluation targetValidation
E1356Compile-time evaluation failedValidation
E2300Duplicate HTTP routeModules
E2353Unknown object propertyType checking
E2493Tuple index out of rangeRuntime safety
E2540Assignment to readonly valueOwnership
E2541Recursive interface definitionType checking
E2542Invalid interface implementationType checking
E2543Invalid type aliasType checking
E2741Missing required object propertyType checking
E2742Unsafe CORS credential configurationValidation
E2743Unusable CORS optionValidation
E3000await outside an async functionControl flow
E3001await on a non-promiseType checking
E3002Unsupported await positionControl flow
E3003Async function missing a promise return typeType checking
E3004Async function missing a returnControl flow
E3005Unused promiseControl flow
E3006Promise already awaitedOwnership
E3007Unsupported owned async payloadType checking
E3008External thenable is not awaitableType checking
E3009Shadowed native async error typeName resolution
E3010Lock guard held across an await in a loopOwnership
E3011Unhandled thrown errorControl flow
E3012throws on the program entry pointControl flow
E3030spawn requires an async functionType checking
E3031Spawned task awaited immediatelyControl flow
E3032Busy wait in an async functionControl flow
E3033Join handle already consumedOwnership
E3034Lock guard held across an awaitOwnership
E3035Invalid channel capacityValidation
E3036Unsupported channel payloadType checking
E3037Unsupported mutex payloadType checking
E3038Unsupported rwlock payloadType checking
E3039Unknown channel endpoint typeName resolution
E3040Shadowed native channel typeName resolution
E3041Unknown join handle typeName resolution
E3042Shadowed native join handle typeName resolution
E3043Unknown mutex typeName resolution
E3044Shadowed native mutex typeName resolution
E3045Unknown rwlock typeName resolution
E3046Shadowed native rwlock typeName resolution
E3047Shadowed native semaphore typeName resolution
E3048Unknown promise typeName resolution
E3049Shadowed native promise typeName resolution
E3070Wrong Ok/Err arityType checking
E3071Result error type mismatchType checking
E3072Optional payload in a ResultType checking
E3073Result pattern on a non-resultPatterns
E3074Result return needs Ok or ErrControl flow
E3075Void result return needs Ok()Control flow
E3076try on a non-resultType checking
E3077try outside a functionControl flow
E3078try in a function that returns no resultType checking
E3079Optional compared against absenceType checking
E3080null literal is not a valueType checking
E3081Move out of a fieldOwnership
E3082Borrow held across an awaitOwnership
E3083Environment file not foundModules
E3085Async capture the frame cannot holdControl flow
E3086Async parameter the frame cannot holdControl flow
E3087Async parameter needing owned frame storageControl flow
E3088Async local needing owned frame storageControl flow
E3100Route without a declared responseValidation
E3101Reply without a statusControl flow
E3102Reply without a bodyControl flow
E3103Reply status set twiceControl flow
E3104Reply sent twiceControl flow
E3105Reply body does not match the declared responseType checking
E3106Undeclared response statusValidation
E3107Raw numeric status codeValidation
E3108Handler must take a replyType checking
E3109Reply flow too complex to verifyControl flow
E3110Handler type not importedName resolution
E3111Invalid portValidation
E3112Invalid server optionValidation
E3113listen options are not a literalValidation
E3114Invalid body limitValidation
E3115Invalid time windowValidation
E3116Invalid trusted proxyValidation
E3117Invalid header nameValidation
E3118Protected response headerValidation
E3119Reply used after streamControl flow
E3140Environment file not configuredModules
E3141Undeclared environment variableName resolution
E3142Duplicate environment variableName resolution
E3143Invalid environment valueValidation
E3144Environment accessed by indexValidation
E3145Invalid process useValidation
E3146Invalid environment file syntaxParse
E3147Environment variable without a typeType checking
E3148Environment variable without a valueValidation
E3149Unknown environment variable typeType checking
E3150Undefined environment referenceName resolution
E3151Cyclic environment referenceName resolution
E3152Invalid environment export decoratorValidation
E3160Unknown validator decorationValidation
E3161Validator decoration on an invalid targetValidation
E3162Invalid validator decoration argumentValidation
E3163Contradictory validator decorationsValidation
E3164Redundant validator decorationValidation
E3165Validator decoration cannot holdValidation
E3166Impossible validator conditionValidation
E3167Redundant validator conditionValidation
E3168Invalid custom validator functionValidation
E3169Invalid custom validator applicationValidation
E3200Wrong number of type argumentsType checking
E3201Missing type argumentsType checking
E3202Unknown generic typeName resolution
E3203Interface extends a non-interfaceType checking
E3204Conflicting inherited fieldType checking
E3205Interface inheritance cycleType checking
E3206Type recursion limit reachedType checking
E3207keyof on a non-objectType checking
E3208Wrong utility type arityType checking
E3209Utility key is not a literalType checking
E3210Utility type needs a functionType checking
E3211Utility type needs an objectType checking
E3212Unknown key in a utility typeType checking
E3213Intersection operand is not an object typeType checking
E3214Conflicting field in a type intersectionType checking
E3215Type intersection outside a type aliasParse
E3216Type intersection cycleType checking
E3217Type intersection mixed with a unionParse
E3218Missing semicolonParse
E3240Invalid map key typeType checking
E3241Invalid set element typeType checking
E3242Invalid union-find element typeType checking
E3243Unsupported type for a memory viewType checking
E3244Unstable layout for a memory viewType checking
E3245Mutable copy binding in a memory viewOwnership
E3246Mutable string source for a memory viewOwnership
E3247Overlapping memory view bindingsOwnership
E3270Wrong styleText arityType checking
E3271Incomplete styleText callType checking
E3272styleText style is not a literalValidation
E3273Unknown styleText styleValidation
E3274Wrong figlet arityType checking
E3275Incomplete figlet callType checking
E3276figlet font is not a literalValidation
E3277Unknown figlet fontValidation
E3278Insecure MD5 digestValidation
E3279JWT claims must be an objectType checking
E3280Unsupported JWT claim fieldType checking
E3290Pipe stage is not callableType checking
E3291Topic reference outside a pipeControl flow
E3292Enum variant payload arityEnums
E3293Shapeless body in the wrong placeType checking
E3294Server policy written in the wrong placeType checking
E3295Request method written twiceType checking
E3296Async return type mismatchType checking
E3297is on an Error that did not come from a catchType checking
E3298Throwing function passed where its type does not declare the effectType checking
E3299Synchronous error skips a finally that awaitsControl flow
E3300Invalid database call argumentsType checking
E3301Database schema snapshot unavailableModules
E3302Invalid SQL statementValidation
E3303Invalid database result typeType checking
E3304Invalid ORM model mappingValidation
E3305Database parameter limit exceededValidation
E3306SQL query is not supported by the configured backendModules
E3307Relation include is not supported by the configured backendModules
E3308Protected export outside its folderModules
E3309protect combined with a default exportParse
E3310protect applied to a re-exportParse
E3311Unsupported archive extensionValidation
E3312Invalid compression levelValidation