-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check that funind-reserved names are available (#4135)
I did not introduce `inductTheoremSuffix` etc, it seems more direct to just spell out the suffix here. If we ever change it there are many occurrences where they need to be changed anyways, so the definition doesn't seem to save much work or add that much robustness.
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
|
||
-- Test that the reserved name availability is checked at function definition time | ||
|
||
namespace Nonrec | ||
|
||
def foo.induct := 1 | ||
|
||
def foo : (n : Nat) → Nat -- no error (yet) | ||
| 0 => 0 | ||
| n+1 => n | ||
|
||
end Nonrec | ||
|
||
namespace Structural | ||
|
||
def foo.induct := 1 | ||
|
||
def foo : (n : Nat) → Nat -- error | ||
| 0 => 0 | ||
| n+1 => foo n | ||
|
||
end Structural | ||
|
||
namespace WF | ||
|
||
def foo.induct := 1 | ||
|
||
def foo : (n : Nat) → Nat -- error | ||
| 0 => 0 | ||
| n+1 => foo n | ||
termination_by n => n | ||
|
||
end WF | ||
|
||
namespace Mutual1 | ||
|
||
def foo.induct := 1 | ||
|
||
mutual | ||
def foo : (n : Nat) → Nat -- error | ||
| 0 => 0 | ||
| n+1 => bar n | ||
termination_by n => n | ||
|
||
def bar : (n : Nat) → Nat -- error | ||
| 0 => 0 | ||
| n+1 => foo n | ||
termination_by n => n | ||
end | ||
|
||
end Mutual1 | ||
|
||
namespace Mutual2 | ||
|
||
def bar.induct := 1 | ||
|
||
mutual | ||
def foo : (n : Nat) → Nat -- error | ||
| 0 => 0 | ||
| n+1 => bar n | ||
termination_by n => n | ||
|
||
def bar : (n : Nat) → Nat | ||
| 0 => 0 | ||
| n+1 => foo n | ||
termination_by n => n | ||
end | ||
|
||
end Mutual2 | ||
|
||
namespace Mutual3 | ||
|
||
def foo.mutual_induct := 1 | ||
|
||
mutual | ||
def foo : (n : Nat) → Nat -- error | ||
| 0 => 0 | ||
| n+1 => bar n | ||
termination_by n => n | ||
|
||
def bar : (n : Nat) → Nat | ||
| 0 => 0 | ||
| n+1 => foo n | ||
termination_by n => n | ||
end | ||
|
||
end Mutual3 | ||
|
||
namespace Nested | ||
|
||
def foo : (n : Nat) → Nat -- error | ||
| 0 => 0 | ||
| n+1 => foo n | ||
where induct := 1 | ||
|
||
end Nested |
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,6 @@ | ||
funind_reserved.lean:18:4-18:7: error: failed to declare `Structural.foo` because `Structural.foo.induct` has already been declared | ||
funind_reserved.lean:28:4-28:7: error: failed to declare `WF.foo` because `WF.foo.induct` has already been declared | ||
funind_reserved.lean:40:4-40:7: error: failed to declare `Mutual1.foo` because `Mutual1.foo.induct` has already been declared | ||
funind_reserved.lean:63:4-63:7: error: failed to declare `Mutual2.bar` because `Mutual2.bar.induct` has already been declared | ||
funind_reserved.lean:76:4-76:7: error: failed to declare `Mutual3.foo` because `Mutual3.foo.mutual_induct` has already been declared | ||
funind_reserved.lean:91:4-91:7: error: failed to declare `Nested.foo` because `Nested.foo.induct` has already been declared |