New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unname some unused variables #1190
Conversation
src/Init/Coe.lean
Outdated
@@ -27,11 +27,11 @@ class CoeTail (α : Sort u) (β : Sort v) where | |||
class CoeHTCT (α : Sort u) (β : Sort v) where | |||
coe : α → β | |||
|
|||
class CoeDep (α : Sort u) (_ : α) (β : Sort v) where | |||
class CoeDep (α : Sort u) (a : α) (β : Sort v) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larsk21 I wonder if we should exclude class signatures by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After seeing this use case, yes, probably. But the same issue occurs with structure
and inductive
signatures as well, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #1191
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the same issue occurs with
structure
andinductive
signatures as well, doesn't it?
That's a good question. It could be argued that it is likelier for classes where parameters that are exclusively for directing typeclass resolution sounds quite reasonable, whereas "faux-typed" structures such as the single KeyedDeclsAttribute.Def
from this PR seem more edge case (and often may as well be def
s, in which case we can't exclude them anyway).
src/Lean/Elab/Structure.lean
Outdated
let _ := if e.isAppOfArity ``id 2 then e.appArg! else e | ||
return some (← reduceProjs (← instantiateMVars e.appArg!) expandedStructNames) | ||
let r := if e.isAppOfArity ``id 2 then e.appArg! else e | ||
return some (← reduceProjs (← instantiateMVars r.appArg!) expandedStructNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not, the change breaks run/diamond{3,4}.lean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. I pushed a fix for this.
let r := if e.isAppOfArity ``id 2 then e.appArg! else e
return some (← reduceProjs (← instantiateMVars r) expandedStructNames)
src/Lean/Meta/ExprDefEq.lean
Outdated
@@ -1147,7 +1147,7 @@ private def unfoldBothDefEq (fn : Name) (t s : Expr) : MetaM LBool := do | |||
|
|||
private def sameHeadSymbol (t s : Expr) : Bool := | |||
match t.getAppFn, s.getAppFn with | |||
| Expr.const c₁ _ _, Expr.const c₂ _ _ => true | |||
| Expr.const _ _ _, Expr.const _ _ _ => true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leodemoura correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. I pushed a fix for it.
|
||
theorem eq_false_of_decide {p : Prop} {s : Decidable p} (h : decide p = false) : p = False := | ||
theorem eq_false_of_decide {p : Prop} {_ : Decidable p} (h : decide p = false) : p = False := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really dislike that this disables the (s := ...)
syntax to specify implicit arguments (for no good reason). (Not that s
is a great name, inst
or something would certainly be better.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, I dislike the counter-intuitive implicit-as-inst-implicit pattern in general. Not sure what would be a good general solution here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implicit-as-inst-implicit pattern
Do you mean {_ : Decidable p}
instead of [Decidable p]
? (Not sure I understood you correctly. I would have named it the way around: inst-implicit-as-implicit pattern.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking of it the other way around - an implicit parameter that becomes an inst-implicit argument in an application
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed that the {_ :
style is prevalent in e.g. Std.Data.PersistentHashMap
, so this really is a pre-existing style issue that should be discussed at a larger scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick idea, but a "nicer" way could be to allow selecting parameters by type as in eq_false_of_decide (‹Decidable p› := ...)
. One slight downside would be a larger parser overlap.
@gebner Thanks, I definitely didn't look at every line in detail! |
@@ -2,9 +2,9 @@ | |||
a : α | |||
as bs : List α | |||
h : bs = a :: as | |||
⊢ List.length (?a :: as) = List.length bs | |||
⊢ List.length (?head :: as) = List.length bs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unexpected consequence from renaming a pattern variable, but I can't say I've every done such a refold myself so far.
Co-authored-by: Gabriel Ebner <gebner@gebner.org>
The following quick script takes as stdin a Lean build log and replaces reportedly unused variables with
_
in the following two cases where formatting isn't too much of an issue:,
(if any)It looks like the linter sometimes reports the same variable multiple times, which confuses the script, so I filtered the input through
sort -u
first. Then I post-processed the result usingsed -i 's![_ : ![!g'
to fix instance implicits. And then I did some more manual cleanups as in the commits below.