Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions VisualFSharp.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
26 changes: 14 additions & 12 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #Regression #Conformance #TypesAndModules #Records
// Verify error when trying to clone a non-record type
//<Expects id="FS1129" status="error" span="(7,39)">The type 'int \[\]' does not contain a field 'B'$</Expects>
//<Expects id="FS0001" status="error" span="(7,17)">This expression was expected to have type</Expects>

type RecType = { A : int; B : string }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #Regression #Conformance #DeclarationElements #MemberDefinitions #MethodsAndProperties
// Verify property setters must have type unit
//<Expects id="FS1129" status="error" span="(10,67)">The type 'unit' does not contain a field 'immutStr'</Expects>
//<Expects id="FS0001" status="error" span="(10,66)">This expression was expected to have type</Expects>

type immut =
{
Expand Down
9 changes: 9 additions & 0 deletions tests/fsharpqa/Source/Warnings/InvalidRecord.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// #Warnings
//<Expects status="Error" span="(7,13)" id="FS0001">This expression was expected to have type</Expects>

type Record = {field1:int; field2:int}
let doSomething (xs) = List.map (fun {field1=x} -> x) xs

doSomething {Record.field1=0; field2=0}

exit 0
1 change: 1 addition & 0 deletions tests/fsharpqa/Source/Warnings/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down