lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

fix: collect level parameters in evalExpr

Open eric-wieser opened this issue 6 months ago • 9 comments

elabEvalUnsafe already does something similar: it also instantiates universe metavariables, but it is not clear to me whether that is sensible here. To be conservative, I leave it out of this PR.

See https://github.com/leanprover/lean4/pull/3090#discussion_r1432007590 for a comparison between #eval and Meta.evalExpr. This PR is not trying to fully align them, but just to fix one particular misalignment that I am impacted by.

Closes #3091

eric-wieser avatar Dec 18 '23 15:12 eric-wieser

  • ❗ Mathlib CI will not be attempted unless you rebase your PR onto the 'nightly' branch. (2023-12-18 15:50:28)
  • ✅ Mathlib branch lean-pr-testing-3090 has successfully built against this PR. (2023-12-20 12:34:38) View Log
  • ✅ Mathlib branch lean-pr-testing-3090 has successfully built against this PR. (2023-12-20 13:12:04) View Log

It would be good to have a Mathlib build for this one. Could you rebase onto nightly-with-mathlib?

semorrison avatar Dec 19 '23 04:12 semorrison

I'm afraid I probably have no time today to do so, but might later this week.

My figuring is that this is very unlikely to break anything, since the change only affects code that was previously producing kernel errors; but indeed it's good practice to test it anyway.

eric-wieser avatar Dec 19 '23 09:12 eric-wieser

It would be good to have a Mathlib build for this one. Could you rebase onto nightly-with-mathlib?

I did this rebase @semorrison, but I guess CI won't run until tomorrow?

eric-wieser avatar Dec 20 '23 10:12 eric-wieser

It would be good to have a Mathlib build for this one. Could you rebase onto nightly-with-mathlib?

I did this rebase @semorrison, but I guess CI won't run until tomorrow?

The workflow is a bit racy; by the time it ran, a new nightly tag appeared (2023-12-19), but nightly-with-mathlib did not advance. I hope that #3097 will fix that. Once that hits master, I can re-trigger the workflow and then it hopefully works. Sorry for the delays.

nomeata avatar Dec 20 '23 10:12 nomeata

Seems to work (https://github.com/leanprover/lean4/actions/runs/7274620683/job/19820906002), mathlib CI should be running

nomeata avatar Dec 20 '23 11:12 nomeata

awaiting-review

eric-wieser avatar Dec 21 '23 12:12 eric-wieser

@semorrison, do you think this is ok as is? While there's some discussion above about instantiating metavariables, it's mainly about code that isn't part of this patch anyway; and the actual change is only two lines!

eric-wieser avatar Mar 09 '24 16:03 eric-wieser

Just to note this now also impacts eval% in mathlib:

import Mathlib.Tactic.Eval

def foo.{u} (x : PUnit.{u}) : Nat := 37

-- fails without this PR
def bar.{u} (x : PUnit.{u}) : Nat := eval% foo.{u} PUnit.unit

eric-wieser avatar Apr 09 '24 21:04 eric-wieser