-
Notifications
You must be signed in to change notification settings - Fork 26
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
Bad error message for null
annotation
#256
Comments
The message is now: |
I have a fix that should prevent this from happening all together! Will create PR tomorrow. |
What do you mean prevent it? Do you mean to make type inference stronger? |
Slightly stronger, but first and foremost it will catch the error during typechecking instead of crashing the backend. |
Great! |
I wanted to close the PR #262, but closed this instead. Reopening. |
I thought you were at dinner? Sophia
|
No, I'm staying home with Kim :) See you tomorrow! |
The famous Kim. Please greet her from me
———•••——— On 21 Oct 2015, at 19:46, Stephan Brandauer <[email protected]mailto:[email protected]> wrote: No, I'm staying home with Kim :) See you tomorrow! — |
The program from OP doesn't compile using master. Any particular reason why |
@albertnetymk: I agree that we could translate it to When (if) we get a common super type for all classes, we could "infer" that type for free occurrences |
Could you give me an example on what kind of bugs you are referring to here? I doubt there’s any.
I see failing-compiling of the below program as incompetent inference algorithm. There’s no hard reasons to disallow this, isn’t it?
|
The kind of bugs we would see are things like
Well, we don't really do any non-local type inference, so I would say the algorithm is non-existing rather than incompetent (still, we infer more types than say C or Java).
Feel free to implement it if you have the time! François Pottier's PhD thesis could be a good place to start reading :) |
What would be the Encore code for below?
Wouldn’t this be caught by clang immediately? Currently, since most type annotations are required, only local inference is needed, I believe. Getting back to my original question: there’s no hard reasons why both programs (the one from OP, and the one I posted) should not compile, right? |
I'm not saying we do have this bug currently, I'm just saying what kind of bugs we could be seeing if we allowed the null type to leak to the backend. I'd rather abort early than hope that I will understand the cause of the error given by clang if the bug should happen.
Absolutely, but we don't want to rely on the errors and warnings given by clang! In my opinion, the encore compiler has a bug whenever it produces C code that does not compile without warnings.
The "hard" reason is that we don't have an encore type to give to In the example from OP, we could give it any type since we're not reading the value, but this would be a special case in our type checking algorithm as we normally do require annotations on In your example, we would need to look at how Sure, type inference is to a large extent a solved problem, even with the presence of subtyping (see my link above), but that does not make it trivial to implement. Someone would still need to put in the hours to make it work. In my opinion, the type annotations right now are few enough to not be in the way, and if the only thing we're looking to gain is that we could save some annotations of I was serious when I said that you are free to implement it if you have the time, but I'd rather see |
yields the error message:
encorec: I don't know how to translate null type to pony.c
The text was updated successfully, but these errors were encountered: