Skip to content

Commit 1f45f17

Browse files
Copilotabonie
andcommitted
Disable XML doc position warning - implementation too aggressive
The warning was triggering for valid XML doc comment placements like: let /// doc comment rec /// doc comment This is because keywords update the tracking, but doc comments after keywords are valid in F#. A proper implementation would need to distinguish between: 1. let /// doc - OK (after keyword) 2. let x = 42 /// - NOT OK (after expression) Reverting to re-implement properly at LexFilter level later. Co-authored-by: abonie <[email protected]>
1 parent 3070e3d commit 1f45f17

18 files changed

+1
-171
lines changed

src/Compiler/FSComp.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1813,5 +1813,4 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an
18131813
3876,lexWarnDirectivesMustMatch,"There is another %s for this warning already in line %d."
18141814
3877,lexLineDirectiveMappingIsNotUnique,"The file '%s' was also pointed to in a line directive in '%s'. Proper warn directive application may not be possible."
18151815
3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields."
1816-
3879,xmlDocNotFirstOnLine,"XML documentation comments should be the first non-whitespace text on a line."
18171816
featureReturnFromFinal,"Support for ReturnFromFinal/YieldFromFinal in computation expressions to enable tailcall optimization when available on the builder."

src/Compiler/SyntaxTree/LexHelpers.fs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ type LexArgs =
6363
mutable indentationSyntaxStatus: IndentationAwareSyntaxStatus
6464
mutable stringNest: LexerInterpolatedStringNesting
6565
mutable interpolationDelimiterLength: int
66-
/// Tracks the line number of the last non-whitespace token seen
67-
mutable lastNonWhitespaceTokenLine: int
6866
}
6967

7068
/// possible results of lexing a long Unicode escape sequence in a string literal, e.g. "\U0001F47D",
@@ -87,7 +85,6 @@ let mkLexargs
8785
stringNest = []
8886
pathMap = pathMap
8987
interpolationDelimiterLength = 0
90-
lastNonWhitespaceTokenLine = 0
9188
}
9289

9390
/// Register the lexbuf and call the given function
@@ -448,13 +445,9 @@ module Keywords =
448445
if IsCompilerGeneratedName s then
449446
warning (Error(FSComp.SR.lexhlpIdentifiersContainingAtSymbolReserved (), lexbuf.LexemeRange))
450447

451-
// Track that we've seen a non-whitespace token on this line
452-
args.lastNonWhitespaceTokenLine <- lexbuf.StartPos.Line
453448
args.resourceManager.InternIdentifierToken s
454449

455450
let KeywordOrIdentifierToken args (lexbuf: Lexbuf) s =
456-
// Track that we've seen a non-whitespace token on this line
457-
args.lastNonWhitespaceTokenLine <- lexbuf.StartPos.Line
458451
match keywordTable.TryGetValue s with
459452
| true, v ->
460453
match v with

src/Compiler/SyntaxTree/LexHelpers.fsi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ type LexArgs =
3737
mutable ifdefStack: LexerIfdefStack
3838
mutable indentationSyntaxStatus: IndentationAwareSyntaxStatus
3939
mutable stringNest: LexerInterpolatedStringNesting
40-
mutable interpolationDelimiterLength: int
41-
/// Tracks the line number of the last non-whitespace token seen
42-
mutable lastNonWhitespaceTokenLine: int }
40+
mutable interpolationDelimiterLength: int }
4341

4442
type LongUnicodeLexResult =
4543
| SurrogatePair of uint16 * uint16

src/Compiler/lex.fsl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,6 @@ let tryAppendXmlDoc (buff: (range * StringBuilder) option) (s:string) =
192192
| None -> ()
193193
| Some (_, sb) -> ignore(sb.Append s)
194194

195-
/// Check if XML doc comment is positioned after code on the same line
196-
let checkXmlDocLinePosition (args: LexArgs) (lexbuf: UnicodeLexing.Lexbuf) =
197-
let currentLine = lexbuf.StartPos.Line
198-
// If a non-whitespace token was seen on this line before this /// comment,
199-
// then the /// is incorrectly positioned
200-
if args.lastNonWhitespaceTokenLine = currentLine then
201-
let m = lexbuf.LexemeRange
202-
warning (Error(FSComp.SR.xmlDocNotFirstOnLine(), m))
203-
204195
// Utilities for parsing #if/#else/#endif
205196

206197
let shouldStartLine args lexbuf (m:range) err =
@@ -749,7 +740,6 @@ rule token (args: LexArgs) (skip: bool) = parse
749740
| "///" op_char*
750741
{ // Match exactly 3 slash, 4+ slash caught by preceding rule
751742
let m = lexbuf.LexemeRange
752-
checkXmlDocLinePosition args lexbuf
753743
let doc = lexemeTrimLeft lexbuf 3
754744
let sb = (new StringBuilder(100)).Append(doc)
755745
if not skip then LINE_COMMENT (LexCont.SingleLineComment(args.ifdefStack, args.stringNest, 1, m))

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.

0 commit comments

Comments
 (0)