Documentation

Desugarer.Errors

inductive DesugarError :

Errors produced while desugaring SurfaceTLAPlus/SurfacePlusCal into CoreTLAPlus/CorePlusCal.

  • misplacedAt (pos : SourceSpan) : DesugarError

    @ used outside of an EXCEPT update.

  • gotoNotInTailPosition (pos : SourceSpan) : DesugarError

    A goto is followed by more unlabelled statements — unreachable dead code (a goto followed by a label is fine).

  • unlabelledStatement (pos : SourceSpan) : DesugarError

    A statement appears before the first label of its enclosing thread — there is no label to attach it (or the block it starts) to.

  • nestedLabel (pos : SourceSpan) : DesugarError

    A label appears inside a with body — never allowed, since a with binding only makes sense within one atomic step.

  • whileInWith (pos : SourceSpan) : DesugarError

    A while statement appears inside a with body, at any nesting depth.

  • whileNotLabelled (pos : SourceSpan) : DesugarError

    A while statement is not immediately preceded by a real, user-written label; none is auto-inserted.

  • notFollowedByLabel (pos : SourceSpan) : DesugarError

    A statement following an if/either that contains a labelled statement or a goto anywhere within it is not itself labelled.

  • withBoundVarWritten (pos : SourceSpan) (name : String) : DesugarError

    A statement writes into a variable currently bound by an enclosing with — an assign target or a receive's target Ref. A with-bound name is a fixed local binding, not a process variable, so writing to it is meaningless.

  • wrongAnnotationKindAtSite (pos : SourceSpan) (found expected : String) : DesugarError

    An annotation-carrying slot only accepts specific kinds of annotation, but a different kind was found there.

  • duplicateAnnotation (pos : SourceSpan) (kind : String) : DesugarError

    Two or more annotations of the same kind found at one slot, for a kind whose content can actually differ between instances (@type, @mailbox). Content-free markers (@parameter) get a warning instead (DesugarWarning.duplicateParameterAnnotation).

  • conflictingAssignment (pos : SourceSpan) (name : String) : DesugarError

    The same bare variable (no index — x, not x[…]) is written more than once within one atomic step (assign/receive, any combination), on the same control path. Indexed writes (x[0] := …) aren't tracked by this check.

  • invalidRecordFieldAccess (pos : SourceSpan) : DesugarError

    The right-hand side of a record-access . is not a bare field-name identifier (e.g. r.1, r.(f)).

  • duplicateMacroDecl (pos : SourceSpan) (name : String) (firstPos : SourceSpan) : DesugarError

    Two macro declarations share a name. firstPos is the earlier one's own span.

  • labelInMacroBody (pos : SourceSpan) : DesugarError

    A label appears inside a macro body — never allowed, same restriction as with.

  • recursiveMacro (pos : SourceSpan) (cycle : List (String × SourceSpan)) : DesugarError

    The macro call-graph (which macro name each declared macro's own body calls) has a cycle. pos is the flagged declaration's own span; cycle is the chain of calls closing the loop, outermost first, each entry the callee name and the call site inside its caller's body.

  • undefinedMacro (pos : SourceSpan) (name : String) : DesugarError

    A Name(…) call names no declared macro.

  • macroArityMismatch (pos : SourceSpan) (name : String) (expected got : ℕ) (declPos : SourceSpan) : DesugarError

    A macro call's argument count doesn't match its declaration's parameter count. declPos is the declaration's own span.

  • macroArgumentNotAssignable (pos : SourceSpan) (macroName paramName : String) (writePos : SourceSpan) : DesugarError

    A macro call's argument is substituted into a parameter that the macro body writes to (assign/receive's target, send's channel), but the argument itself is not a reference (variable, possibly indexed/field-accessed) that can be written to. writePos is the span of the statement inside the macro body that writes to the parameter.

  • internalUnexpandedMacroCall (pos : SourceSpan) : DesugarError

    A .macroCall reached statement desugaring — every one should have been rewritten away by Desugarer/PlusCalMacros.lean's expansion pass, which runs first in runDesugarer. Reported as a diagnostic rather than panic!/unreachable!, matching this compiler's own instinct of never taking the process down on a "should be impossible" path.

Instances For
    @[implicit_reducible]
    Equations
    • One or more equations did not get rendered due to their size.
    inductive DesugarWarning :

    Non-fatal issues found while desugaring — collected out-of-band and filtered/printed once desugaring returns (Driver/Modules.lean's compileModule).

    • duplicateParameterAnnotation (pos : SourceSpan) : DesugarWarning

      A @parameter marker repeated on the same variable — content-free, so a warning rather than DesugarError.duplicateAnnotation.

    • partialMulticastAnnotation (pos : SourceSpan) : DesugarWarning

      A multicast filter whose components carry @type annotations on some binds but not all. The desugarer collapses the components into one binder over their Cartesian product, whose declared type is the tuple of theirs — which it can only build when every component supplies one. The annotations that were written are dropped, and the recipient's type comes from the channel's own declared domain instead.

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

        The -W<name>/-Wno-<name> name a given warning is filtered under.

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