lean2js

Lean2Js.Traps

source

Imports 2

Which traps one exported function can actually reach #

Reads off the syntax the trap codes a call of one exported function can throw.

The .d.ts is where a consumer decides whether to write a try. One line naming every code the subset has tells them nothing: a function that only adds and multiplies carries divByZero beside a function that divides, so the comment stops being a reason to catch anything. What is worth reading is the codes this function can reach.

Reaching is read off the syntax, the way the fuel bound is. Each operation contributes the codes its case in Eval can return, a call contributes the callee's, and a declaration handed over as a function contributes its own at the call that hands it over -- which is where the invariant lives: a function-typed parameter is only ever bound to a declared name passed as an argument, so a call through such a parameter adds nothing the caller has not already counted.

noMatchingAlternative is not among them. Exhaustive proves a match the compiler accepted has an arm for every value the entry check lets through, and a fold's alternatives one for every node its walk rebuilds, so the generated chain never runs off the end.

This is not proved, and emit does not take it on trust: every vector generated for a declaration is checked to trap only with a code this reads off it.

def

Lean2Js.Traps.allCodes

source

Every code the generated code throws, in the order a @throws line names them.

Equations
Instances For
    Used by
      def

      Lean2Js.Traps.canonical

      source

      The codes of a set, deduplicated and in that order, so two declarations that reach the same traps carry the same line.

      Equations
      Instances For
        Used by
          def

          Lean2Js.Traps.exprCodes

          source

          The codes an expression can reach, given what the declarations before it reach. A call to a name the table does not hold is a call through a function-typed parameter, which the caller counted when it named the declaration.

          Equations
          Instances For
            Used by
              def

              Lean2Js.Traps.exprCodesList

              source
              Equations
              Instances For
                Used by
                  def

                  Lean2Js.Traps.exprCodesArgs

                  source
                  Equations
                  Instances For
                    Used by
                      def

                      Lean2Js.Traps.exprCodesAlts

                      source
                      Equations
                      Instances For
                        Used by
                          def

                          Lean2Js.Traps.exprCodesEntries

                          source
                          Equations
                          Instances For
                            Used by
                              def

                              Lean2Js.Traps.table

                              source

                              The table, built in declaration order. Every call reaches backwards, so a callee's codes are already in it by the time the caller is read.

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

                                  Lean2Js.Traps.forDecl

                                  source

                                  What one declaration's @throws names. The entry check is what puts typeError there: it reads the arguments a JavaScript caller passed, and a declaration that takes none has nothing to refuse.

                                  The .d.ts and the check emit runs against every vector both go through here, so the line a consumer reads and the line the build stands behind cannot come apart.

                                  Equations
                                  Instances For
                                    Used by
                                      def

                                      Lean2Js.Traps.forName

                                      source
                                      (p : Core.Program) (traps : List (String × List String)) (fn : String) :
                                      Equations
                                      Instances For
                                        Used by