-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1120 from ocaml/typer-caching-policy
Stricter typechecker caching policy
- Loading branch information
Showing
5 changed files
with
214 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
open Dep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
Instances of the typechecker are cached based on configuration | ||
(values of type `Mconfig.t`). | ||
|
||
Older versions of Merlin ignored some components resulting in possible | ||
mismatches between the internal configuration of the typechecker (loadpath, | ||
global modules visible from the environment) and Merlin configuration. | ||
|
||
For instance, `-package` and `-cmi-path` were ignored. | ||
|
||
The server might already be running, we kill it to make sure we start from a | ||
clean slate: | ||
|
||
$ $MERLIN server stop-server | ||
|
||
We build a dep which we will be revealed to Merlin later: | ||
|
||
$ $OCAMLC -c sub/dep.ml | ||
|
||
First try with dep hidden: | ||
|
||
$ $MERLIN server errors -filename test.ml < test.ml | ||
{ | ||
"class": "return", | ||
"value": [ | ||
{ | ||
"start": { | ||
"line": 1, | ||
"col": 5 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"col": 8 | ||
}, | ||
"type": "typer", | ||
"sub": [], | ||
"valid": true, | ||
"message": "Unbound module Dep" | ||
} | ||
], | ||
"notifications": [] | ||
} | ||
|
||
For reference, the answer in single mode: | ||
|
||
$ $MERLIN single errors -filename test.ml < test.ml | ||
{ | ||
"class": "return", | ||
"value": [ | ||
{ | ||
"start": { | ||
"line": 1, | ||
"col": 5 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"col": 8 | ||
}, | ||
"type": "typer", | ||
"sub": [], | ||
"valid": true, | ||
"message": "Unbound module Dep" | ||
} | ||
], | ||
"notifications": [] | ||
} | ||
|
||
|
||
We try again after revealing the dependency: | ||
|
||
$ $MERLIN server errors -filename test.ml -cmi-path sub < test.ml | ||
{ | ||
"class": "return", | ||
"value": [], | ||
"notifications": [] | ||
} | ||
|
||
|
||
Reference: | ||
|
||
$ $MERLIN single errors -filename test.ml -cmi-path sub < test.ml | ||
{ | ||
"class": "return", | ||
"value": [], | ||
"notifications": [] | ||
} | ||
|
||
|
||
Well behaving versions of Merlin (>= 3.3.4) of should return the same answer as | ||
reference. | ||
|
||
We should check in the other direction too. Starting from a visible dep and | ||
hidding it. Older versions of the typechecker (before the 4.08 revamp of Env) | ||
would accumulate dependencies and forget to flush the cache when a dependency | ||
disappeared. | ||
|
||
$ $MERLIN server stop-server | ||
|
||
|
||
Visible: | ||
|
||
$ $MERLIN server errors -filename test.ml -cmi-path sub < test.ml | ||
{ | ||
"class": "return", | ||
"value": [], | ||
"notifications": [] | ||
} | ||
|
||
|
||
Reference: | ||
|
||
$ $MERLIN single errors -filename test.ml -cmi-path sub < test.ml | ||
{ | ||
"class": "return", | ||
"value": [], | ||
"notifications": [] | ||
} | ||
|
||
|
||
Hidden: | ||
|
||
$ $MERLIN server errors -filename test.ml < test.ml | ||
{ | ||
"class": "return", | ||
"value": [ | ||
{ | ||
"start": { | ||
"line": 1, | ||
"col": 5 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"col": 8 | ||
}, | ||
"type": "typer", | ||
"sub": [], | ||
"valid": true, | ||
"message": "Unbound module Dep" | ||
} | ||
], | ||
"notifications": [] | ||
} | ||
|
||
|
||
Reference: | ||
|
||
$ $MERLIN single errors -filename test.ml < test.ml | ||
{ | ||
"class": "return", | ||
"value": [ | ||
{ | ||
"start": { | ||
"line": 1, | ||
"col": 5 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"col": 8 | ||
}, | ||
"type": "typer", | ||
"sub": [], | ||
"valid": true, | ||
"message": "Unbound module Dep" | ||
} | ||
], | ||
"notifications": [] | ||
} | ||
|
||
|
||
Now some cleanup. | ||
|
||
$ rm sub/dep.cm* |