Skip to content
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

[Merged by Bors] - fix(slim_check): do not crash when binders contain a function type #11231

Closed
wants to merge 2 commits into from

Conversation

eric-wieser
Copy link
Member

Previously

import Mathlib

open scoped BigOperators in
example (n : ℕ) : ∑ f : Unit → Fin (n + 1), f () = 0 := by slim_check

failed with

application type mismatch
  SlimCheck.NamedBinder "a._@._hyg.23" (Unit → Fin (n + 1))
argument
  Unit → Fin (n + 1)
has type
  Type : Type 1
but is expected to have type
  Prop : Type

Open in Gitpod

@eric-wieser eric-wieser added bug Something isn't working t-meta Tactics, attributes or user commands labels Mar 7, 2024
@eric-wieser eric-wieser added the awaiting-review The author would like community review of the PR label Mar 7, 2024
Copy link
Collaborator

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm the new code is (more) correct (than before).

maintainer merge

Comment on lines +512 to +513
if not (← Meta.inferType expr).isProp then
return .done expr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the meaning clearer this way (although I know you weren't the one introducing this spelling).

Suggested change
if not (← Meta.inferType expr).isProp then
return .done expr
unless (← Meta.inferType expr).isProp
return .done expr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does unless support else? I think in an else/if chain, using unless makes things a little weirder to read.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it does, but I claim that's a feature. The unless clause indicates a condition on which you want to immediately abort, which is not what an else/if chain indicates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to use "this if isn't really part of this patch" to avoid having to do anything in this CL. If you feel strongly that unless is underused, perhaps open a follow-up with 10 or so replacements across mathlib and see what people think.

bors merge

Copy link

🚀 Pull request has been placed on the maintainer queue by YaelDillies.

Copy link

🚀 Pull request has been placed on the maintainer queue by YaelDillies.

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors d+

@mathlib-bors
Copy link

mathlib-bors bot commented Mar 23, 2024

✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added delegated and removed awaiting-review The author would like community review of the PR labels Mar 23, 2024
mathlib-bors bot pushed a commit that referenced this pull request Mar 23, 2024
…11231)

Previously
```lean
import Mathlib

open scoped BigOperators in
example (n : ℕ) : ∑ f : Unit → Fin (n + 1), f () = 0 := by slim_check
```
failed with
```
application type mismatch
  SlimCheck.NamedBinder "a._@._hyg.23" (Unit → Fin (n + 1))
argument
  Unit → Fin (n + 1)
has type
  Type : Type 1
but is expected to have type
  Prop : Type
```
@mathlib-bors
Copy link

mathlib-bors bot commented Mar 23, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title fix(slim_check): do not crash when binders contain a function type [Merged by Bors] - fix(slim_check): do not crash when binders contain a function type Mar 23, 2024
@mathlib-bors mathlib-bors bot closed this Mar 23, 2024
@mathlib-bors mathlib-bors bot deleted the eric-wieser/slim_check-bug branch March 23, 2024 11:16
utensil pushed a commit that referenced this pull request Mar 26, 2024
…11231)

Previously
```lean
import Mathlib

open scoped BigOperators in
example (n : ℕ) : ∑ f : Unit → Fin (n + 1), f () = 0 := by slim_check
```
failed with
```
application type mismatch
  SlimCheck.NamedBinder "a._@._hyg.23" (Unit → Fin (n + 1))
argument
  Unit → Fin (n + 1)
has type
  Type : Type 1
but is expected to have type
  Prop : Type
```
Louddy pushed a commit that referenced this pull request Apr 15, 2024
…11231)

Previously
```lean
import Mathlib

open scoped BigOperators in
example (n : ℕ) : ∑ f : Unit → Fin (n + 1), f () = 0 := by slim_check
```
failed with
```
application type mismatch
  SlimCheck.NamedBinder "a._@._hyg.23" (Unit → Fin (n + 1))
argument
  Unit → Fin (n + 1)
has type
  Type : Type 1
but is expected to have type
  Prop : Type
```
atarnoam pushed a commit that referenced this pull request Apr 16, 2024
…11231)

Previously
```lean
import Mathlib

open scoped BigOperators in
example (n : ℕ) : ∑ f : Unit → Fin (n + 1), f () = 0 := by slim_check
```
failed with
```
application type mismatch
  SlimCheck.NamedBinder "a._@._hyg.23" (Unit → Fin (n + 1))
argument
  Unit → Fin (n + 1)
has type
  Type : Type 1
but is expected to have type
  Prop : Type
```
uniwuni pushed a commit that referenced this pull request Apr 19, 2024
…11231)

Previously
```lean
import Mathlib

open scoped BigOperators in
example (n : ℕ) : ∑ f : Unit → Fin (n + 1), f () = 0 := by slim_check
```
failed with
```
application type mismatch
  SlimCheck.NamedBinder "a._@._hyg.23" (Unit → Fin (n + 1))
argument
  Unit → Fin (n + 1)
has type
  Type : Type 1
but is expected to have type
  Prop : Type
```
callesonne pushed a commit that referenced this pull request Apr 22, 2024
…11231)

Previously
```lean
import Mathlib

open scoped BigOperators in
example (n : ℕ) : ∑ f : Unit → Fin (n + 1), f () = 0 := by slim_check
```
failed with
```
application type mismatch
  SlimCheck.NamedBinder "a._@._hyg.23" (Unit → Fin (n + 1))
argument
  Unit → Fin (n + 1)
has type
  Type : Type 1
but is expected to have type
  Prop : Type
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working delegated maintainer-merge t-meta Tactics, attributes or user commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants