You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is this needed though? Java also reports type mismatches with the same keyword as it is used in the code.
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World");
String a = "a";
int b = 1;
a = b;
float c = a - b;
}
}
$javac HelloWorld.java
HelloWorld.java:7: error: incompatible types: int cannot be converted to String
a = b;
^
HelloWorld.java:8: error: bad operand types for binary operator '-'
float c = a - b;
^
first type: String
second type: int
2 errors
Some of the type-ids are shortened (for the purposes of usability, mostly), which can make them a tad cryptic in error messages. Example: 'bint' ("bigint"). Also, "nul" looks weird in error messages, but had to be with one "l" because it's a reserved keyword.
Define lookup mappings from typeID (like "int") to friendly type names (like "integer") for the purposes of error messages.
Similar to
getTypeID(..)
. Like this:The text was updated successfully, but these errors were encountered: