Skip to content

Commit 848c038

Browse files
Fix17713 - Reverting PR - 17649 - Make the interaction between #line and #nowarn directives consistent (#17724)
* fix * temp * revert * readme --------- Co-authored-by: Vlad Zarytovskii <[email protected]>
1 parent d30b976 commit 848c038

29 files changed

+22
-151
lines changed

buildtools/fsyacc/fsyaccdriver.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile
199199
writer.WriteLineInterface "module %s" s;
200200

201201
writer.WriteLine "#nowarn \"64\";; // turn off warnings that type variables used in production annotations are instantiated to concrete type";
202-
writer.WriteLine "#nowarn \"1182\" // the generated code often has unused variable 'parseState'"
203-
writer.WriteLine "#nowarn \"3261\" // the generated code would need to properly annotate nulls, e.g. changing System.Object to `obj|null`";
204202

205203
for s in generatorState.opens do
206204
writer.WriteLine "open %s" s;

docs/release-notes/.FSharp.Compiler.Service/9.0.100.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
### Fixed
22

3-
* Fix a bug in the interaction between ``#line` and `#nowarn` directives ([PR #17649](https://github.com/dotnet/fsharp/pull/17649))
43
* Fix wrong TailCall warning ([Issue #17604](https://github.com/dotnet/fsharp/issues/17604), [PR #17637](https://github.com/dotnet/fsharp/pull/17637))
54
* Compiler hangs when compiling inline recursive invocation ([Issue #17376](https://github.com/dotnet/fsharp/issues/17376), [PR #17394](https://github.com/dotnet/fsharp/pull/17394))
65
* Fix reporting IsFromComputationExpression only for CE builder type constructors and let bindings. ([PR #17375](https://github.com/dotnet/fsharp/pull/17375))

src/Compiler/AbstractIL/ilpars.fsy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
%{
44

5-
#nowarn "64" // turn off warnings that type variables used in production annotations are instantiated to concrete type
65
#nowarn "1182" // the generated code often has unused variable "parseState"
76
#nowarn "3261" // the generated code would need to properly annotate nulls, e.g. changing System.Object to `obj|null`
87

src/Compiler/Driver/CompilerDiagnostics.fs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ open FSharp.Compiler.ConstraintSolver
2424
open FSharp.Compiler.DiagnosticMessage
2525
open FSharp.Compiler.Diagnostics
2626
open FSharp.Compiler.DiagnosticsLogger
27-
open FSharp.Compiler.Features
2827
open FSharp.Compiler.Infos
2928
open FSharp.Compiler.IO
3029
open FSharp.Compiler.Lexhelp
@@ -2300,13 +2299,17 @@ type PhasedDiagnostic with
23002299
// Scoped #nowarn pragmas
23012300

23022301
/// Build an DiagnosticsLogger that delegates to another DiagnosticsLogger but filters warnings turned off by the given pragma declarations
2302+
//
2303+
// NOTE: we allow a flag to turn of strict file checking. This is because file names sometimes don't match due to use of
2304+
// #line directives, e.g. for pars.fs/pars.fsy. In this case we just test by line number - in most cases this is sufficient
2305+
// because we install a filtering error handler on a file-by-file basis for parsing and type-checking.
2306+
// However this is indicative of a more systematic problem where source-line
2307+
// sensitive operations (lexfilter and warning filtering) do not always
2308+
// interact well with #line directives.
23032309
type DiagnosticsLoggerFilteringByScopedPragmas
2304-
(langVersion: LanguageVersion, scopedPragmas, diagnosticOptions: FSharpDiagnosticOptions, diagnosticsLogger: DiagnosticsLogger) =
2310+
(checkFile, scopedPragmas, diagnosticOptions: FSharpDiagnosticOptions, diagnosticsLogger: DiagnosticsLogger) =
23052311
inherit DiagnosticsLogger("DiagnosticsLoggerFilteringByScopedPragmas")
23062312

2307-
let needCompatibilityWithEarlierInconsistentInteraction =
2308-
not (langVersion.SupportsFeature LanguageFeature.ConsistentNowarnLineDirectiveInteraction)
2309-
23102313
let mutable realErrorPresent = false
23112314

23122315
override _.DiagnosticSink(diagnostic: PhasedDiagnostic, severity) =
@@ -2320,10 +2323,12 @@ type DiagnosticsLoggerFilteringByScopedPragmas
23202323
match diagnostic.Range with
23212324
| Some m ->
23222325
scopedPragmas
2323-
|> List.exists (fun (ScopedPragma.WarningOff(pragmaRange, warningNumFromPragma)) ->
2326+
|> List.exists (fun pragma ->
2327+
let (ScopedPragma.WarningOff(pragmaRange, warningNumFromPragma)) = pragma
2328+
23242329
warningNum = warningNumFromPragma
2325-
&& (needCompatibilityWithEarlierInconsistentInteraction
2326-
|| m.FileIndex = pragmaRange.FileIndex && posGeq m.Start pragmaRange.Start))
2330+
&& (not checkFile || m.FileIndex = pragmaRange.FileIndex)
2331+
&& posGeq m.Start pragmaRange.Start)
23272332
|> not
23282333
| None -> true
23292334

@@ -2339,5 +2344,5 @@ type DiagnosticsLoggerFilteringByScopedPragmas
23392344

23402345
override _.CheckForRealErrorsIgnoringWarnings = realErrorPresent
23412346

2342-
let GetDiagnosticsLoggerFilteringByScopedPragmas (langVersion, scopedPragmas, diagnosticOptions, diagnosticsLogger) =
2343-
DiagnosticsLoggerFilteringByScopedPragmas(langVersion, scopedPragmas, diagnosticOptions, diagnosticsLogger) :> DiagnosticsLogger
2347+
let GetDiagnosticsLoggerFilteringByScopedPragmas (checkFile, scopedPragmas, diagnosticOptions, diagnosticsLogger) =
2348+
DiagnosticsLoggerFilteringByScopedPragmas(checkFile, scopedPragmas, diagnosticOptions, diagnosticsLogger) :> DiagnosticsLogger

src/Compiler/Driver/CompilerDiagnostics.fsi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ open System.Text
77
open FSharp.Compiler.CompilerConfig
88
open FSharp.Compiler.Diagnostics
99
open FSharp.Compiler.DiagnosticsLogger
10-
open FSharp.Compiler.Features
1110
open FSharp.Compiler.Syntax
1211
open FSharp.Compiler.Text
1312

@@ -85,7 +84,7 @@ type PhasedDiagnostic with
8584

8685
/// Get a diagnostics logger that filters the reporting of warnings based on scoped pragma information
8786
val GetDiagnosticsLoggerFilteringByScopedPragmas:
88-
langVersion: LanguageVersion *
87+
checkFile: bool *
8988
scopedPragmas: ScopedPragma list *
9089
diagnosticOptions: FSharpDiagnosticOptions *
9190
diagnosticsLogger: DiagnosticsLogger ->

src/Compiler/Driver/ParseAndCheckInputs.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ let ParseInput
511511
finally
512512
// OK, now commit the errors, since the ScopedPragmas will (hopefully) have been scraped
513513
let filteringDiagnosticsLogger =
514-
GetDiagnosticsLoggerFilteringByScopedPragmas(lexbuf.LanguageVersion, scopedPragmas, diagnosticOptions, diagnosticsLogger)
514+
GetDiagnosticsLoggerFilteringByScopedPragmas(false, scopedPragmas, diagnosticOptions, diagnosticsLogger)
515515

516516
delayLogger.CommitDelayedDiagnostics filteringDiagnosticsLogger
517517

@@ -1429,7 +1429,7 @@ let CheckOneInput
14291429

14301430
// Within a file, equip loggers to locally filter w.r.t. scope pragmas in each input
14311431
let DiagnosticsLoggerForInput (tcConfig: TcConfig, input: ParsedInput, oldLogger) =
1432-
GetDiagnosticsLoggerFilteringByScopedPragmas(tcConfig.langVersion, input.ScopedPragmas, tcConfig.diagnosticsOptions, oldLogger)
1432+
GetDiagnosticsLoggerFilteringByScopedPragmas(false, input.ScopedPragmas, tcConfig.diagnosticsOptions, oldLogger)
14331433

14341434
/// Typecheck a single file (or interactive entry into F# Interactive)
14351435
let CheckOneInputEntry (ctok, checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt) tcState input =

src/Compiler/Driver/fsc.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ let main2
745745
yield! pragmas
746746
]
747747

748-
GetDiagnosticsLoggerFilteringByScopedPragmas(tcConfig.langVersion, scopedPragmas, tcConfig.diagnosticsOptions, oldLogger)
748+
GetDiagnosticsLoggerFilteringByScopedPragmas(true, scopedPragmas, tcConfig.diagnosticsOptions, oldLogger)
749749

750750
SetThreadDiagnosticsLoggerNoUnwind diagnosticsLogger
751751

src/Compiler/FSComp.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,5 +1783,4 @@ featureEmptyBodiedComputationExpressions,"Support for computation expressions wi
17831783
featureAllowAccessModifiersToAutoPropertiesGettersAndSetters,"Allow access modifiers to auto properties getters and setters"
17841784
3871,tcAccessModifiersNotAllowedInSRTPConstraint,"Access modifiers cannot be applied to an SRTP constraint."
17851785
featureAllowObjectExpressionWithoutOverrides,"Allow object expressions without overrides"
1786-
3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern."
1787-
featureConsistentNowarnLineDirectiveInteraction,"The interaction between #nowarn and #line is now consistent."
1786+
3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern."

src/Compiler/Facilities/LanguageFeatures.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ type LanguageFeature =
9494
| ParsedHashDirectiveArgumentNonQuotes
9595
| EmptyBodiedComputationExpressions
9696
| AllowObjectExpressionWithoutOverrides
97-
| ConsistentNowarnLineDirectiveInteraction
9897

9998
/// LanguageVersion management
10099
type LanguageVersion(versionText) =
@@ -213,7 +212,6 @@ type LanguageVersion(versionText) =
213212
LanguageFeature.LowerSimpleMappingsInComprehensionsToFastLoops, languageVersion90
214213
LanguageFeature.ParsedHashDirectiveArgumentNonQuotes, languageVersion90
215214
LanguageFeature.EmptyBodiedComputationExpressions, languageVersion90
216-
LanguageFeature.ConsistentNowarnLineDirectiveInteraction, languageVersion90
217215

218216
// F# preview
219217
LanguageFeature.EnforceAttributeTargets, previewVersion // waiting for fix of https://github.com/dotnet/fsharp/issues/17731
@@ -377,7 +375,6 @@ type LanguageVersion(versionText) =
377375
| LanguageFeature.ParsedHashDirectiveArgumentNonQuotes -> FSComp.SR.featureParsedHashDirectiveArgumentNonString ()
378376
| LanguageFeature.EmptyBodiedComputationExpressions -> FSComp.SR.featureEmptyBodiedComputationExpressions ()
379377
| LanguageFeature.AllowObjectExpressionWithoutOverrides -> FSComp.SR.featureAllowObjectExpressionWithoutOverrides ()
380-
| LanguageFeature.ConsistentNowarnLineDirectiveInteraction -> FSComp.SR.featureConsistentNowarnLineDirectiveInteraction ()
381378

382379
/// Get a version string associated with the given feature.
383380
static member GetFeatureVersionString feature =

src/Compiler/Facilities/LanguageFeatures.fsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ type LanguageFeature =
8585
| ParsedHashDirectiveArgumentNonQuotes
8686
| EmptyBodiedComputationExpressions
8787
| AllowObjectExpressionWithoutOverrides
88-
| ConsistentNowarnLineDirectiveInteraction
8988

9089
/// LanguageVersion management
9190
type LanguageVersion =

src/Compiler/Service/IncrementalBuild.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ type BoundModel private (
259259

260260
IncrementalBuilderEventTesting.MRU.Add(IncrementalBuilderEventTesting.IBETypechecked fileName)
261261
let capturingDiagnosticsLogger = CapturingDiagnosticsLogger("TypeCheck")
262-
let diagnosticsLogger = GetDiagnosticsLoggerFilteringByScopedPragmas(tcConfig.langVersion, input.ScopedPragmas, tcConfig.diagnosticsOptions, capturingDiagnosticsLogger)
262+
let diagnosticsLogger = GetDiagnosticsLoggerFilteringByScopedPragmas(false, input.ScopedPragmas, tcConfig.diagnosticsOptions, capturingDiagnosticsLogger)
263263
use _ = new CompilationGlobalsScope(diagnosticsLogger, BuildPhase.TypeCheck)
264264

265265
beforeFileChecked.Trigger fileName

src/Compiler/Service/TransparentCompiler.fs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,12 +1303,7 @@ type internal TransparentCompiler
13031303
let diagnosticsLogger = errHandler.DiagnosticsLogger
13041304

13051305
let diagnosticsLogger =
1306-
GetDiagnosticsLoggerFilteringByScopedPragmas(
1307-
tcConfig.langVersion,
1308-
input.ScopedPragmas,
1309-
tcConfig.diagnosticsOptions,
1310-
diagnosticsLogger
1311-
)
1306+
GetDiagnosticsLoggerFilteringByScopedPragmas(false, input.ScopedPragmas, tcConfig.diagnosticsOptions, diagnosticsLogger)
13121307

13131308
use _ = new CompilationGlobalsScope(diagnosticsLogger, BuildPhase.TypeCheck)
13141309

src/Compiler/pars.fsy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
%{
44

5-
#nowarn "64" // turn off warnings that type variables used in production annotations are instantiated to concrete type
65
#nowarn "1182" // generated code has lots of unused "parseState"
76
#nowarn "3261" // the generated code would need to properly annotate nulls, e.g. changing System.Object to `obj|null`
87

src/Compiler/pppars.fsy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
%{
44
open FSharp.Compiler.DiagnosticsLogger
55

6-
#nowarn "64" // turn off warnings that type variables used in production annotations are instantiated to concrete type
76
#nowarn "3261" // the generated code would need to properly annotate nulls, e.g. changing System.Object to `obj|null`
87

98
let dummy = IfdefId("DUMMY")

src/Compiler/xlf/FSComp.txt.cs.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.de.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.es.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.fr.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.it.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ja.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ko.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.pl.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.pt-BR.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.ru.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.tr.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)