A wrong type is reported in a type mismatch error
Consider this code:
let a, b: int = ()
The error is produced on the unit expression, but it says that the type is int:
Error FS0001 : This expression was expected to have type
''a * 'b'
but here has type
'int'
This may be happening due to some expressions rewriting during the analysis.
Right, if I remember correctly, the compiler basically uses the type annotation on a binding to wrap the expression being bound in a SynExpr.Typed.
AST
expr =
SynExpr.Typed(
expr = SynExpr.Const(constant = SynConst.Unit, range = R("(1,16--1,18)")),
targetType = SynType.LongIdent(SynLongIdent.SynLongIdent(id = [ Ident("int", R("(1,10--1,13)")) ], dotRanges = [], trivia = [ None ])),
range = R("(1,16--1,18)")
),
It gives the exact same error for this:
let x, y = () : int
But the SynBindingReturnInfo is still available in the AST after that transformation, so we could use that to improve the error message here.
Is it alright if I try my hand at this?
Is it alright if I try my hand at this?
Absolutely, would be great!