rescript-lang / rescript-lang/reanalyze
Re-exported variant is incorrectly marked dead
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 281
- Forks
- 22
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 7
Description
Running reanalyze https://github.com/rescript-association/reanalyze/commit/389dd682223201b42c33e5c444e5c79e0805adad on Goblint https://github.com/goblint/analyzer/commit/a544002114324a207df72f9e79eb656c3ebe7b5b revealed the following.
In MyCFG module we have the following re-exporting type definition:
(** Re-exported [Edge.t] with constructors. See [Edge.t] for documentation. *)
type edge = Edge.t =
| Assign of CilType.Lval.t * CilType.Exp.t
| Proc of CilType.Lval.t option * CilType.Exp.t * CilType.Exp.t list
| Entry of CilType.Fundec.t
| Ret of CilType.Exp.t option * CilType.Fundec.t
| Test of CilType.Exp.t * bool
| ASM of string list * Edge.asm_out * Edge.asm_in
| VDecl of CilType.Varinfo.t
| Skip
and in Edge module we have the original type definition:
type t =
| Assign of CilType.Lval.t * CilType.Exp.t
(** Assignments lval = exp *)
| Proc of CilType.Lval.t option * CilType.Exp.t * CilType.Exp.t list
(** Function calls of the form lva = fexp (e1, e2, ...) *)
| Entry of CilType.Fundec.t
(** Entry edge that relates function declaration to function body. You can use
* this to initialize the local variables. *)
| Ret of CilType.Exp.t option * CilType.Fundec.t
(** Return edge is between the return statement, which may optionally contain
* a return value, and the function. The result of the call is then
* transferred to the function node! *)
| Test of CilType.Exp.t * bool
(** The true-branch or false-branch of a conditional exp *)
| ASM of string list * asm_out * asm_in
(** Inline assembly statements, and the annotations for output and input
* variables. *)
| VDecl of CilType.Varinfo.t
(** VDecl edge for the variable in varinfo. Whether such an edge is there for all
* local variables or only when it is not possible to pull the declaration up, is
* determined by alwaysGenerateVarDecl in cabs2cil.ml in CIL. One case in which a VDecl
* is always there is for VLA. If there is a VDecl edge, it is where the declaration originally
* appeared *)
| Skip [@dead "t.Skip"]
(** This is here for historical reasons. I never use Skip edges! *)
Despite the last documentation comment, we use MyCFG.Skip in various places and it's not marked dead. But the corresponding Edge.Skip variant is marked dead.
This is incorrect, because due to the type re-exporting, it wouldn't be possible to remove Edge.Skip as the two type manifests must match for the code to compile. I suppose reanalyze isn't accounting for this fact.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how reanalyze handles the re-exported MyCFG.edge and original Edge.t definitions, focusing on the dead-variant marking for Edge.Skip. Compare that analysis with the shown MyCFG.Skip uses and the OCaml type-manifest requirement. Done means the re-exported variant is not reported as dead when its re-export is used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100