vyrn

std/diag

3 exports, from std/diag.vyrn.

A generator reports a diagnostic, anchored in a file it read.

A line of a gen fn's output may be a report: a severity, an anchor in a file the generator read, and a message. The loader lifts it out, and every tool shows it like any other diagnostic.

import { report, Severity } from "std/diag"

export gen fn table(path: String) -> String {
    let mut out = ""
    out = out + report(Warning, path, 9, 3, "column `email` has no length limit")
    out = out + "export fn columnCount() -> Int64 { return 3 }\n"
    return out
}

A Warning changes no exit code and no output byte, unless the build passes --deny-warnings. An Error fails the load at the anchor. The anchor is a 1-based line and column, in //@origin notation, resolved against the module that imported the generator.

Dependencies

The import graph shows the whole library.

Imports
fn report(
    severity: Severity,
    file: String,
    line: Int64,
    col: Int64,
    message: String,
) -> String

A report anchored in an input file, at a 1-based line and col.

fn reportHere(severity: Severity, message: String) -> String

A report with no position, shown at the generated line it sits on: for a fault in the generator's inputs as a whole, such as a missing file.

Tests

4 test blocks in std/diag.vyrn. CI runs all of them.

Test names
  • a report is one directive line
  • an error says error
  • a message never breaks out of its line
  • a zero position is clamped, not lost

Examples

1 program in examples/ import this module. Each runs as WebAssembly and as a native binary.