Zulip Chat Archive
Stream: mathlib4
Topic: Unused variable linter bug (?)
Pim Otte (Aug 31 2024 at 08:49):
The following gives an unused variable on G
(and removing it gives errors for obvious reasons). My meta-programming skills are still a little lacking to de-mathlibify this mwe, but maybe someone else can? I have checked it on live.lean-lang.org with v4.11.0-rc3
import Mathlib.Combinatorics.SimpleGraph.Path
def oddVerts (G : SimpleGraph V) := {(c : SimpleGraph.ConnectedComponent G) | Nonempty c}
Johan Commelin (Sep 03 2024 at 04:53):
@Kyle Miller do you know what is going on?
Kyle Miller (Sep 03 2024 at 15:32):
I've seen this issue before -- in the macro expansion, you have match (c : SimpleGraph.ConnectedComponent G) with ...
, and for some reason type ascriptions in match
statement discriminants don't appear to elaborate correctly, or at least terminfo is missing (try hovering over the type in the type ascription; you don't get any hover information!)
A fix is to avoid using this particular notation and instead use the basic set separation notation:
def oddVerts (G : SimpleGraph V) := {c : SimpleGraph.ConnectedComponent G | Nonempty c}
We should probably extend basic set separation notation to accept parentheses here, since the parenthesis notation gives a surprising expansion anyway.
Mario Carneiro (Sep 04 2024 at 22:58):
I don't think it's match statement discriminants, but rather type ascriptions in match patterns
Mario Carneiro (Sep 04 2024 at 23:00):
example (F : Nat → Prop) (x : Nat) (y : F x) : Nat :=
match (y : F x) with
-- ^ this has hover info
| (_y : F x) => 1
-- ^ this doesn't
Mario Carneiro (Sep 04 2024 at 23:01):
the same issue appears in anything that desugars to match
statements, including pattern matching in let
and have
Mario Carneiro (Sep 04 2024 at 23:02):
this is lean4#3955
Last updated: May 02 2025 at 03:31 UTC