Multi-error reporting and raw_hash in the LSP and VS Code extension

SimplicityHL upstream branch now keeps analysing after an error, and adds a new unstable raw_hash builtin. Both are available in development branches of simplicityhl-lsp and the VS Code extension. You get all errors in the editor at once, and raw_hash gets completion, hover docs and diagnostics.

More than one error per run

Take this program and turn on the Enums experimental feature:

type Alias = Missing;
enum E { A(Unknown), B }
fn f(a: (Foo, Bar), b: u32) -> u32 { b }
fn g() -> u32 { y }

fn main() {
    let t: bool = true;
    let r: u32 = f(1, t);
}

With the current release (SimplicityHL 0.8.0 / simplicityhl-lsp 0.8.0), analysis stops at the first failing item, so you see only one error:

On SimplicityHL upstream, analysis continues after an undefined type (#430) or a failed function body (#424). The editor now shows all of them:

More details on the compiler side: SimplicityHL now reports more than one error per run.

raw_hash

raw_hash::<T>(tuple) hashes a tuple of unsigned integers with SHA-256 and returns a u256. It’s unstable, so it’s behind a setting like Imports and Enums: Settings → SimplicityHL: Experimental Features → Raw Hash.

fn main() {
    let a8: u8 = 255;
    let a32: u32 = 1_000_000;

    let raw: u256 = raw_hash::<(u8, u32)>((a8, a32));
    let ctx: Ctx8 = jet::sha_256_ctx_8_init();
    let ctx: Ctx8 = jet::sha_256_ctx_8_add_1(ctx, a8);
    let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, a32);
    assert!(jet::eq_256(raw, jet::sha_256_ctx_8_finalize(ctx)));
}

With Raw Hash off, the editor reports that raw_hash needs the unstable feature:

With it on, the code checks cleanly, and hovering over raw_hash shows its signature and a usage example:

The extension also adds -Z raw_hash to its Compile commands when the setting is on.

raw_hash supports tuples of u8, u16, u32, u64, u128 and u256.

Try it

None of this is released yet. The instructions use these commits: