leanprover / leanprover/lean4

Setting `-D Elab.async=false` breaks `backward.privateInPublic`

Open
#13,647 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites

(cf. #8746, but it is different and more fatal)

Description

As title said: Elab.async and backward.privateInPublic are incompatible.

Steps to Reproduce

Code:

-- main.lean
module

set_option backward.privateInPublic true

public class U : Type where
  a : Nat
  h : a = a

private theorem A : 0 = 0 := rfl

public instance : U := ⟨0, A⟩

Compile it use lean main.lean -D Elab.async=false.

Expected behavior:

main.lean:12:27: warning: Private declaration `A` accessed publicly; this is allowed only because the `backward.privateInPublic` option is enabled.

Disable `backward.privateInPublic.warn` to silence this warning.

Actual behavior:

main.lean:12:27: error(lean.unknownIdentifier): Unknown identifier `A`

Note: A private declaration `A` (from the current module) exists but would need to be public to access here.
Versions

4.30.0-rc2, macOS (reproducible in live):

https://live.lean-lang.org/#codez=LYewJgrgNgpgUHAzjALgfRABxQSxAOwAIAjAQwGMBrAd1ICcwA6TOnAN1JRgEl8AFCMSg5yhFHQjxk6LLgKEAolFLFGpRAE98ogGakoyBJkHDR5ZYkSEAqoQBchACobMMQtQAWMOvEKFS9oQAcpxwfh6BAQC8%2FkasHFxiXiA%2BwIQAgoEADIQxOXYxdDpQRiYihDj4iCik2m4OtgWEgBfkWQA0GYCX5HBAA

Additional Information

Based on the description
https://github.com/leanprover/lean4/blob/aa6fa1cf1a7c7a7161ceeda64c934176abc3595b/src/Lean/CoreM.lean#L35-L46
of this option, it shouldn't affect any correctness.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the provided main.lean example with lean main.lean -D Elab.async=false and compare it with the expected warning. Read the Elab.async option description in src/Lean/CoreM.lean at lines 35-46, then trace the elaboration behavior involved in backward.privateInPublic; done means the reproducible case no longer reports A as an unknown identifier.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.