This PR modifies macros, which implement non-atomic definitions and ```$cmd1 in $cmd2``` syntax. These macros involve implicit scopes, introduced through ```section``` and ```namespace``` commands. Since sections or namespaces are designed to delimit local attributes, this has led to unintuitive behaviour when applying local attributes to definitions appearing in the above-mentioned contexts. This has been causing the following examples to fail: ```lean4 axiom A : Prop namespace ex1 open Nat in @[local simp] axiom a : A ↔ True example : A := by simp end ex1 namespace ex2 @[local simp] axiom Foo.a : A ↔ True example : A := by simp end ex2 ``` This PR adds an internal-only piece of syntax, ```InternalSyntax.end_local_scope```, that influences the ```ScopedEnvExtension.addLocalEntry``` used in implementing local attributes, to avoid delimiting local entries in the current scope. This command is used in the above-mentioned macros. Closes [#9445](https://github.com/leanprover/lean4/issues/9445). --------- Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
53 lines
849 B
Text
53 lines
849 B
Text
axiom A : Prop
|
|
|
|
namespace ex0
|
|
@[local simp] axiom a : A ↔ True
|
|
example : A := by simp
|
|
end ex0
|
|
|
|
namespace ex1
|
|
set_option linter.unusedVariables false in
|
|
@[local simp] axiom a : A ↔ True
|
|
example : A := by simp
|
|
end ex1
|
|
|
|
namespace ex2
|
|
open Nat in
|
|
@[local simp] axiom a : A ↔ True
|
|
example : A := by simp
|
|
end ex2
|
|
|
|
namespace ex3
|
|
@[local simp] axiom Foo.a : A ↔ True
|
|
example : A := by simp
|
|
end ex3
|
|
|
|
namespace ex4
|
|
axiom test.a : A ↔ True
|
|
set_option pp.mvars true in
|
|
attribute [local simp] test.a
|
|
example : A := by simp
|
|
end ex4
|
|
|
|
namespace ex5
|
|
section
|
|
@[local simp] axiom Foo.a : A ↔ True
|
|
end
|
|
/--
|
|
error: `simp` made no progress
|
|
-/
|
|
#guard_msgs in
|
|
example : A := by simp
|
|
end ex5
|
|
|
|
namespace ex6
|
|
namespace Foo
|
|
axiom a : A ↔ True
|
|
attribute [local simp] a
|
|
end Foo
|
|
/--
|
|
error: `simp` made no progress
|
|
-/
|
|
#guard_msgs in
|
|
example : A := by simp
|
|
end ex6
|