Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close coq#18637 To be decided: - should we warn for variable names starting with `_`? (current code does) - should we split the warning like ocaml does (unused `let x := ...` treated differently from unused `x` next to used `y` in `match ... with (x,y) => ...` or unused `x` in `fun x => ...`) Future work: more precise locations, currently it's on the whole expression ie all of `let x := ... in ...`, just `x` would be nicer.
- Loading branch information
1 parent
8fc5b01
commit 9dbb7a9
Showing
14 changed files
with
152 additions
and
19 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
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,4 @@ | ||
- **Added:** | ||
warning on unused Ltac2 variables | ||
(`#18641 <https://github.com/coq/coq/pull/18641>`_, | ||
by Gaëtan Gilbert). |
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
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
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
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,28 @@ | ||
File "./output/ltac2_unused_var.v", line 3, characters 6-18: | ||
Warning: Unused variable: x. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 5, characters 16-27: | ||
Warning: Unused variable: y. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 5, characters 6-27: | ||
Warning: Unused variable: x. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 8, characters 6-19: | ||
Warning: Unused variable: _x. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 10, characters 0-38: | ||
Warning: Unused variable: x. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 16, characters 17-23: | ||
Warning: Unused variable: x. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 18, characters 16-40: | ||
Warning: Unused variable: y. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 20, characters 16-56: | ||
Warning: Unused variable: x. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 22, characters 16-43: | ||
Warning: Unused variable: b. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 24, characters 15-32: | ||
Warning: Unused variable: x. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 26, characters 23-26: | ||
Warning: Unused variables: x y. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 28, characters 23-26: | ||
Warning: Unused variable: y. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 30, characters 18-55: | ||
Warning: Unused variable: y. [ltac2-unused-variable,ltac2,default] | ||
File "./output/ltac2_unused_var.v", line 42, characters 37-39: | ||
Warning: Unused variable: x. [ltac2-unused-variable,ltac2,default] |
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,46 @@ | ||
Require Import Ltac2.Ltac2. | ||
|
||
Ltac2 foo1 x := (). | ||
|
||
Ltac2 foo2 x := fun y => (). | ||
|
||
(* we also warn on _ prefixed variable unlike ocaml *) | ||
Ltac2 foo3 _x := (). | ||
|
||
Ltac2 Notation "foo4" x(constr) := (). | ||
|
||
(* questionable behaviour: unused variable in untyped notation warns at notation use time *) | ||
Unset Ltac2 Typed Notations. | ||
Ltac2 Notation "foo5" x(constr) := (). | ||
Set Ltac2 Typed Notations. | ||
Ltac2 foo6 () := foo5 1. | ||
|
||
Ltac2 foo7 x := match x with y => () end. | ||
|
||
Ltac2 foo8 x := match x with Some x => 1 | None => 2 end. | ||
|
||
Ltac2 foo9 x := match x with (a,b) => a end. | ||
|
||
Ltac2 foo10 := let x := () in (). | ||
|
||
Ltac2 foo11 () := let (x,y) := (1,2) in (). | ||
|
||
Ltac2 foo12 () := let (x,y) := (1,2) in x. | ||
|
||
Ltac2 foo13 () := let rec x () := 1 with y () := 2 in x. | ||
|
||
Ltac2 foo14 () := let rec x () := y () with y () := 2 in x. | ||
|
||
(* missing warning for unused letrec (bug?) *) | ||
Ltac2 foo15 () := let rec x () := y () with y () := x () in (). | ||
|
||
Ltac2 mutable bar () := (). | ||
|
||
(* missing warning for unused "Set as" (bug?) *) | ||
Ltac2 Set bar as bar0 := fun () => (). | ||
|
||
Ltac2 foo16 () := ltac1:(ltac2:(x |- ())). | ||
|
||
(* no warning for y even though it's bound in the ltac2 context | ||
(ltac2 can't tell that the notation isn't eg "ltac2:(...) + y") *) | ||
Notation foo17 x y := ltac2:(exact $preterm:x) (only parsing). |
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
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