Tc env signature merge repro #9
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
Let's start off with a bold statement: I don't think you can type check a signature file in parallel.
Allow me to elaborate:
Inside
CheckOneInputAux'we call theCheckOneSigFilefunction to type check the signature AST.Inside this function, a bunch of stuff is being added to the
TcEnv(tcState.tcsTcSigEnvto be specific).The callback function of
CheckOneInputAux'will update thisTcEnv:Notice that
tcsTcSigEnv = tcEnvwill completely overwrite theTcEnvfor the current signature file. This is problematic when you have signature files that don't depend on each other. What one file added to theTcEnvcan get overridden by another.Consider my sample project:
Bdepends onAandChas no relations and soAandCwill be type-checked in parallel.That callback of
Awill update thetcState.tcsTcSigEnvwith thetcEnvresult of type checkingA.fsi. The callback ofCwill do the same thing accordingly.When
D.fsiis being processed, the callbacks will be invoked correctly.But as
C.fsioverrides the informationA.fsi,B.fsiadded,A.fsiwill no longer be known in theTcEnv. This will be problematic whenD.fsiis type checked.The
tcState, however, will have the correctrootSigsadded. So looking merely at the state, at a glance you would think that everything happened correctly.This problem does not occur in the current type check impl/sig pairs in parallel.
Because the signature files are still processed in order, leading to correct
TcEnvand later theChoice2Of2implementation files are processed in parallel.So, now what? Short term I think it is worth trying to type-check the signature file as part of the callback. This is not ideal, but the only other option would be to merge the
TcEnvof signature files. Which are a bunch of nested collections and I'm not sure how easy that will be.To see all this with your own eyes, you would need to run the
ParallelTypeCheckingTestsproject in "graph" mode using the args file of the sample. (Yup, hard coded absolute paths in that args.txt file).Put a breakpoint in:
Comparing

tcsTcSigEnvwithtcEnv:In the
NameEnv.eModulesAndNamespacesyou can spot that one will haveAand the other will haveB.I've added some code to really crash the application when a problem occurs.