Documentation

Lean.Message

def Lean.mkErrorStringWithPos (fileName : String) (pos : Position) (msg : String) (endPos : Option Position := none) :
Equations
  • One or more equations did not get rendered due to their size.

A naming context is the information needed to shorten names in pretty printing.

It gives the current namespace and the list of open declarations.

structure Lean.TraceData :
  • cls : Name

    Trace class, e.g. Elab.step.

  • startTime : Float

    Start time in seconds; 0 if unknown to avoid Option allocation.

  • stopTime : Float

    Stop time in seconds; 0 if unknown to avoid Option allocation.

  • collapsed : Bool

    Whether trace node defaults to collapsed in the infoview.

  • tag : String

    Optional tag shown in trace.profiler.output output after the trace class name.

Structured message data. We use it for reporting errors, trace messages, etc.

Instances For
def Lean.MessageData.lazy (f : PPContextBaseIO MessageData) (hasSyntheticSorry : MetavarContextBool := fun (x : MetavarContext) => false) :

Lazy message data production, with access to the context as given by a surrounding MessageData.withContext (which is expected to exist).

Equations
  • One or more equations did not get rendered due to their size.
partial def Lean.MessageData.hasTag (p : NameBool) :

Returns true when the message contains a MessageData.tagged tag .. constructor where p tag is true.

This does not descend into lazily generated subtrees (.ofLazy); message tags of interest (like those added by logLinter) are expected to be near the root of the MessageData, and not hidden inside .ofLazy.

Returns the top-level tag of the message. If none, returns Name.anonymous.

This does not descend into message subtrees (e.g., .compose, .ofLazy). The message kind is expected to describe the whole message.

Equations
Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
def Lean.MessageData.ofConstName (constName : Name) (fullNames : Bool := false) :

Represents a constant name such that hovering and "go to definition" works. If there is no such constant in the environment, the name is simply formatted, but sanitized if it is a hygienic name. Use MessageData.ofName if hovers are undesired.

If fullNames is true, then pretty prints as if pp.fullNames is true. Otherwise, pretty prints using the current user setting for pp.fullNames.

Equations
  • One or more equations did not get rendered due to their size.

Maximum number of trace node children to display by default to prevent slowdowns from rendering. In the info view, more children can be expanded interactively.

Equations
Equations
Equations
  • One or more equations did not get rendered due to their size.

Wrap the given message in parentheses ().

Equations

Wrap the given message in square brackets [].

Equations

Write the given list of messages as a list, separating each item with ,\n and surrounding with square brackets.

Equations

Puts MessageData into a comma-separated list with "or" at the back (no Oxford comma). Best used on non-empty lists; returns "– none –" for an empty list.

Equations

Puts MessageData into a comma-separated list with "and" at the back (no Oxford comma). Best used on non-empty lists; returns "– none –" for an empty list.

Equations
structure Lean.BaseMessage (α : Type u) :

A BaseMessage is a richly formatted piece of information emitted by Lean. They are rendered by client editors in the infoview and in diagnostic windows. There are two varieties in the Lean core:

  • fileName : String
  • pos : Position
  • endPos : Option Position
  • keepFullRange : Bool

    If true, report range as given; see msgToInteractiveDiagnostic.

  • severity : MessageSeverity
  • isSilent : Bool

    If true, filter this message from non-language server output. In the language server, silent messages are served as silent diagnostics. See also DiagnosticWith.isSilent?.

  • caption : String
  • data : α

    The content of the message.

Instances For
Equations
  • One or more equations did not get rendered due to their size.
@[reducible, inline]

A Message is a richly formatted piece of information emitted by Lean. They are rendered by client editors in the infoview and in diagnostic windows.

Equations

A SerialMessage is a Message whose MessageData has been eagerly serialized and is thus appropriate for use in pure contexts where the effectful MessageData.toString cannot be used.

Instances For
@[inline]
Equations
  • One or more equations did not get rendered due to their size.
def Lean.SerialMessage.toString (msg : SerialMessage) (includeEndPos : Bool := false) :
Equations
  • One or more equations did not get rendered due to their size.
@[reducible, inline]

Returns the top-level tag of the message. If none, returns Name.anonymous.

This does not descend into message subtrees (e.g., .compose, .ofLazy). The message kind is expected to describe the whole message.

Equations
@[inline]

Serializes the message, converting its data into a string and saving its kind.

Equations
  • One or more equations did not get rendered due to their size.
def Lean.Message.toString (msg : Message) (includeEndPos : Bool := false) :
Equations
Equations

A persistent array of messages.

In the Lean elaborator, we use a fresh message log per command but may also report diagnostics at various points inside a command, which will empty unreported and move its messages to reported. Reported messages are preserved for some specific "lookback" operations such as hasError that should consider the entire message history of the current command; most other functions such as add and toList will only operate on unreported messages.

  • The list of messages already reported (i.e. saved in a Snapshot), in insertion order.

  • The list of messages not already reported, in insertion order.

  • loggedKinds : NameSet

    Set of message kinds that have been added to the log. For example, we have the kind unsafe.exponentiation.warning for warning messages associated with the configuration option exponentiation.threshold. We don't produce a warning if the kind is already in the following set.

Instances For
Equations
@[deprecated "renamed to `unreported`; direct access should in general be avoided in favor of using `MessageLog.toList/toArray`" (since := "2024-05-22")]
Equations
Equations
Equations
Equations

Checks if either of reported or unreported contains an error, i.e. whether the current command has errored yet.

Equations
  • One or more equations did not get rendered due to their size.

Moves unreported messages to reported.

Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
def Lean.MessageLog.forM {m : TypeType} [Monad m] (log : MessageLog) (f : Messagem Unit) :
Equations

Converts the unreported messages to a list, oldest message first.

Equations

Converts the unreported messages to an array, oldest message first.

Equations

Quote e using and if e is not a free variable, constant, or literal.

Equations
  • addMessageContext : MessageDatam MessageData

    Without context, a MessageData object may be missing information (e.g. hover info) for pretty printing, or may print an error. Hence, addMessageContext should be called on all constructed MessageData (e.g. via m!) before taking it out of context (e.g. leaving MetaM or CoreM).

Instances
Equations
Equations
  • One or more equations did not get rendered due to their size.
@[defaultInstance 1000]
Equations
Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.