You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reduced the issue to a self-contained, reproducible test case.
Description
Allowing a namespace inside a section can cause compile issues.
Steps to Reproduce
Compile the following code:
sectionuniverses u
inductivemy_unit : Type u
| foo
namespace my_unit
defone : ℕ := 1end my_unit
lemmatest : my_unit.one = 1 := by refl
end
Expected behavior: Code compiles, in particular, my_unit.one isn't treated as field notation.
Actual behavior: Obtain error message:
invalid field notation, type is not of the form (C ...) where C is a constant
my_unit
has type
Type u
Reproduces how often: 100%
Versions
Lean (version 3.32.1, commit 35b3a9c, Release) on cygwin.
Additional Information
If you rephrase the code, you can also get another issue which I think is related:
sectionuniverses u
inductivemy_unit : Type u
| foo
defmy_unit.one (_ : my_unit) : ℕ := 1lemmatest : my_unit.one my_unit.foo = 1 := by unfold my_unit.one
end
gives:
unfold tactic failed, my_unit.one does not have equational lemmas nor is a projection
state:
⊢ my_unit.foo.one = 1
There some small adjustments I've been able to make to get either example to compile. I think the second and third qualifies as a workaround.
Don't use universe polymorphism.
sectioninductivemy_unit : Type
| foo
namespace my_unit
defone : ℕ := 1end my_unit
lemmatest : my_unit.one = 1 := by refl
end
Move the namespace out of the section.
sectionuniverses u
inductivemy_unit : Type u
| foo
endnamespace my_unit
universes u
defone : ℕ := 1-- other code which uses `u`end my_unit
sectionuniverses u
lemmatest : my_unit.one = 1 := by refl
end
Use _root_.
sectionuniverses u
inductivemy_unit : Type u
| foo
namespace my_unit
defone : ℕ := 1end my_unit
lemmatest : _root_.my_unit.one = 1 := by refl
end
Hopefully I haven't made any mistakes or missed an issue/PR, I couldn't find anything related when searching for both "namespace" and "section".
The text was updated successfully, but these errors were encountered:
Prerequisites
or feature requests.
Description
Allowing a
namespace
inside asection
can cause compile issues.Steps to Reproduce
Expected behavior: Code compiles, in particular,
my_unit.one
isn't treated as field notation.Actual behavior: Obtain error message:
Reproduces how often: 100%
Versions
Additional Information
If you rephrase the code, you can also get another issue which I think is related:
gives:
There some small adjustments I've been able to make to get either example to compile. I think the second and third qualifies as a workaround.
namespace
out of thesection
._root_
.Hopefully I haven't made any mistakes or missed an issue/PR, I couldn't find anything related when searching for both "namespace" and "section".
The text was updated successfully, but these errors were encountered: