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

Introduction chapter: #assertType example likely not behaving as expected in Lean 4.17 #168

Open
philnguyen opened this issue Mar 9, 2025 · 0 comments

Comments

@philnguyen
Copy link

I tried the example as below:

import Lean

elab "#assertType " termStx:term " : " typeStx:term : command =>
  open Lean Lean.Elab Command Term in
  liftTermElabM
    try
      let tp ← elabType typeStx
      discard $ elabTermEnsuringType termStx tp
      synthesizeSyntheticMVarsNoPostponing
      logInfo "success"
    catch | _ => throwError "failure"

/-- info: success -/
#assertType 5 : Nat

-- don't display names of metavariables
set_option pp.mvars false in

/--
error: type mismatch
  []
has type
  List ?_ : Type _
but is expected to have type
  Nat : Type
-/
#assertType [] : Nat

And could reproduce the following problems either in the online editor, or locally on emacs:

  • At the end of the -/ closing block comment, I get error message "unexpected token '#assertType'..."
  • If I delete the block comments, the first example #assertType 5 : Nat works as expected. But in the second example, even though I see an error below [] as expected, the entire command is still underlined blue, saying "success" when I hover over it.

I guess Lean has recently changed behaviors that made the examples outdated?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant