Skip to content

Commit

Permalink
fix: use two tokens for open private/export private (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-christiansen authored Nov 15, 2024
1 parent 9dcf294 commit 01f4969
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Batteries/Tactic/OpenPrivate.lean
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ name component.
It is also possible to specify the module instead with
`open private a b c from Other.Module`.
-/
syntax (name := openPrivate) "open private" (ppSpace ident)*
syntax (name := openPrivate) "open" ppSpace "private" (ppSpace ident)*
(" in" (ppSpace ident)*)? (" from" (ppSpace ident)*)? : command

/-- Elaborator for `open private`. -/
Expand All @@ -119,7 +119,7 @@ It will also open the newly created alias definition under the provided short na
It is also possible to specify the module instead with
`export private a b c from Other.Module`.
-/
syntax (name := exportPrivate) "export private" (ppSpace ident)*
syntax (name := exportPrivate) "export" ppSpace "private" (ppSpace ident)*
(" in" (ppSpace ident)*)? (" from" (ppSpace ident)*)? : command

/-- Elaborator for `export private`. -/
Expand Down
4 changes: 4 additions & 0 deletions BatteriesTest/OpenPrivateDefs.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/-!
This file contains a private declaration. It's tested in `openPrivate.lean`.
-/
private def secretNumber : Nat := 2
37 changes: 37 additions & 0 deletions BatteriesTest/openPrivate.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

import Batteries.Tactic.OpenPrivate

import BatteriesTest.OpenPrivateDefs



/-- error: unknown identifier 'secretNumber' -/
#guard_msgs in
#eval secretNumber


-- It works with one space between the tokens
/-- info: 2 -/
#guard_msgs in
open private secretNumber from BatteriesTest.OpenPrivateDefs in
#eval secretNumber


-- It also works with other kinds of whitespace between the tokens

/-- info: 2 -/
#guard_msgs in
open private secretNumber from BatteriesTest.OpenPrivateDefs in
#eval secretNumber


/-- info: 2 -/
#guard_msgs in
open
private secretNumber from BatteriesTest.OpenPrivateDefs in
#eval secretNumber

/-- info: 2 -/
#guard_msgs in
open /- Being sneaky! -/ private secretNumber from BatteriesTest.OpenPrivateDefs in
#eval secretNumber

0 comments on commit 01f4969

Please sign in to comment.