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
Tests for the `linter.checkUnivs` linter, which warns when a declaration has a universe
5
+
parameter that only ever occurs in a `max u v` together with another parameter, never
6
+
on its own.
7
+
-/
8
+
9
+
set_option linter.checkUnivs true
10
+
11
+
universe u v
12
+
13
+
-- Good: each universe parameter occurs alone somewhere.
14
+
defgoodUnivs (α : Type u) (β : Type v) : Type (max u v) := α × β
15
+
16
+
-- Good: `u` occurs alone in `α`, so the `max u v` is fine.
17
+
defgoodUnivsDominated (α : Type u) (β : Type (max u v)) : Type (max u v) := α × β
18
+
19
+
-- Bad: neither `u` nor `v` occur alone in `badUnivs`'s type.
20
+
/--
21
+
warning: `badUnivs`: universes `u`, `v` only occur together. This usually means there is a `max` expression in the type where none of these universes appear on their own.
22
+
23
+
Note: This linter can be disabled with `set_option linter.checkUnivs false`
24
+
-/
25
+
#guard_msgs in
26
+
defbadUnivs (α : Type (max u v)) : Type (max u v) := α
27
+
28
+
-- `set_option ... false in` suppresses the warning locally.
29
+
#guard_msgs in
30
+
set_option linter.checkUnivs false in
31
+
defbadUnivsSuppressed (α : Type (max u v)) : Type (max u v) := α
32
+
33
+
-- Inductives are also checked.
34
+
/--
35
+
warning: `BadInd`: universes `u`, `v` only occur together. This usually means there is a `max` expression in the type where none of these universes appear on their own.
36
+
37
+
Note: This linter can be disabled with `set_option linter.checkUnivs false`
0 commit comments