|Anonymous | Login | Signup for a new account||2019-02-20 19:11 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0007852||OCaml||typing||public||2018-09-21 18:46||2019-01-14 07:45|
|Target Version||Fixed in Version|
|Summary||0007852: Spurious unused value warning with destructive substitution|
|Description||This regression was introduced by https://github.com/ocaml/ocaml/pull/1737 [^]|
I'll try to fix it without having to revert the GPR.
But if I fail, we can always revert it, it's not that important.
|Steps To Reproduce||$ cat test.mli|
module M : sig
val foo : t -> int
val bar : t -> int
module N : sig
val foo : t -> outer
val bar : t -> outer
end with type outer := int
$ ./ocamlc.opt -w +32 -c ./test.mli
File "./test.mli", line 10, characters 2-22:
Warning 32: unused value foo.
File "./test.mli", line 11, characters 2-22:
Warning 32: unused value bar.
$ $HOME/.opam/4.07.0/bin/ocamlc -w +32 -c ./test.mli
|Tags||No tags attached.|
|Btw, this would also happen when destructively substituting a module.|
This was reverted in https://github.com/ocaml/ocaml/pull/2092 [^]
FTR, what was happening is basically this:
Usage of items in OCaml is tracked by their name (i.e. the string, not the ident) and a Location.
When first typing the "sig .. end" part of "sig .. end with ..." (that is done in Typemod), we enter the names and locations of foo and bar in some table in Env.
When we process the constraint (the "with ..." part) (also done in Typemod), we assign a new location to these items.
Once we're done with the typing (we're now in Compile_common.typecheck_intf), we call "ignore (Includemod.signatures info.env sg sg)". Which has the effect of marking every item in the signature as used (which makes sense for mlis).
The issue is that we're doing that by going over the signature, taking the name + location of every item, and then using that to look in the table in Env. But the location we have is the new one, not the initial one which was used to add the items to the table. So we never mark the items that were initially added.
And so we get the spurious warnings.
|Thanks for the summary, I get it now. (Another motivation to have a proper "declaration path" notion instead of source locations.)|
|2018-09-21 18:46||trefis||New Issue|
|2018-09-21 18:46||trefis||Status||new => assigned|
|2018-09-21 18:46||trefis||Assigned To||=> trefis|
|2018-09-21 18:47||trefis||Note Added: 0019378|
|2019-01-10 16:25||trefis||Note Added: 0019545|
|2019-01-14 07:45||gasche||Note Added: 0019547|
|Copyright © 2000 - 2011 MantisBT Group|