TypL icon indicating copy to clipboard operation
TypL copied to clipboard

Lookup mappings for TypeIDs

Open getify opened this issue 6 years ago • 3 comments

Define lookup mappings from typeID (like "int") to friendly type names (like "integer") for the purposes of error messages.

Similar to getTypeID(..). Like this:

getTypeName("int");  // "integer"

getTypeName({ inferred: "int" });  // "integer"

getify avatar Feb 13 '19 03:02 getify

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


mraak avatar Feb 14 '19 15:02 mraak

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.

getify avatar Feb 14 '19 16:02 getify

Yeah for 'bint' and 'nul' I agree.

mraak avatar Feb 14 '19 17:02 mraak