This PR refines and clarifies the `meta` phase distinction in the module system. * `meta import A` without `public` now has the clarified meaning of "enable compile-time evaluation of declarations in or above `A` in the current module, but not downstream". This is now checked statically by enforcing that public meta defs, which therefore may be referenced from outside, can only use public meta imports, and that global evaluating attributes such as `@[term_parser]` can only be applied to public meta defs. * `meta def`s may no longer reference non-meta defs even when in the same module. This clarifies the meta distinction as well as improves locality of (new) error messages. * parser references in `syntax` are now also properly tracked as meta references. * A `meta import` of an `import` now properly loads only the `.ir` of the nested module for the purposes of execution instead of also making its declarations available for general elaboration. * `initialize` is now no longer being run on import under the module system, which is now covered by `meta initialize`.
111 lines
1.6 KiB
Text
111 lines
1.6 KiB
Text
import Lean
|
||
/-!
|
||
# Tests for the `#where` command
|
||
-/
|
||
|
||
-- Restore the options to a pristine state
|
||
set_option internal.cmdlineSnapshots false
|
||
set_option experimental.module false
|
||
set_option Elab.inServer false
|
||
|
||
/-- info: -- In root namespace with initial scope -/
|
||
#guard_msgs in #where
|
||
|
||
noncomputable section
|
||
/-- info: noncomputable section -/
|
||
#guard_msgs in #where
|
||
end
|
||
|
||
namespace WhereTest
|
||
variable (x : Nat) (α : Type)
|
||
/--
|
||
info: namespace WhereTest
|
||
|
||
variable (x : Nat) (α : Type)
|
||
-/
|
||
#guard_msgs in #where
|
||
|
||
universe u v
|
||
universe w
|
||
|
||
/--
|
||
info: namespace WhereTest
|
||
|
||
universe u v w
|
||
|
||
variable (x : Nat) (α : Type)
|
||
-/
|
||
#guard_msgs in #where
|
||
|
||
set_option pp.piBinderTypes false
|
||
|
||
/--
|
||
info: namespace WhereTest
|
||
|
||
universe u v w
|
||
|
||
variable (x : Nat) (α : Type)
|
||
|
||
set_option pp.piBinderTypes false
|
||
-/
|
||
#guard_msgs in #where
|
||
|
||
include x
|
||
|
||
/--
|
||
info: namespace WhereTest
|
||
|
||
universe u v w
|
||
|
||
variable (x : Nat) (α : Type)
|
||
|
||
include x
|
||
|
||
set_option pp.piBinderTypes false
|
||
-/
|
||
#guard_msgs in #where
|
||
|
||
end WhereTest
|
||
|
||
section
|
||
open Lean Meta
|
||
|
||
/--
|
||
info: open Lean Lean.Meta
|
||
-/
|
||
#guard_msgs in #where
|
||
|
||
open Elab hiding TermElabM
|
||
|
||
/--
|
||
info: open Lean Lean.Meta
|
||
open Lean.Elab hiding TermElabM
|
||
-/
|
||
#guard_msgs in #where
|
||
|
||
open Command Std
|
||
open Array renaming map -> listMap
|
||
|
||
/--
|
||
info: open Lean Lean.Meta
|
||
open Lean.Elab hiding TermElabM
|
||
open Lean.Elab.Command Std
|
||
open Array renaming map → listMap
|
||
-/
|
||
#guard_msgs in #where
|
||
end
|
||
|
||
|
||
/-!
|
||
Stripping comments on `variable` binders
|
||
-/
|
||
section
|
||
variable (a : Nat)
|
||
-- Some discussion
|
||
(b : Nat)
|
||
-- Some more discussion
|
||
|
||
/-- info: variable (a : Nat) (b : Nat) -/
|
||
#guard_msgs in #where
|
||
|
||
end
|