diff --git a/VisualFSharp.sln b/VisualFSharp.sln index 002dbd63f6b..a203741dcd3 100644 --- a/VisualFSharp.sln +++ b/VisualFSharp.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler", "src\fsharp\FSharp.Compiler\FSharp.Compiler.fsproj", "{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}" EndProject @@ -126,9 +126,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProjectSection EndProject Global - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x86 = Debug|x86 diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 309f121046d..f9ecb656b11 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -956,7 +956,6 @@ lexfltSeparatorTokensOfPatternMatchMisaligned,"The '|' tokens separating rules o 1126,nrGlobalUsedOnlyAsFirstName,"'global' may only be used as the first name in a qualified path" 1127,nrIsNotConstructorOrLiteral,"This is not a constructor or literal, or a constructor is being used incorrectly" 1128,nrUnexpectedEmptyLongId,"Unexpected empty long identifier" -1129,nrTypeDoesNotContainSuchField,"The type '%s' does not contain a field '%s'" 1129,nrRecordDoesNotContainSuchLabel,"The record type '%s' does not contain a label '%s'." 1130,nrInvalidFieldLabel,"Invalid field label" 1132,nrInvalidExpression,"Invalid expression '%s'" diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 52345ff8c43..2f270d2625a 100755 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -2552,17 +2552,7 @@ let ResolveFieldPrim (ncenv:NameResolver) nenv ad typ (mp,id:Ident) allFields = let m = id.idRange match mp with | [] -> - if isAppTy g typ then - match ncenv.InfoReader.TryFindRecdOrClassFieldInfoOfType(id.idText,m,typ) with - | Some (RecdFieldInfo(_,rfref)) -> [ResolutionInfo.Empty, FieldResolution(rfref,false)] - | None -> - let typeName = NicePrint.minimalStringOfType nenv.eDisplayEnv typ - if isRecdTy g typ then - // record label doesn't belong to record type -> predict other labels of same record - error(Error(SuggestOtherLabelsOfSameRecordType nenv typeName id allFields,m)) - else - error(Error(FSComp.SR.nrTypeDoesNotContainSuchField(typeName, id.idText),m)) - else + let lookup() = let frefs = try Map.find id.idText nenv.eFieldLabels with :? KeyNotFoundException -> @@ -2573,7 +2563,19 @@ let ResolveFieldPrim (ncenv:NameResolver) nenv ad typ (mp,id:Ident) allFields = frefs |> ListSet.setify (fun fref1 fref2 -> tyconRefEq g fref1.TyconRef fref2.TyconRef) |> List.map (fun x -> ResolutionInfo.Empty, FieldResolution(x,false)) - + + if isAppTy g typ then + match ncenv.InfoReader.TryFindRecdOrClassFieldInfoOfType(id.idText,m,typ) with + | Some (RecdFieldInfo(_,rfref)) -> [ResolutionInfo.Empty, FieldResolution(rfref,false)] + | None -> + let typeName = NicePrint.minimalStringOfType nenv.eDisplayEnv typ + if isRecdTy g typ then + // record label doesn't belong to record type -> predict other labels of same record + error(Error(SuggestOtherLabelsOfSameRecordType nenv typeName id allFields,m)) + else + lookup() + else + lookup() | _ -> let lid = (mp@[id]) let tyconSearch ad = diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index b5da2a0281b..07f6ef7d7c6 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -6644,7 +6644,7 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, optOrigExpr, flds, mWholeExpr ] match flds with | [] -> [] - | _ -> + | _ -> let tcref,_,fldsList = BuildFieldMap cenv env (isSome optOrigExpr) overallTy flds mWholeExpr let _,_,_,gtyp = infoOfTyconRef mWholeExpr tcref UnifyTypes cenv env mWholeExpr overallTy gtyp diff --git a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/E_RecordCloning01.fs b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/E_RecordCloning01.fs index aa2172850b0..16e53eca0a5 100644 --- a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/E_RecordCloning01.fs +++ b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/E_RecordCloning01.fs @@ -1,6 +1,6 @@ // #Regression #Conformance #TypesAndModules #Records // Verify error when trying to clone a non-record type -//The type 'int \[\]' does not contain a field 'B'$ +//This expression was expected to have type type RecType = { A : int; B : string } diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_SettersMustHaveUnit01.fs b/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_SettersMustHaveUnit01.fs index 131df38108f..7097557c72d 100644 --- a/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_SettersMustHaveUnit01.fs +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_SettersMustHaveUnit01.fs @@ -1,6 +1,6 @@ // #Regression #Conformance #DeclarationElements #MemberDefinitions #MethodsAndProperties // Verify property setters must have type unit -//The type 'unit' does not contain a field 'immutStr' +//This expression was expected to have type type immut = { diff --git a/tests/fsharpqa/Source/Warnings/InvalidRecord.fs b/tests/fsharpqa/Source/Warnings/InvalidRecord.fs new file mode 100644 index 00000000000..f04f24e4576 --- /dev/null +++ b/tests/fsharpqa/Source/Warnings/InvalidRecord.fs @@ -0,0 +1,9 @@ +// #Warnings +//This expression was expected to have type + +type Record = {field1:int; field2:int} +let doSomething (xs) = List.map (fun {field1=x} -> x) xs + +doSomething {Record.field1=0; field2=0} + +exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst index da119ba25d2..3ed17922c22 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -2,6 +2,7 @@ SOURCE=WarnIfMissingElseBranch.fs # WarnIfMissingElseBranch.fs SOURCE=ReturnInsteadOfReturnBang.fs # ReturnInsteadOfReturnBang.fs SOURCE=YieldInsteadOfYieldBang.fs # YieldInsteadOfYieldBang.fs + SOURCE=InvalidRecord.fs # InvalidRecord.fs SOURCE=CommaInRecCtor.fs # CommaInRecCtor.fs SOURCE=ValidCommaInRecCtor.fs # ValidCommaInRecCtor.fs SOURCE=ElseBranchHasWrongType.fs # ElseBranchHasWrongType.fs