I've now run into this multiple times on different scripts, so filing a bug with logs. I'm writing fsdocs scripts. Things go great, but then at some point type checking stops working. I can type 1+1.0 and there are no red squigglies. Though line lens, code completion, and sending to fsi still works.
But ... if I get in this state and rename the file, such as changing a not working file name file.fsx to file1.fsx or fil.fsx, voila type checking comes back.
I do not have a simple reproducible example. But I did collect detailed logs and do a file diff to identify differences. The main difference seemed to be that the file that doesn't work sent semantic tokens before it recieved the fsharp/fileParsed notificatoin. The file that worked got the fsharp/fileParsed notification before it sent semantic tokens.
Here is a gist with logs from two versions of a script, where the only difference is one character in the file name: https://gist.github.com/nhirschey/e7e7894cf15de913f85dc03df2dfcedb
...lots more messages...
...lots more messages...
Version: 1.54.0-insider (user setup)
Commit: 192c817fd350bcbf3caecae22a45ec39bae78516
Date: 2021-02-19T05:14:28.632Z
Electron: 11.2.3
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042
Hey @nhirschey :wave:,
Thank you for opening an issue. We will get back to you as
soon as we can. Also, check out our OpenCollective and consider
backing us.
https://opencollective.com/ionide
PS.: We offer
backersupport for all backers. Don't forget to addbackerlabel when you start backing us :smile:
The singularity is still a long ways off ; ) https://opencollective.com/nicholas-hirschey
bad bot!
If changing the file name makes things work again, then this sounds like some kind of typecheck-cache/file watcher issue in FSAC. We should double-check the way that script filenames are cached/computed/checked, since filenames are the primary key for our caches.
Some things to add:
(** *) comments to (* *) comments with find and replace, but that didn't fix things. But when deleting comments entirely, it's unclear if it's something about the changed file size or line length or something specific to the comments.Hey, I just ran into this again while live coding for my students. Good news is that I have new debug info for how to get intellisense back without renaming the file, and it worked on two consecutive classes where this occurred, so I think it's repeatable (if you get into the bad state that I don't know how to reproduce but that I get into regularly):
I was able to get intellisense typechecking to come back if I
After that, intellisense properly caught errors.
I continue to hit this all the time (scripts not being type-checked), but I now have a reproducible example that might help debug.
Caveat: my general problem is that I will be working on a script and type-checking randomly stops (for example above logs from the original issue). But I cannot reproduce a random error; this is only a reproduction of a script that isn't type checked, but I hope this is a special case of the general bug.
mkdir no-type-check
cd no-type-check
code .
code test.fsx
let x =
[
"A"
"A"
0
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
"a"
""
]

I think same issue as this and #1518 -- but not just in Script files, but normal F# code files in F# project too.
While trying to figuring out what's happening, I found these reproduction steps:
(In short: no compiler errors & warnings for F# tabs that were front tabs at time of VS Code start)
Problems view (in bottom panel)mkdir tmp; cd tmp)dotnet new console -lang f#code .Program.fs in Tab.%s to %i in printfn.
Ctrl+Shift+p -> Developer: Reload WindowProblems view (not shown in image)
To restore error highlighting:
Program.fs is not front tab (active, selected, visible tab). For example by either:Program.fstmp.fsprojCtrl+n. File doesn't need to be saved to disk -- a fresh untitled file is enoughDeveloper: Reload Window)Program.fs Tab -> error should be visibleProgram.fs -> Program2.fs -> Program.fs)textDocument/publishDiagnostics. When error is in a front tab, no publishDiagnostics notification (or any other notification) contains the compiler errorI can reproduce @Booksbaum 's bug. It feels very similar to the script bug, though it's a bit better because if the file is open it looks like I can close code and reopen and the error shows up. However, with a script you can close code and reopen and type checking doesn't come back. Script type checking only comes back if you close the file before closing code.
To my observation, this happens
a) for new files that you add to the project
b) for the file that was open (visible) when you last closed VS Code.