Generate FileTarget for all possible targetLocations#3893
Conversation
fdcdb40 to
e84ff76
Compare
michaelpj
left a comment
There was a problem hiding this comment.
Not sure I entirely understand, but seems plausible!
|
Test failures seem genuine :( |
|
Patch seems fine to me. Did you check locally to see why tests are failing? |
|
Not yet, but will look into it! |
e84ff76 to
553e516
Compare
|
The existence check seems to be removing valid file targets. I.e., there are many file targets that don't exist on disk. Probably related to the VFS? I am confused why it works with Module Targets in that case, since we always filter those. |
Many files from the testsuite only exist in the VFS, and those files are always |
|
We could also ensure that explicit file targets aren't filtered out. |
553e516 to
78fe225
Compare
What are explicit file targets? |
This is incorrect. We might end up trying to typecheck non-existent hs-boot files, or files in the wrong include directory
The FilePath argument to case targetTarget of
TargetFile f -> do
found <- filterM (IO.doesFileExist . fromNormalizedFilePath) targetLocations
return [(targetTarget, nubOrd (f:found))] |
|
Ah, I see! |
|
No, but the problematic situation will only be when a file is listed as a Target but not saved to disk, i.e. the user has edited the cabal file to include the module, but has not saved the module yet. |
78fe225 to
4c05e0b
Compare
If a target file has multiple possible locations, then we assume they are all separate file targets. This happens with '.hs-boot' files if they are in the root directory of the project. GHC reports options such as '-i. A' as 'TargetFile A.hs' instead of 'TargetModule A'. In 'fromTargetId', we dutifully look for '.hs-boot' files and add them to the targetLocations of the TargetDetails. Then we add everything to the 'knownTargetsVar'. However, when we look for a 'Foo.hs-boot' file in 'FindImports.hs', we look for either * TargetFile Foo.hs-boot * TargetModule Foo If we don't generate a TargetFile for each potential location, we will only have 'TargetFile Foo.hs' in the 'knownTargetsVar', thus not find 'TargetFile Foo.hs-boot' and also not find 'TargetModule Foo'.
4c05e0b to
86fb77b
Compare
|
@wz1000 Looks good now? |
If a target file has multiple possible locations, then we
assume they are all separate file targets.
This happens with '.hs-boot' files if they are in the root directory of the project.
GHC reports options such as '-i. A' as 'TargetFile A.hs' instead of 'TargetModule A'.
In 'fromTargetId', we dutifully look for '.hs-boot' files and add them to the
targetLocations of the TargetDetails. Then we add everything to the 'knownTargetsVar'.
However, when we look for a 'Foo.hs-boot' file in 'FindImports.hs', we look for either
If we don't generate a TargetFile for each potential location, we will only have
'TargetFile Foo.hs' in the 'knownTargetsVar', thus not find 'TargetFile Foo.hs-boot'
and also not find 'TargetModule Foo'.
It took a while, but this fixes #3794