Teyru

Teyru diagnostics at a glance

The stable code format TY-<stage>-<four digits> of every diagnostic, and the representative messages for each stage.

Every diagnostic has a stable code, with the format TY-<stage>-<four digits>. Stage prefixes:

PrefixStageRepresentative
TY-SYNLexing and parsingSemicolons, parentheses, line breaks, literals
TY-TYPSemantic analysis (names, types, members)Symbol not found, type mismatch, overloading
TY-PROPNative property rulesAccessor conflicts, storage requirements
TY-INTCompiler internals / prelude libraryCorrupt prelude, unsupported nodes
TY-IOFile accessSource file cannot be read

The output format is file:line:column: error[code]: message, for example:

hello.teyru:4:11: error[TY-TYP-0051]: incompatible types: String cannot be converted to int

TY-SYN-0001, 0002, 00040011 are produced by the lexer (TY-SYN-0003 is the exception: it is emitted by the parser at the end of a statement and at a throw line break), and everything from TY-SYN-0100 onwards is produced by the parser too.


TY-SYN: lexing and parsing

CodeMessageExplanation and fix
TY-SYN-0001';' is not Teyru syntax; end statements with a newlineTeyru has no semicolons. Delete the semicolon and let the statement end with a newline; in a for header, separate the parts with a colon instead.
TY-SYN-0002unexpected character %qA character that belongs to no token appeared (usually a full-width punctuation mark or a pasted control character).
TY-SYN-0003expected end of line, found %sthrow expression must start on the same lineThere are leftover tokens after the statement; or the throw expression is cut off by a line break. Write the expression on the same line, or start it with ( so that it spans lines. A yield that needs a value does not get this message: after a line break it is treated as an identifier, and you get cannot find symbol yield.
TY-SYN-0004unterminated block commentA /* with no matching */.
TY-SYN-0005invalid unicode escape\uXXXX is not four hexadecimal digits.
TY-SYN-0006unterminated string literalunterminated text blockThe string is not closed before the line break, or the text block is missing its closing """.
TY-SYN-0007text block must start with a line break after """A line break must follow """ immediately.
TY-SYN-0008unterminated character literalcharacter literal does not fit in a charThe character literal is not terminated, or it exceeds U+FFFF.
TY-SYN-0009malformed integer literalmalformed floating-point literalMalformed number (for example no digits after 0x, or 1e with no exponent).
TY-SYN-0010integer literal out of rangeThe integer literal exceeds the number of bits that can be represented: decimal int is limited to 2^31-1 and long to 2^63-1, non-decimal int to 0xFFFFFFFF and long to 0xFFFFFFFFFFFFFFFF (boundary values wrap round to negative). For a larger value, add the L suffix.
TY-SYN-0011invalid escape sequence \%cThe string or character literal contains an escape sequence Teyru does not recognise (for example \q). The valid ones are \n \t \r \b \f \s \0 \\ \' \", octal \nnn and \uXXXX.
TY-SYN-0100expected '%s', found %sA token that was expected is missing (), ], {, }, : and so on).
TY-SYN-0101expected identifier, found %sSomething else sits where an identifier is required; common when a keyword is used as a name.
TY-SYN-0102unexpected %s at top levelThe top level of a file allows only package/import/type declarations, or members written directly (the implicit class form).
TY-SYN-0103unexpected %s in class bodyThe class member declaration is incomplete.
TY-SYN-0104expected ',' ':' or '}' after enum constantsThe enum constant section and the member section must be separated by a single :.
TY-SYN-0105expected 'get' or 'set' accessor, found %sOnly get and set may appear in an accessor block.
TY-SYN-0106unexpected %sA statement that cannot be parsed appears in the block.
TY-SYN-0107try resources must be separated by line breaksSeparate each try-with-resources resource with a line break, not a semicolon.
TY-SYN-0108try requires catch or finallyA try needs at least one catch or finally.
TY-SYN-0109expected 'case' or 'default', found %sOnly case/default may appear in a switch block.
TY-SYN-0110cannot mix '->' and ':' case labelsA single switch may use only one form of label.
TY-SYN-0111expected expression, found %sAnother token sits where an expression is required.
TY-SYN-0112array dimension expression after empty dimension[5] cannot be written after new int[3][].
TY-SYN-0113array creation with both dimensions and initializernew int[3]{1,2,3} is not legal; give either a size or initial values.

TY-TYP: types and symbols

Declarations and members (0001–0025)

CodeMessageExplanation and fix
TY-TYP-0001duplicate type %s (also declared at %s)duplicate nested type %sA type with the same name is declared twice.
TY-TYP-0002type variable %s cannot have type argumentsA type variable cannot itself carry type arguments.
TY-TYP-0003cannot find type %sThe type name cannot be found; check the spelling, the import or the prelude.
TY-TYP-0004type %s expects %d type arguments, found %dThe number of generic arguments does not match.
TY-TYP-0005primitive type %s cannot be a type argument; use its box typeGenerics cannot use a primitive type; use the wrapper class.
TY-TYP-0006class cannot extend interface %sA class uses implements for an interface.
TY-TYP-0007cannot extend final class %sA class marked final cannot be extended. When final is applied by @Value/@UtilityClass, this is reported only after annotation expansion (the “block inheritance” check used to run before expansion, so those two annotations had no effect).
TY-TYP-0008cyclic inheritance involving %sThe inheritance relationship forms a cycle.
TY-TYP-0009%s is not an interfaceOnly an interface may follow implements.
TY-TYP-0010duplicate field %s in %sA field is declared twice in the same class.
TY-TYP-0011duplicate method %s in %sduplicate constructor %sA method or constructor with the same signature after parameter erasure is declared twice.
TY-TYP-0012varargs parameter must be last... may only go on the last parameter.
TY-TYP-0013interface method with a body must be default, static or privateAn interface method with a body must be marked default/static/private.
TY-TYP-0014method %s needs a bodyA non-abstract method needs a body.
TY-TYP-0015abstract or native method %s cannot have a bodyAn abstract/native method cannot have a body.
TY-TYP-0016abstract method %s in non-abstract class %sA class with abstract methods must be marked abstract.
TY-TYP-0017(removed)A native method can now be declared in any class and implemented in C supplied through --native.
TY-TYP-0018'%s' is only allowed for local variables; fields need an explicit typevar/val cannot be used for a field, a parameter or a return type.
TY-TYP-0019%s must implement %s from %sA concrete class does not implement an abstract method of an interface or superclass.
TY-TYP-0020missing return statementA method with a return value has paths that lack a return.
TY-TYP-0021duplicate local variable %sA local variable is declared twice in the same scope.
TY-TYP-0022break outside of loop or switchbreak may only appear inside a loop or switch (the labelled form is the exception).
TY-TYP-0023continue outside of loopcontinue may only appear inside a loop.
TY-TYP-0024thrown value must be a Throwable, found %sThe object thrown by throw must extend Throwable.
TY-TYP-0025cannot synchronize on voidThe lock of a synchronized cannot be a void expression.

Statements (0026–0044)

CodeMessageExplanation and fix
TY-TYP-0026local variables cannot be declared final; use 'val'Use val for a local variable that cannot be rebound.
TY-TYP-0027'%s' requires an initializervar/val must have an initial value.
TY-TYP-0028'%s' cannot infer a type from nullA type cannot be inferred from null; write the type out explicitly.
TY-TYP-0029'%s' cannot infer a functional interface type; declare it explicitlyA lambda needs a target type; declare the interface type explicitly.
TY-TYP-0030for-each requires an array or Iterable, found %sThe enhanced for only works on an array or an Iterable.
TY-TYP-0031incompatible types: %s is not assignable to %sThe loop variable type does not match the element type.
TY-TYP-0032return value required for %sA method with a return value cannot return empty-handed.
TY-TYP-0033cannot return a value from a void methodA void method cannot return a value.
TY-TYP-0034catch type must be a Throwable, found %sThe catch type must be from the Throwable family.
TY-TYP-0035switch selector must be a char, byte, short, int, Character, Byte, Short, Integer, String or enum type, found %sThe selector type of the switch is not legal.
TY-TYP-0036duplicate default labelA single switch may have only one default.
TY-TYP-0037incompatible pattern type %s for switch on %scase <type> <name> is unrelated to the selector type.
TY-TYP-0038case label must be a constant expressionA case label must be a compile-time constant.
TY-TYP-0039duplicate case labelA label is duplicated within the same switch.
TY-TYP-0040array required, found %s[] is used on something that is not an array.
TY-TYP-0041inconvertible types: %s cannot be cast to %sThis cast can never succeed.
TY-TYP-0042incompatible pattern type %s for %sThe type of the instanceof pattern is unrelated to the left-hand side.
TY-TYP-0043not an enclosing class: %sThe enclosing class of Outer.this does not exist.
TY-TYP-0044no superclasssuper is used although there is no superclass.

Names and access (0045–0048)

CodeMessageExplanation and fix
TY-TYP-0045cannot access instance field %s from a static contextAn instance field cannot be read directly inside a static method.
TY-TYP-0046%s has private access in %sA private member can only be accessed inside its own class. For a property, what counts is the modifier of the accessor (the underlying storage is always private, so the modifiers of the storage field cannot be used to decide); x.p = v looks at the setter, while p.x and p.x += 1 look at the getter. Access is mutual within the same nest (the same top-level class).
TY-TYP-0048cannot find symbol %sThe name cannot be found: check the spelling, the scope, the import, or whether you forgot to declare it.

Conversions and operators (0049–0067)

CodeMessageExplanation and fix
TY-TYP-0049null is not assignable to %snull cannot be given to a primitive type.
TY-TYP-0050possible lossy conversion from %s to %sA narrowing conversion is needed; add a cast.
TY-TYP-0051incompatible types: %s cannot be converted to %sThe most common type error: the types of an assignment, an argument or a return are incompatible.
TY-TYP-0052operator '!' cannot be applied to %s! only works on boolean.
TY-TYP-0053operator '~' requires an integral operand~ only works on integers.
TY-TYP-0054operator '%s' requires a numeric operandUnary +/- only works on numeric values.
TY-TYP-0055operator '%s' requires a numeric operand++/-- only works on numeric values.
TY-TYP-0056cannot apply '%s' to a non-assignable expressionThe target of ++/-- must be assignable.
TY-TYP-0057cannot assign a value to final variable %sA val or final variable cannot be assigned again.
TY-TYP-0058cannot assign a value to final field %sA final field of another class cannot be assigned.
TY-TYP-0059incompatible operand types %s and %sThe two sides of ==/!= cannot be compared.
TY-TYP-0060incomparable types: %s and %sTwo reference types can never be equal.
TY-TYP-0061operator '%s' cannot be applied to %s and %sOrdering comparisons only work on numeric values.
TY-TYP-0062operator '%s' requires integral or boolean operandsThe operand type of &/|/^ is not legal.
TY-TYP-0063operator '%s' requires integral operandsThe shift operators only work on integers.
TY-TYP-0064operator '%s' cannot be applied to %s and %sThe operand of an arithmetic operator is not numeric (a common case: an object that was not unboxed).
TY-TYP-0065left-hand side of an assignment must be a variableThe left-hand side of an assignment cannot be an arbitrary expression.
TY-TYP-0066operator '%s' cannot be applied to booleanboolean cannot be added, subtracted, multiplied or divided.
TY-TYP-0067array dimension must be non-negativeThe array size is a negative constant.

Construction and instantiation (0068–0075)

CodeMessageExplanation and fix
TY-TYP-0068cannot instantiate %sThis type cannot be used with new.
TY-TYP-0069%s is abstract; cannot be instantiatedAn abstract class cannot be newed directly.
TY-TYP-0070cannot extend final class %scannot subclass enum %sAn anonymous class cannot extend a final class or an enum.
TY-TYP-0071an enclosing instance of %s is requiredAn inner class has to be created where an enclosing instance exists.
TY-TYP-0072no suitable constructor found for %s(%s)No matching constructor; check the number and the types of the arguments.
TY-TYP-0073array clone takes no argumentsclone() takes no arguments.
TY-TYP-0074this(...) and super(...) may only be called from a constructorthis(...)/super(...) may only be written inside a constructor (it can be one of the “statements before super()” that JEP 513 allows, see docs/language.md §4.2).
TY-TYP-0075recursive constructor invocationThe constructor calls itself recursively.

Method resolution, lambda and pattern (0076–0094)

CodeMessageExplanation and fix
TY-TYP-0076cannot find method %s(%s)cannot find method %s for this functional interfaceThe method cannot be found: check the name, the parameter types, the visibility or the receiver type.
TY-TYP-0077non-static method %s cannot be referenced from a type nameOnly static methods can be called through a class name.
TY-TYP-0078cannot invoke %s on %sCalling a method on this type is not legal.
TY-TYP-0079%s has %s access in %sThe method is not visible enough.
TY-TYP-0080cannot find symbol %s in %son arrayThe member does not exist on that type.
TY-TYP-0081cannot infer the functional interface for this lambda; declare the target typecannot infer the functional interface for this method referenceThe lambda/method reference has no target type; specify one explicitly.
TY-TYP-0082lambda target type must be a functional interface, found %smethod reference target type must be a functional interfaceThe target type is not an interface.
TY-TYP-0083%s is not a functional interfaceThe interface has several abstract methods and cannot be a lambda target.
TY-TYP-0084lambda has %d parameters but %s requires %dThe number of lambda parameters does not match.
TY-TYP-0085cannot construct %sThe target of the constructor reference cannot be constructed.
TY-TYP-0086cannot resolve static import %sNo matching member can be found for the static import.
TY-TYP-0087record pattern requires a record type, found %sThe left-hand side of the destructuring pattern is not a record type (the Point in case Point(int x, int y) must be a record).
TY-TYP-0088record pattern for %s needs %d components, found %dThe number of bindings in the destructuring does not match the number of record components; a nested destructuring has to match up item by item as well.
TY-TYP-0089'case null' requires a reference selectorcase null only works on a switch selector of reference type; for a primitive type use default instead.
TY-TYP-0090%s does not name a super interfaceThe Interface in Interface.super.method() does not exist or is not an interface.
TY-TYP-0091%s is not a super interface of %sA qualified super can only point at an interface the class itself implements (directly or indirectly).
TY-TYP-0092a primitive pattern needs a name to bind the value toA primitive pattern must bind a variable: o instanceof int i, not just o instanceof int.
TY-TYP-0093boolean cannot be converted to %sboolean can only be matched by a boolean pattern.
TY-TYP-0094primitive pattern %s needs a boxed value, found %sThe selector is neither a reference type nor a primitive numeric value.
TY-IO-0101An error in the module file itself (teyru.mod cannot be parsed, wrong version syntax…)The message comes from internal/mod and names the file and the reason.
TY-IO-0102cannot read package %s: %vThe imported package is not found in the module cache, or its source files cannot be read. Run teyru mod tidy or teyru get first.
TY-IO-0103Hash mismatch for teyru.sumThe module contents in the cache differ from what teyru.sum records. Either the dependency was changed or the cache was touched; the build stops instead of using it.
TY-IO-0104%s declares package %s, but %s in the same directory declares %sTwo files in the same directory declare different packages.
TY-TYP-0095cannot infer the type arguments of %s(%s)The type arguments of the generic method cannot be inferred: there is no argument that carries a type and no target type to use (lambda parameters are the most common case). Write the type arguments, or pass an argument that has a type.
TY-TYP-0096switch expression does not cover all possible input valuesA switch expression must be exhaustive: an int/String selector must have a default, and an enum selector must cover every constant. A switch statement is not subject to this.
TY-TYP-0097native methods %s and %s both need the C symbol %sTwo overloaded native methods encode to the same C symbol (for example the class name AI and int[]). Rename one or change a parameter type.
TY-TYP-0098non-static %s cannot be referenced from a static contextThe lambda body uses the this of the place where it is written (including unqualified instance method calls, bare field names and super), but the lambda is written in a static method or a static initialiser block, so there is no instance to capture. Java rejects it as well.
TY-TYP-0108(removed)The JSON binding reads the class at run time; there is no step that generates one.
TY-TYP-0109(removed)As above: two fields of one @SerializedName name are only visible when they are read.
TY-TYP-0112(removed)A class read from JSON is built at run time, so a constructor that cannot be called shows up at newInstance.
TY-TYP-0111(removed)A controller's answer is written as JSON by the binding whatever type it is.
TY-TYP-0110(removed)Whether a field's type binds is something the reading finds out.
TY-TYP-0114not a statement: %s has no effectAn expression statement without a side effect (JLS 14.8). This language ends an expression at the line break, so long x = a followed by a newline and + b are two statements, the second a silent unary plus — x comes up one term short with no message at all. It is reported now.
TY-TYP-0113resource type %s is not a subtype of AutoCloseableThe resource type of try-with-resources must be a subtype of AutoCloseable. The implicit close() is one interface call, so a class that merely “happens to have a close() method” compiles into an itable call on an object that has no such entry, and blows up at run time.
TY-TYP-0115cannot resolve import %sThe import path points at nothing. In Teyru a name is looked up by its simple name, and whatever package is written in front makes no difference, so a misspelt package such as import java.utli.List used to be ignored silently and you still got List. Now an import has to point at: a package the standard library answers for (the teyru package itself, plus java.util, com.google.gson, lombok… for compatibility, see docs/language.md §11), a package declared by some file in this build, or a type whose fully qualified name is exactly this path.
TY-TYP-0100(removed)Two beans of one name are refused by the container at refresh().
TY-TYP-0101%s is declared by the framework and cannot be redefined__TeyruFramework is the generated class the container's registry lives in; its name is reserved.
TY-TYP-0102@Bean method %s must not be static / @Bean method %s must return the bean's type / @Bean method %s does not return a class typeA @Bean method must not be static and must return a class type (a primitive is boxed).
TY-TYP-0103(removed)A missing bean is an exception at refresh() now, which is when Spring finds out too.
TY-TYP-0104(removed)Two candidates are an exception at refresh(), with both names in the message.
TY-TYP-0105(removed)Which constructor to call is decided at run time: the @Autowired one, the only one, or the one that takes nothing.
TY-TYP-0106(removed)A @PostConstruct signature is checked when it is called.
TY-TYP-0107(removed)A dependency loop is an exception at refresh(), with the cycle in the message.
TY-TYP-0099reference to %s is ambiguous: it is declared in both %s and %sTwo import p.* both provide the same simple name (JLS 6.5.5.1). Write the fully qualified name or disambiguate with a single-type import (import a.Widget).

TY-PROP: native property

CodeMessageExplanation and fix
TY-PROP-0001a property declaration must declare exactly one nameA property can declare only one name.
TY-PROP-0002duplicate get accessorduplicate set accessorget/set may each appear only once.
TY-PROP-0003computed property %s cannot use storage modifiersA property without storage cannot use final/volatile/transient.
TY-PROP-0004final property %s cannot declare a setterA final property cannot have a setter.
TY-PROP-0005property %s has no getterA property with only a setter cannot be read; inside the accessor, use field.
TY-PROP-0007property %s has no setterA property with only a getter cannot be assigned.
TY-PROP-0008property %s needs a getter for compound assignmentp.x += 1 needs a getter and a setter.

TY-INT and TY-IO

CodeMessageExplanation
TY-INT-0001prelude is missing class %sThe prelude is corrupt or the class was overridden; this is an internal compiler error.
TY-INT-0002unsupported expression %TSemantic analysis met a node it does not handle; this is an internal compiler error (please report it).
TY-INT-0004@Singular goes on a builder field, not on the classOn a class it means nothing.
TY-INT-0005@Singular needs a List or Map field, found %s@Singular only works on a collection field.
TY-INT-0006@CustomLog needs %s in a %s file in the source file's directory or above it@CustomLog cannot pass TYPE: …@CustomLog: cannot resolve the factory class %q named by %s@CustomLog relies on lombok.log.custom.declaration in lombok.config to know how to build the logger (see docs/lombok.md for how it is read): a missing key, a pattern that uses TYPE, or a pattern naming a class that cannot be found are all reported here. You can also switch to @Log or declare the field yourself.
TY-IO-0001cannot read %s: %vThe source file cannot be read; check the path and the permissions.

Runtime errors

A run-time failure is not a diagnostic code but a member of the Throwable family:

ExceptionWhen it is thrown
NullPointerExceptionUnboxing null, or reading/writing a field, calling a method (String methods, clone(), interface methods and virtual calls all count), reading/writing an array element or taking length
ArrayIndexOutOfBoundsExceptionAn array index outside [0, length) (both reads and writes; a null array throws NullPointerException first)
IndexOutOfBoundsExceptionThe index of ArrayList.get/set/remove outside [0, size)
NoSuchElementExceptionIterator.next() called again although there are no elements left
ArithmeticExceptionInteger division by zero or remainder by zero
ClassCastExceptionA cast that fails, through cast or instanceof
NegativeArraySizeExceptionA negative array length
AssertionErrorA failed assert
IllegalArgumentExceptionenum.valueOf cannot find the constant, and so on

An exception that is not caught prints Exception in thread "main" … and exits with status 1. Reaching an abstract method that has no implementation prints teyru: no implementation for … and exits with status 70.

On this page