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

Uninformative error message in calc mode when confusing types #6370

Open
3 tasks done
Mr-vedant-gupta opened this issue Dec 12, 2024 · 0 comments
Open
3 tasks done

Uninformative error message in calc mode when confusing types #6370

Mr-vedant-gupta opened this issue Dec 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Mr-vedant-gupta
Copy link

Mr-vedant-gupta commented Dec 12, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

When using calc mode, on accidentally using 1/2 : ℕ (which rounds to 0) instead of 1/2 : ℝ due to a forgotten type cast, I get a confusing type mismatch error message where the expected and current types are identical.

Context

https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/Calc.20mode.20complaining.20about.20non-matching.20expressions

Steps to Reproduce

import Mathlib

theorem nonsense (a b  : ℝ) :
  ((a + b) ^ 2 ) ^ (1/2 : ℝ)  = 1 :=
by
  calc
    ((a + b) ^ 2) ^ (1 / 2) = 1 := by sorry -- forgot to cast (1 / 2) to ℝ

Expected behavior: [Clear and concise description of what you expect to happen]
An error message like

invalid 'calc' step, left-hand side is
  ((a + b) ^ 2) ^ (1 / 2) : ℕ 
but is expected to be
  ((a + b) ^ 2) ^ (1 / 2) : ℝ

Actual behavior: [Clear and concise description of what actually happens]
Lean throws this error message

invalid 'calc' step, left-hand side is
  ((a + b) ^ 2) ^ (1 / 2) : ℝ
but is expected to be
  ((a + b) ^ 2) ^ (1 / 2) : ℝ
@Mr-vedant-gupta Mr-vedant-gupta added the bug Something isn't working label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant