From 2a0202a37a0c0e6969bb50522f98e07dea15e800 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 26 Jan 2015 15:48:24 +0100 Subject: [PATCH] Show warning when Record is accessed without type but RequiredQualifiedAccess was set - relates to #95 --- src/fsharp/nameres.fs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fsharp/nameres.fs b/src/fsharp/nameres.fs index 8aee0c5dc9d..9d0a07674aa 100644 --- a/src/fsharp/nameres.fs +++ b/src/fsharp/nameres.fs @@ -2144,6 +2144,10 @@ let rec ResolveFieldInModuleOrNamespace (ncenv:NameResolver) nenv ad (resInfo:Re let modulScopedFieldNames = match TryFindTypeWithRecdField modref id with | Some tycon when IsEntityAccessible ncenv.amap m ad (modref.MkNestedTyconRef tycon) -> + let showDeprecated = HasFSharpAttribute ncenv.g ncenv.g.attrib_RequireQualifiedAccessAttribute tycon.Attribs + if showDeprecated then + let message = sprintf "The record type for the record case '%s' was defined with the RequireQualifiedAccessAttribute. Include the name of the record type ('%s') in the name you are using.'" (id.ToString()) tycon.DisplayName + warning(Deprecated(message,m)) success(modref.MkNestedRecdFieldRef tycon id, rest) | _ -> error // search for type-qualified names, e.g. { Microsoft.FSharp.Core.Ref.contents = 1 }