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

feat: Use private names in where and local let #2717

Closed
wants to merge 1 commit into from

Conversation

nomeata
Copy link
Contributor

@nomeata nomeata commented Oct 20, 2023

(no need to look yet, running this to see what breaks)

Motivation:

Hide local definitions from generated documentation, and prevent docstring
linters from complaining about missing docstrings in where clauses.

@github-actions github-actions bot added the WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet. label Oct 20, 2023
@nomeata
Copy link
Contributor Author

nomeata commented Oct 20, 2023

Some tests fail, for example ./tests/lean/run/inlineWithNestedRecIssue.lean:

import Lean

@[inline] private unsafe def mapMonoMImp [Monad m] (as : Array α) (f : α → m α) : m (Array α) :=
  go 0 as
where
  @[specialize] go (i : Nat) (as : Array α) : m (Array α) := do
    if h : i < as.size then
      let a := as[i]
      let b ← f a
      if ptrEq a b then
        go (i+1) as
      else
        go (i+1) (as.set ⟨i, h⟩ b)
    else
      return as

set_option trace.Compiler.result true
#eval Lean.Compiler.compile #[``mapMonoMImp, ``mapMonoMImp.go]

So there is a need to access the local definitions from the outside. And test ./tests/lean/docStr.lean also shows that by design local definitions are available from the outside…

So maybe another way must be found to let documentation and linters recognize local definitions (and, for example, hide them from the API unless they have a docstring).

Or maybe local definitoins should support private, public, protected qualifiers, maybe even defaulting to private.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant