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

unknown free variable: _kernel_fresh.1210 #4548

Open
nomeata opened this issue Jun 24, 2024 · 3 comments
Open

unknown free variable: _kernel_fresh.1210 #4548

nomeata opened this issue Jun 24, 2024 · 3 comments
Labels
bug Something isn't working depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it P-high We will work on this issue

Comments

@nomeata
Copy link
Contributor

nomeata commented Jun 24, 2024

Prerequisites

I stumbled upon this while working on lean, this is what I minimized it to so far:

import Lean

open Lean Meta

opaque foo : MetaM Unit

-- unknown free variable: _kernel_fresh.1210
partial def bar : MetaM Unit := do -- doesn't happen with IO here
  let nonIndices : Array Unit := #[].filter (fun i => true) -- doesn't happen without filter here
  for i in nonIndices do
    try
      foo -- needs this foo, pure () is not enough
      return
    catch e => pure () -- needs pure here, return doesnt work

Could be a duplicate of #1415 or #4418, but it is hard to tell without a full investigation, so reporting separately to avoid confusion if a fix ends up fixing one some of these instances.

Versions

4.9.0-rc2, 4.10.0-nightly-2024-06-23,
[Output of #eval Lean.versionString]
[OS version, if not using live.lean-lang.org.]

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@nomeata nomeata added the bug Something isn't working label Jun 24, 2024
@nomeata
Copy link
Contributor Author

nomeata commented Jun 24, 2024

Ah, adding some mostly unrelated lines to my function makes the error go away. So I'm at least unblocked.

@leodemoura leodemoura added the depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it label Jun 25, 2024
@leodemoura
Copy link
Member

We can confirm that is a code generator issue by using noncomputable

@leanprover-bot leanprover-bot added the P-high We will work on this issue label Aug 9, 2024
@JLimperg
Copy link
Contributor

Probably another instance of this bug, minimised from some Aesop code:

import Lean

open Lean Lean.Parser.Tactic

/-
unknown free variable: _kernel_fresh.134
-/
def foo {m} [Monad m] [MonadQuotation m] (tacs : Array (TSyntax `tactic)) (ns : Array Ident) (b : Bool) : m Syntax := do
  let usedNames : HashSet Name := tacs[1:].foldl (init := sorry) sorry
  for n in ns do
    if usedNames.contains sorry then
      continue
  if b then
    let tacs : TSyntax ``tacticSeq ← `(tacticSeq| $tacs:tactic*)
    sorry
  else
    sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it P-high We will work on this issue
Projects
None yet
Development

No branches or pull requests

4 participants