You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 7482 Reporter:@mlasson Assigned to:@alainfrisch Status: resolved (set by @alainfrisch on 2017-02-20T09:38:42Z) Resolution: duplicate Priority: normal Severity: minor Target version: 4.06.0 +dev/beta1/beta2/rc1 Category: typing Duplicate of:#6013 Monitored by:@diml
Bug description
When compiling
let f = ()
let () =
let f = () in (* unused *)
()
one gets a "Warning: unused variable f", which is fine.
But if you craft this piece of code in a ppx extension that does
not locate its identifiers (or that locate them at the same place),
the warning will not be triggered.
This is because these checks are implemented using hash tables with
the "located name" used as a key, so the two occurrences of "f" are
seen as used (because the first one is).
( Note that this was "discovered" while investigating this issue LexiFi/landmarks#9 )
Steps to reproduce
You can try by compiling :
let str = [%str
let f = ()
let () =
let f = () in
()
]
let () =
let open Ast_mapper in
register "landmarks"
(fun _ ->
{ default_mapper with
structure = (fun _ _ -> str)})
with ocamlfind ocamlopt -package ppx_tools.metaquot -package compiler-libs.common -linkpkg -o ppx_bug ppx_bug.ml (it requires ocamlfind and ppx_tools).
And then use the ppx to compile any file (eg. "test.ml"): ocamlc -ppx ./ppx_bug -dsource test.ml.
It will output:
let f = ()
let () = let f = () in ()
And not trigger any warning.
The text was updated successfully, but these errors were encountered:
I have a feeling that we'll have to live with this issue. @Frisch: as the original author of this unused variable analysis, would you please handle this PR?
Original bug ID: 7482
Reporter: @mlasson
Assigned to: @alainfrisch
Status: resolved (set by @alainfrisch on 2017-02-20T09:38:42Z)
Resolution: duplicate
Priority: normal
Severity: minor
Target version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Duplicate of: #6013
Monitored by: @diml
Bug description
When compiling
one gets a "Warning: unused variable f", which is fine.
But if you craft this piece of code in a ppx extension that does
not locate its identifiers (or that locate them at the same place),
the warning will not be triggered.
This is because these checks are implemented using hash tables with
the "located name" used as a key, so the two occurrences of "f" are
seen as used (because the first one is).
( Note that this was "discovered" while investigating this issue LexiFi/landmarks#9 )
Steps to reproduce
You can try by compiling :
with
ocamlfind ocamlopt -package ppx_tools.metaquot -package compiler-libs.common -linkpkg -o ppx_bug ppx_bug.ml
(it requires ocamlfind and ppx_tools).And then use the ppx to compile any file (eg. "test.ml"):
ocamlc -ppx ./ppx_bug -dsource test.ml
.It will output:
let f = ()
let () = let f = () in ()
And not trigger any warning.
The text was updated successfully, but these errors were encountered: