Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup mappings for TypeIDs #11

Open
getify opened this issue Feb 13, 2019 · 3 comments
Open

Lookup mappings for TypeIDs #11

getify opened this issue Feb 13, 2019 · 3 comments
Assignees

Comments

@getify
Copy link
Owner

getify commented Feb 13, 2019

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"
@mraak
Copy link
Collaborator

mraak commented Feb 14, 2019

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


@getify
Copy link
Owner Author

getify commented Feb 14, 2019

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.

@mraak
Copy link
Collaborator

mraak commented Feb 14, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants