Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: warn about unused section parameters #14993

Open
cpitclaudel opened this issue Oct 6, 2021 · 4 comments
Open

Feature request: warn about unused section parameters #14993

cpitclaudel opened this issue Oct 6, 2021 · 4 comments
Labels
kind: feature New user-facing feature request or implementation. kind: wish Feature or enhancement requests.

Comments

@cpitclaudel
Copy link
Contributor

Description of the problem

The project that I currently work with (bedrock 2) has lots of typeclasses and parameters; most of my files start with something like this:

Section __.
  Context {width: Z} {BW: Bitwidth width} {word: word.word width} {mem: map.map word Byte.byte}.
  Context {locals: map.map String.string word}.
  Context {env: map.map String.string (list String.string * list String.string * Syntax.cmd)}.
  Context {ext_spec: bedrock2.Semantics.ExtSpec}.
  Context {word_ok : word.ok word} {mem_ok : map.ok mem}.
  Context {locals_ok : map.ok locals}.
  Context {env_ok : map.ok env}.
  Context {ext_spec_ok : Semantics.ext_spec.ok ext_spec}.

In practice, though, it's often the case that some of these are unnecessary — sometimes even most of them.
It would be really nice if Coq warned me about unused section variables when I closed such a section.

Test case:

Section test.
  Context {a b c: nat}.
  Definition x := a + a.
  Goal True. Proof using b. destruct (Nat.eqb b b). all: exact I. Qed.
End test.

(This should warn about c)

@cpitclaudel cpitclaudel added the kind: feature New user-facing feature request or implementation. label Oct 6, 2021
@SkySkimmer
Copy link
Contributor

Definition ignore (x:nat) := 0.
Section S.
Variable v : nat.
Definition foo := Eval lazy in ignore v.
Check v.
End S.

should this warn unused v? (foo has type nat after closing the section) (I would say yes)

Can variables matter after the section other than through a kernel object? eg

Section S.
Variable v : nat.
Ltac foo := exact v.
End S.

tactic foo won't exist after the section, so we're fine to warn about v.

@Alizter Alizter added the kind: wish Feature or enhancement requests. label Oct 6, 2021
@ppedrot
Copy link
Member

ppedrot commented Oct 8, 2021

It's a bit hard to make this work with the delayed proof mechanism. The warning would only be triggered in sequential mode...

@SkySkimmer
Copy link
Contributor

But delayed proofs need Proof using, so they shouldn't be a problem.

@ppedrot
Copy link
Member

ppedrot commented Oct 8, 2021

Ah, yes, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New user-facing feature request or implementation. kind: wish Feature or enhancement requests.
Projects
None yet
Development

No branches or pull requests

4 participants