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
When a let binding produces a type error because of its annotation, the rest of the code is type-checked with the actual inferred type of the binding instead of the (possibly narrowed) annotated type. This potentially produces misleading follow-up type errors:
pubfnmain(){letx:String=5// type error: expected String, got Intlety:Int=x// validletz:String=x// type error: expected String, got Int}
I think the assignment to y should produce the type error here, not z. I would have expected one of the major benefits of adding explicit annotations to be to help the compiler produce better errors in exactly those situations. My assumption here of course is that if the user adds an explicit annotation, they want and expect that annotation to be assumed the correct type.