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
10 changes: 7 additions & 3 deletions src/fsharp/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,14 @@ rule token args skip = parse
// Construct the new position
if args.applyLineDirectives then
lexbuf.EndPos <- pos.ApplyLineDirective((match file with Some f -> fileIndexOfFile f | None -> pos.FileIndex), line)

else
// add a newline when we don't apply a directive since we consumed a newline getting here
newline lexbuf
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line that really fixes the problem.

token args skip lexbuf
else
if not skip then (HASH_LINE (LexCont.Token !args.ifdefStack)) else token args skip lexbuf }
else
// add a newline when we don't apply a directive since we consumed a newline getting here
newline lexbuf
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually unsure about putting this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm this is needed as well.

I tested by turning "skip" off.

(HASH_LINE (LexCont.Token !args.ifdefStack)) }

| "<@" { checkExprOp lexbuf; LQUOTE ("<@ @>", false) }
| "<@@" { checkExprOp lexbuf; LQUOTE ("<@@ @@>", true) }
Expand Down
2 changes: 1 addition & 1 deletion tests/service/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5291,7 +5291,7 @@ let ``Test line directives in foreground analysis`` () = // see https://github.c
for e in checkResults1.Errors do
printfn "ProjectLineDirectives checkResults1 error file: <<<%s>>>" e.FileName

[ for e in checkResults1.Errors -> e.StartLineAlternate, e.EndLineAlternate, e.FileName ] |> shouldEqual [(4, 4, ProjectLineDirectives.fileName1)]
[ for e in checkResults1.Errors -> e.StartLineAlternate, e.EndLineAlternate, e.FileName ] |> shouldEqual [(5, 5, ProjectLineDirectives.fileName1)]

//------------------------------------------------------

Expand Down