# E# > E# is a multi-paradigm, general-purpose programming language for the .NET CLR (`.es` files, not ECMAScript). It compiles to standard CLR assemblies with full C#/F# interop; value-semantic by default, errors as values, uncolored async. ## Guide - [what-is-esharp](https://esharp-lang.vercel.app/guide/what-is-esharp/) - [types](https://esharp-lang.vercel.app/guide/types/) - [inheritance](https://esharp-lang.vercel.app/guide/inheritance/) - [functions](https://esharp-lang.vercel.app/guide/functions/) - [control-flow](https://esharp-lang.vercel.app/guide/control-flow/) - [errors](https://esharp-lang.vercel.app/guide/errors/) - [memory](https://esharp-lang.vercel.app/guide/memory/) - [concurrency](https://esharp-lang.vercel.app/guide/concurrency/) - [interop](https://esharp-lang.vercel.app/guide/interop/) ## Specification The normative language specification — keyword tables, EBNF grammar, name resolution, the CLR lowering, and the full diagnostic catalog. Reproduced inline in llms-full.txt. - [overview](https://esharp-lang.vercel.app/spec/) - [lexical](https://esharp-lang.vercel.app/spec/lexical/) - [names-and-resolution](https://esharp-lang.vercel.app/spec/names-and-resolution/) - [declarations](https://esharp-lang.vercel.app/spec/declarations/) - [expressions](https://esharp-lang.vercel.app/spec/expressions/) - [statements](https://esharp-lang.vercel.app/spec/statements/) - [functions](https://esharp-lang.vercel.app/spec/functions/) - [pointers](https://esharp-lang.vercel.app/spec/pointers/) - [errors](https://esharp-lang.vercel.app/spec/errors/) - [concurrency](https://esharp-lang.vercel.app/spec/concurrency/) - [delegates-events](https://esharp-lang.vercel.app/spec/delegates-events/) - [clr-mapping](https://esharp-lang.vercel.app/spec/clr-mapping/) - [limitations](https://esharp-lang.vercel.app/spec/limitations/) - [diagnostics](https://esharp-lang.vercel.app/spec/diagnostics/) — every `ES####` code, linked to the corpus examples that provoke it ## Compiler & contributing - [compiler](https://esharp-lang.vercel.app/compiler/) — the compiler is in a private repo during active development; how to request access and contribute tests The corpus below is drawn from the language's own test suite and samples — passing test cases, showcases, and integration tests. Each example compiles cleanly (or, for negative cases, is rejected with its expected diagnostic) and either produces its asserted output or stands as a real, well-formed program. ## Corpus by topic - [allocation (72 examples)](https://esharp-lang.vercel.app/examples/allocation/1/) - [async (87 examples)](https://esharp-lang.vercel.app/examples/async/1/) - [choice (159 examples)](https://esharp-lang.vercel.app/examples/choice/1/) - [const (22 examples)](https://esharp-lang.vercel.app/examples/const/1/) - [core (500 examples)](https://esharp-lang.vercel.app/examples/core/1/) - [data (199 examples)](https://esharp-lang.vercel.app/examples/data/1/) - [delegates-events (33 examples)](https://esharp-lang.vercel.app/examples/delegates-events/1/) - [embedding (20 examples)](https://esharp-lang.vercel.app/examples/embedding/1/) - [enum (8 examples)](https://esharp-lang.vercel.app/examples/enum/1/) - [field-defaults (5 examples)](https://esharp-lang.vercel.app/examples/field-defaults/1/) - [generics (11 examples)](https://esharp-lang.vercel.app/examples/generics/1/) - [inheritance (40 examples)](https://esharp-lang.vercel.app/examples/inheritance/1/) - [interop (63 examples)](https://esharp-lang.vercel.app/examples/interop/1/) - [interpolation (66 examples)](https://esharp-lang.vercel.app/examples/interpolation/1/) - [pointers (135 examples)](https://esharp-lang.vercel.app/examples/pointers/1/) - [programs (4 examples)](https://esharp-lang.vercel.app/examples/programs/1/) - [result (41 examples)](https://esharp-lang.vercel.app/examples/result/1/) - [static-func (49 examples)](https://esharp-lang.vercel.app/examples/static-func/1/) ## Full corpus - [llms-full.txt](https://esharp-lang.vercel.app/llms-full.txt) — the entire Guide, Specification, and every example, inline --- # Guide ## What is E# E# is a general-purpose programming language for the **.NET Common Language Runtime (CLR)**. Source files end in `.es`, and they compile through Mono.Cecil straight to ordinary .NET assemblies. A type written in E# is a real CLR type: a C# project references the `.dll` and uses it without knowing or caring that it wasn't C#. It is **not** ECMAScript (the `.es` extension is a collision, nothing more), and it is not a preprocessor or a dialect of C#. It is its own language that shares C#'s runtime. ## Why it exists E# started from a wish list, not a gap in the market. The type system should read like Go — small, regular, few surprises — but go further than Go does: real generics, classes when a problem wants them, and a good chunk of the ideas Rust gets right in its type system (tagged unions you match exhaustively, errors as values, the `->` return syntax). Concurrency modelled on what Go and Swift do well. And an object model that lands **between Go and C#** — more structure than Go, far less ceremony than C#. That combination didn't exist on the CLR, so E# is it. Targeting the CLR was a goal from day one, and that's where the second pillar comes in. Because E# is a first-class CLR citizen, it can do something .NET never really had. The JVM has long been polyglot in the small: Java, Scala, and Kotlin mix *inside one project*, not just across a package boundary. The CLR never got that — you had C#, and while F# exists, it doesn't drop into a C# codebase the way Scala drops into a Java one. E# closes that case. **`.es` and `.cs` files compile into a single assembly** — drop both kinds in a directory and point the compiler at it: the E# half emits IL through Mono.Cecil, Roslyn compiles the C# half, and ILRepack fuses both into one `.dll` with bidirectional references. (Pure-E# code skips Roslyn entirely.) No NuGet boundary between them, no interop attributes, no two-projects-and-a-reference dance. This was an early priority precisely because it's the payoff of being native to the runtime rather than bolted on after — a big part of the language, even if it isn't the whole reason for it. ## The shape of it E# borrows the readability of modern languages and puts it on a runtime many of us already use: - `->` return arrows and name-before-type annotations (`func add(a: int, b: int) -> int`) - expression-bodied functions (`func double(x: int) -> int = x * 2`) - value types by default, with the object world available when you ask for it - errors as values; `match` over tagged unions; uncolored-by-default async (semi-colored when you want the machinery) The goal is **not** to out-feature C#. C# is, by feature count, about the largest language going (before you even reach its BCL). E# goes the other way: a smaller, composable core. Modern, object-oriented, and — relative to C# — simple. ```es namespace Geometry data Point { x: int, y: int } // A free function whose first parameter is `Point` becomes a method on it — // composition by attachment, instead of methods trapped inside a class body. func dist2(p: Point) -> int = p.x * p.x + p.y * p.y func demo() -> int { let p = Point { x: 3, y: 4 } return p.dist2() // 25 — called as a method } ``` ## Object-oriented, with a procedural front door There is no `class` keyword. `data` (a value type) and `ref data` (a class, with identity) cover the type story; `static func` gives you a static class. Methods *attach* to a type through instance-method promotion rather than living inside it, and composition leans on `interface` conformance plus that promotion. Inheritance exists on `ref data` but is opt-in and sealed by default — the opposite of C#'s "inheritable unless you say otherwise." If you want a one-line placement: E#'s object-orientation sits **between Go and C#** — more than Go (which has no classes or inheritance), less than C# (where everything is a class). That choice extends to how a program *starts*. An executable is entered through `main`, in either shape: a bare top-level `func main()` (the program is a function), or a `main` method on a `ref data Program` (the program is an object). The class-style needs no launcher — the compiler enters it as `Program().main()`: ```es // function-style // class-style func main() -> int { ref data Program { return run() func main() -> int { return run() } } } ``` ## Where it's a good fit E# is general-purpose — it covers the same range as any other CLR language, with no single intended niche. Where it slots in is shaped by mechanics rather than preference: - **In an existing .NET project** — `.es` and `.cs` compile into one assembly, so E# can be adopted incrementally, a file at a time, instead of as a separate project. - **As a library** — an E# type is an ordinary CLR type; C# and F# consume it directly, with no shim. - **Standalone** — pure-E# code compiles straight to an assembly through Mono.Cecil. ## Status E# is **pre-alpha**. The language is real and tested — the IL compiler is the source of truth, and every assembly the test harness produces is run through ILVerify — but the surface is still moving and some corners are unfinished. The most honest picture of what compiles *today* is the [corpus](/examples/): a large set of real `.es` programs drawn from the language's own test suite and samples — passing test cases, showcases, and integration tests — each one compiled cleanly (or rejected with its expected diagnostic) and either producing its asserted output or standing as a real, well-formed program. Start there, or walk the guide: - [Types](/guide/types/) — `data`, `ref data`, `choice`, `enum`, `interface` - [Functions & promotion](/guide/functions/) — free functions, methods by attachment, `static func` - [Control flow & match](/guide/control-flow/) — `if`, loops, and pattern matching - [Errors: Result & ?](/guide/errors/) — errors as values - [Pointers & memory](/guide/memory/) — `*T`, `new`, `&`, and the mutation triad - [Async & concurrency](/guide/concurrency/) — uncolored async, channels, structured concurrency - [Interop & delegates](/guide/interop/) — the polyglot payoff - [Showcase](/guide/showcase/) — curated, heavily-commented programs end to end ## Types E# has a small set of type kinds. The split that matters most is **value vs. identity**: `data` is value-semantic by default, `ref data` is the object world you opt into. ## `data` — the value-semantic default `data` is the kind you reach for most. It carries a **value-semantic contract**: - **Copy-on-assign** — `let b = a` copies; mutating `b` never touches `a`. - **No object identity** — two `data` values with equal fields are equal; there's no reference identity. - **Value-shaped equality** — field-wise by default. - **No shared mutation through aliases** — every binding is its own value. - **`nil` is invalid on plain `T`** — nullability requires `*T` or `T?`. - **The CLR form isn't part of the contract** — the compiler represents a `data` as a struct or a class (small/simple stays a struct; large/reference-heavy/heavily-copied silently becomes a class). The contract holds either way, so you never have to care; a C# consumer sees a stable surface regardless. Pin it with `[StackAlloc]` / `[HeapAlloc]` when you have a measured reason. ```es data Point { x: int, y: int } let a = Point { x: 1, y: 2 } let b = a // a copy — mutating b never touches a ``` To a C# eye, `data` reads a lot like a `record` — value equality, `with`, copy semantics — but `record` is a C#-language construct, not a CLR primitive. `data` is E#'s own take: it lowers to a plain CLR struct or class, with the value-equality and `with` machinery generated directly. Fields can be written on one line (comma-separated) or one per line. Construction is the composite literal `T { field: value }`; there are no constructors on `data` — an `init` block on a `data` is an error ([ES3012](/spec/diagnostics/#es3012)). If construction needs logic, write a factory function: ```es func makePoint(x: int, y: int) -> Point = Point { x: x, y: y } ``` A `data` can't contain itself by value (that would be infinitely large) — break the cycle with a pointer ([ES2002](/spec/diagnostics/#es2002)). See [Pointers & memory](/guide/memory/). ```es data Node { value: int, next: *Node } // *Node, not Node data Tree { value: int, children: List<*Tree> } // through a generic container too ``` **Declaration order is free.** A type may reference another declared *later* in the file, and two types may reference each other — the compiler resolves all type names regardless of order: ```es data Field { key: string, value: Json } // references Json, declared below ref choice Json { jnull jobj(fields: List) // ...which references Field — a mutual cycle } ``` ### Field mutability Fields are mutable by default. Mark a field `let` (immutable after construction — emits `initonly`) or `var` (explicitly mutable): ```es data Cursor { var position: int, let label: string } ``` ### Positional form Sugar for the full form plus positional construction — you still get the composite form too: ```es data Vec2(x: int, y: int) // construct as Vec2(3, 4) or Vec2 { x: 3, y: 4 } ``` ### `readonly data` Sugar for "all fields `let`", and it also emits `[IsReadOnly]` on the struct, telling the JIT to skip defensive copies on `in` parameters: ```es readonly data RegisterFile { rax: long, rbx: long, rip: long, flags: int } ``` ### `with` — non-destructive update Copy a value and overwrite specific fields, producing a new value — zero allocation, zero heap. `with` is value-only (using it on a `ref data` is an error): ```es let p1 = Point { x: 3, y: 4 } let p2 = p1 with { x: 10 } // p1.x == 3, p2.x == 10, both y == 4 ``` ### Struct embedding A bare type name as a field embeds it; the embedded type's fields and methods are *promoted* — reachable directly on the outer type (`t.x` desugars to `t.Vec2.x`; the outer type's own members shadow promoted names). Pointer embedding (`*T`) promotes through auto-deref: ```es data Transform { Vec2, var scale: double } // t.x, t.magnitude() reach into Vec2 data Entity { *Vec2, name: string } // promoted through the pointer (nullable) ``` ### Generic `data` Type parameters are **reified** — each instantiation is a real closed type at runtime, not an erasure: ```es data Pair { first: A, second: B } let p = Pair { first: 1, second: "x" } ``` [Browse `data` examples →](/examples/data/1/) · [`embedding` →](/examples/embedding/1/) ## `ref data` — identity and the object world `ref data` is a CLR class: heap-allocated, reference equality, GC-tracked. Reach for it when you genuinely want identity, shared mutable state, framework interop, or constructors. Methods can live directly in the body, `init(...)` blocks are real constructors, and fields can carry defaults that run before the `init` body. ```es ref data Server { let host: string = "localhost" // field default var port: int = 8080 init(port: int) { self.port = port } func describe() -> string = "{self.host}:{self.port}" } ``` Inheritance is opt-in and **sealed by default** (`open` / `abstract`, `virtual` / `abstract` / `: func`, `init(...) : base(...)`) — it has its own page: [Inheritance](/guide/inheritance/). [Browse inheritance examples →](/examples/inheritance/1/) ## `choice` — tagged unions A `choice` is a sum type: a value that is exactly one of several named variants, each carrying its own payload. Emits as a tag enum + struct with factory methods (always a struct). It pairs with [`match`](/guide/control-flow/). ```es choice AuthError { invalidCredentials accountLocked(untilUtc: DateTimeOffset) // multi-payload cases allowed rateLimited(retryAfterMs: int) } let err = AuthError.invalidCredentials() // factory form ``` **Generic `choice` is reified** — `Option` is a real closed generic struct, not an erasure to `object`; a `match` binds the payload at its substituted type: ```es choice Option { some(value: T), none } let o = Option.some(99) // typed Option; .some(v) → v : int ``` **Dot-case shorthand** works when the type is known from context: ```es func findUser(id: Guid) -> Option { if user == nil { return .none } return .some(user) } ``` [Browse `choice` examples →](/examples/choice/1/) ## `ref choice` — sealed class hierarchy The identity-carrying variant — an abstract base with a sealed subclass per case — for recursive, polymorphic structures (ASTs, UI trees, state machines). ```es ref choice Expr { literal(value: int) add(left: Expr, right: Expr) neg(inner: Expr) } ``` Two construction forms emit equivalent IL — the factory (mirrors the dot-shorthand) and the per-case subtype composite literal (the underlying CLR type per case is `Outer_case`): ```es let tree = Expr.add(Expr.literal(3), Expr.literal(4)) // factory let sum = Expr_add { left: Expr_literal { value: 3 }, right: Expr_literal { value: 4 } } // composite ``` A `match` over a `ref choice` uses an `isinst` type pattern: ```es match expr { .literal(v) { return v } .add(l, r) { return eval(l) + eval(r) } .neg(inner) { return 0 - eval(inner) } } ``` ## `enum` — a closed set of constants A plain set of named constants with no payloads. Emits as a real CLR `System.Enum` (int32 underlying), interchangeable with C# enums. Variants without an explicit value start at `0` and increment; after an explicit value, auto-numbering resumes from `value + 1`: ```es enum Direction { north, south, east, west } enum Level { a, b = 10, c } // a=0, b=10, c=11 ``` Construct with the factory form — the trailing `()` is required, so the same call shape works across `enum`, `choice`, and `ref choice`: ```es let d = Direction.north() ``` A `match` on an enum needs a type hint, because variants flow through the dot-case shorthand: ```es match (d: Direction) { .north { return "N" } .south { return "S" } default { return "?" } } ``` [Browse `enum` examples →](/examples/enum/1/) ## `interface` — nominal conformance Interfaces emit as standard CLR interfaces. Conformance is **nominal** (`data` and `ref data` alike): a type implements an interface only when it *names* it after `:`. There's no structural auto-satisfaction — methods still attach via promotion, but the type declares which interfaces it fulfills. The check is exact: every method matched by name, parameter types, **and** return type. ```es interface IDescribable { func describe() -> string } data Client : IDescribable { name: string } func describe(c: Client) -> string = "client: {c.name}" ``` Why nominal: the CLR is nominal underneath, declaring the interface makes the (value-type) boxing site explicit, and it lines up with how dependency registration is written. A type that *would* satisfy an interface it doesn't declare gets a warning ([ES2153](/spec/diagnostics/#es2153)) naming the `: IFoo` to add — a structural coincidence is never silently treated as conformance. When only the **pointer** method set satisfies a declared interface (a pointer-receiver method, `func f(x: *T)`), the generated `__Ptr_T` wrapper implements the interface and the value type does not — the Go pointer-receiver case. See [Pointers & memory](/guide/memory/). ## Nullable `T?` `T?` is *optional presence* — distinct from [`Result`](/guide/errors/), which is for fallible operations. | `T?` of… | Emits as | |---|---| | value type (`int?`, `data?`) | `Nullable` | | reference type (`string?`, `ref data?`) | unwrapped (already nullable) — holds as a generic arg too: `Func` is `Func` | `nil` fills either (`initobj Nullable` for value types, `ldnull` for reference types). ```es func find(id: int) -> User? { if id == 0 { return nil } return lookupUser(id) } ``` ## Attributes `[Name]` and `[Name(args)]` pass straight through as CLR custom attributes — same syntax as C#, with constructor arguments resolved at bind time: ```es [Obsolete("use v2")] [StructLayout(LayoutKind.Explicit)] ref data Config { name: string } ``` (`[StackAlloc]` / `[HeapAlloc]` are compiler directives, not CLR attributes — they pin a `data`'s form, then vanish from the assembly.) ## `derive` — generated members `derive` emits real members at **compile time** (not runtime reflection). Place it above the type; combine directives with a comma: ```es derive equality, debug data Packet { header: uint, length: int } ``` - `derive equality` generates `Equals(object)`, `GetHashCode()`, and `==` / `!=`. - `derive debug` generates `ToString()` → `Packet { header: 1, length: 2 }`. ## Primitive types | E# | CLR | Size | | E# | CLR | Size | |---|---|---|---|---|---|---| | `int` | `Int32` | 4 | | `float` | `Single` | 4 | | `uint` | `UInt32` | 4 | | `double` | `Double` | 8 | | `long` | `Int64` | 8 | | `bool` | `Boolean` | 1 | | `ulong` | `UInt64` | 8 | | `char` | `Char` | 2 | | `short` | `Int16` | 2 | | `string` | `String` | ref | | `ushort` | `UInt16` | 2 | | `void` | `Void` | 0 | | `byte` / `sbyte` | `Byte` / `SByte` | 1 | | | | | ## Built-in types - **`Result`** — error-as-value; `ok(...)` / `error(...)`, `?` propagation, combinators. See [Errors](/guide/errors/). - **`Job` / `Job`** — task handles from `spawn` / `task func`. - **`Chan`** — typed channels. - **`TaskScope`** — structured concurrency. The last three are covered in [Async & concurrency](/guide/concurrency/). **Type resolution order:** primitives → built-in generics (`Result`, `Chan`) → current unit → other files → external .NET types. ## Visibility Everything is **internal by default**; `pub` makes a declaration visible outside its assembly. Two levels only — there's no `private` / `protected`. The module is the privacy boundary. Fields inherit the enclosing type's visibility unless overridden with `pub`. ```es pub data Order { symbol: string, qty: int } // public type data Internal { secret: int, pub name: string } // internal type, one public field ``` For the exact grammar and normative rules behind every type kind, see the [Specification](/spec/). ## Inheritance Inheritance exists on `ref data` only, and is **opt-in, sealed by default** — the opposite of C#'s "inheritable unless `sealed`". `data`, `choice`, and `enum` do not participate. ## Class modifiers | Modifier | Instantiable | Inheritable | CLR shape | |---|---|---|---| | (none) | yes | no | `sealed` class — the default; there is no `sealed` modifier to write | | `open` | yes | yes | regular (non-sealed, non-abstract) class | | `abstract` | no | yes | `abstract` class | ```es ref data Tag { init() { } } // sealed by default — no modifier open ref data Animal { init() { } } // base for derivation abstract ref data Shape { init() { } } // must be subclassed ``` `open` is the one shape that is **both instantiable and inheritable** — and E#'s take on OO is that a class should be **either `abstract` or sealed**, never both at once. So `open` is **slated to become an explicit `.esproj` opt-in, disabled by default**: the language steers you toward `abstract` (a base you extend) or the sealed default (a leaf you instantiate), and the both-at-once middle is something you enable deliberately — explicitness over habit — rather than reach for by default. ## Member forms | Form | Body | Meaning | |---|---|---| | `func name(...)` | required | Ordinary method. Shadowing a virtual parent → [ES2120](/spec/diagnostics/#es2120). | | `virtual func name(...)` | required | New vtable slot; subclasses may override. Only on `open`/`abstract` ([ES2126](/spec/diagnostics/#es2126) otherwise). | | `abstract func name(...)` | none | Contract; subclasses must fulfill. Only inside `abstract ref data` ([ES2125](/spec/diagnostics/#es2125) otherwise). | | `: func name(...)` | depends | Inheritance-participating. The compiler infers the role (below). | ## `: func` role inference When the compiler walks the chain and finds a matching `virtual`/`abstract` parent, it infers the role from *parent form × this body × child kind*: | Parent form | Has body? | Child abstract? | Resolved role | Emits | |---|---|---|---|---| | `abstract` | yes | no | **Fulfill** | `Virtual`, reuses the vtable slot | | `virtual` | yes | no | **Override** | `Virtual`, reuses the slot | | `abstract` | no | yes | **PassThrough** | contract stays abstract; no MethodDef on the child | | `virtual` | no | yes | **ReAbstract** | child removes the body (rare) | ```es abstract ref data Shape { init() { } abstract func area() -> int } ref data Square : Shape { side: int init(s: int) : base() { self.side = s } : func area() -> int { return self.side * self.side } // Fulfill } ``` Diagnostics around `: func`: | Code | Trigger | |---|---| | [ES2121](/spec/diagnostics/#es2121) | `: func` body required in a concrete subclass | | [ES2122](/spec/diagnostics/#es2122) | no matching virtual/abstract on the chain | | [ES2123](/spec/diagnostics/#es2123) | parent member is neither `virtual` nor `abstract` | | [ES2124](/spec/diagnostics/#es2124) | `:` used in a class with no inheritance header | ## Base-constructor chaining A subclass `init` chains to the base with `: base(...)` between the parameter list and the body: ```es open ref data Animal { species: string, init(s: string) { self.species = s } } ref data Dog : Animal { name: string, init(n: string) : base("dog") { self.name = n } } ``` The compiler resolves `: base(args)` against the base `init` and emits the matching `.ctor` call before field-default initialization. An argument-count mismatch is [ES2128](/spec/diagnostics/#es2128). Inherited fields and methods resolve transparently through the chain; an overridden `virtual` dispatches via `callvirt`. ## Interfaces and base classes together `ref data Renderer : IDrawable, IDescribable { ... }` — multiple interfaces are comma-separated. When the `:` list includes a **base class**, the base class must be the first entry. Interface conformance itself is nominal — see [Types → interface](/guide/types/#interface--nominal-conformance). [Browse inheritance examples →](/examples/inheritance/1/) ## Functions & promotion Functions are the front door of E#. You write them free, at namespace scope, and the compiler attaches them to types where it makes sense — so you get methods without trapping behavior inside a class body. ## Declarations ```es func add(a: int, b: int) -> int { return a + b } ``` The type comes after the name; the return type after `->`. No `-> T` means the function returns nothing (`void`). A top-level `func` emits as a static method on its namespace class. `returns` is a synonym for `->` if you prefer the word: ```es func add(a: int, b: int) returns int { return a + b } ``` ## Expression-bodied functions When the body is a single expression, drop the braces and `return`: ```es func double(x: int) -> int = x * 2 func abs(x: int) -> int = x > 0 ? x : 0 - x func log(msg: string) = Console.WriteLine(msg) ``` ## Generics CLR reified generics — each instantiation is a real type at runtime: ```es func identity(value: T) -> T = value func swap(pair: Pair) -> Pair { return Pair { first: pair.second, second: pair.first } } ``` ## Instance-method promotion This is the one to internalize. **A function whose first parameter is a `data` type automatically becomes a method on that type.** You define behavior next to the data without nesting it inside the declaration. ```es data Client { name: string, age: int } func describe(client: Client) -> string = "{client.name} is {client.age}" let c = Client { name: "Ada", age: 36 } let s = c.describe() // method call ``` Promotion works across files — the type and the function don't have to live together. There's a deliberate rule about call shape: - A function on a **value** receiver (`func bump(v: Vec)`) *is* the method `v.bump()`. Calling it free as `bump(v)` is an error (with a fixit pointing at `v.bump()`). The method travels with its type, reachable wherever the type is in scope. - A function on a **pointer** receiver (`func bump(v: *Vec)`) stays a real free function *and* joins `*Vec`'s method set — both `bump(&x)` and (where applicable) the method form work. Take a pointer receiver when you want to mutate, or to avoid copying a large struct. Only `data` triggers promotion — not `choice`, `enum`, or primitives. ### Method chaining (fluent) Promoted calls chain when a method returns a value the next call lands on. A method that returns its **receiver** makes a fluent API — and since a `ref data` is a reference, returning it hands back the *same* object, so each call mutates and returns the one instance, with no re-binding: ```es ref data Turtle { var x: int, var y: int, init() { self.x = 0 self.y = 0 } } func forward(t: Turtle, n: int) -> Turtle { t.y += n return t } // returns self → chains let t = Turtle().forward(5).forward(3) // one object threaded through the chain ``` A value `data` chains too, but each step returns a *fresh* value — transformation, not mutation (`a.add(b).scaled(2)`). A chain may break across lines with a **leading dot**; a newline before a `.` continues the chain: ```es let t = Turtle() .forward(5) .turn(.right) .forward(3) ``` A method returning `Result` doesn't chain (the next call would be on a `Result`) — unwrap each step with `?`, or design the method to return the receiver. See the [turtle showcase](/guide/showcase/#turtle). ## `static func` — a static class `static func Name { ... }` declares a static class (a sibling of the namespace class). Its body holds fields and functions — the home for grouped helpers and constants. ```es static func Password { const MIN_LEN = 8 func isStrong(s: string) -> bool = s.Length > MIN_LEN } func ok() -> bool = Password.isStrong("hunter2hunter2") ``` A `let X = ` in the body becomes a CLR `const`; a `let X = ` becomes a `static readonly`; `var X` is a mutable static; `func`s are static methods. [Browse `static func` examples →](/examples/static-func/1/) ## Lambdas & function literals ```es let dbl = func(x: int) -> int { return x * 2 } let sq = (x) => x * x // arrow form, expression-bodied let add = (a, b) => a + b ``` Arrow-lambda parameter types are inferred when a delegate type is expected at the call site. Both forms capture surrounding variables (closures), and captures are mutable — writes inside the closure are visible outside, and vice versa. ```es var total = 0 let inc = func() { total = total + 1 } inc() inc() // total == 2 ``` ## Function pointers vs. delegates E# has two ways to pass behavior around, picked by intent: - **Function pointer** — `&func`, zero allocation, single-target, `ldftn` + `calli`. For hot paths and dispatch tables. - **Delegate** — `Func<>`, `Action<>`, or a nominal `delegate func`; heap-allocated and multicast. For framework interop, callbacks, and events. ```es func addOp(a: int, b: int) -> int = a + b let p = &addOp // function pointer let n = p(3, 4) // 7 — called via calli, no delegate object ``` Both are covered in depth — including nominal `delegate func` and events — in [Interop & delegates](/guide/interop/). ## Every path must return A non-void function must return on every path; falling through is a hard error rather than a silent default. The check is exhaustive-match-aware, so a `match` that covers every variant and returns in each arm counts as returning — no redundant trailing `return` needed. See [Control flow & match](/guide/control-flow/). ## Control flow & match Control flow is conventional where it can be and expressive where it counts. No parentheses around conditions; braces are mandatory. ## if / else ```es if x < 0 { return 0 - x } if a > b { return a } else if b > c { return b } else { return c } ``` ## Loops ```es while i <= n { total += i i += 1 } for i in 0..n { // range buffer[i] = 0 } for item in collection { // any iterable process(item) } for event in ch { // a channel, until it closes handle(event) } ``` `for..in` also destructures tuples — and a `Dictionary`, whose `KeyValuePair` elements unpack into the key and value (each typed, so `key.Length` resolves): ```es for (key, value) in scores { // scores: Dictionary log("{key}: {value}") } ``` ## match `match` is where `choice`, `ref choice`, and `enum` pay off. Each arm names a variant with `.case`, optionally binding its payload. ```es choice ConnState { disconnected connecting connected(sessionId: int) failed(reason: string) } func describe(s: ConnState) -> string { match s { .disconnected { return "disconnected" } .connecting { return "connecting" } .connected(sid) { return "connected:{sid}" } .failed(reason) { return "failed:{reason}" } } } ``` Multi-payload cases bind positionally (`.message(lvl, txt)`), and you can ignore a payload with `_`. There's also a **single-binding case view**: bind the whole case to one name and reach its payloads by field — `.pair(p)` then `p.a`, `p.b` — which composes with positional binding so you pick whichever reads better. For a **single-payload** case the case view is *transparent*: the bound name **is** the payload value, and `name.field` still resolves to the same thing — so `.connected(sid)` lets you use `sid` as the int directly. This holds for value `choice` **and** `ref choice` alike: ```es ref choice Json { jbool(value: bool) jarr(items: List) } match j { .jbool(b) { return b ? "true" : "false" } // b IS the bool .jarr(items) { return "[{items.Count}]" } // items IS the List } ``` It's pure sugar — `.jbool(b)` is exactly `.jbool(c)` reaching `c.value`, both lowering to the same payload load. (A multi-payload case has no single value to unwrap to, so it keeps the named view: `.add(n)` then `n.left` / `n.right`.) `ref choice` matches the same way (it uses an `isinst` type check under the hood): ```es ref choice Expr { literal(value: int) add(left: Expr, right: Expr) neg(inner: Expr) } func eval(e: Expr) -> int { match e { .literal(v) { return v } .add(l, r) { return eval(l) + eval(r) } .neg(inner) { return 0 - eval(inner) } } } ``` ### match is exhaustive The compiler warns when a `match` over a `choice`/`ref choice`/`enum` misses a variant. Combined with the every-path-must-return rule, an exhaustive match where every arm returns *is* a complete function body — no trailing `return` needed. Add `default { }` as the catch-all when you want it. ### Literal patterns `match` also dispatches on `int`, `string`, and `bool` literals: ```es match status { 200 { return "ok" } 404 { return "not found" } default { return "unknown" } } ``` (Literal universes are open, so `default` is how you stay total — exhaustiveness checking doesn't apply here.) ### match is an expression A `match` can appear anywhere an expression can — a `let`, a `return`, an interpolation, an expression-bodied function. Every arm must produce the same type. ```es let label = match status { 200 { "ok" } 404 { "not found" } default { "other" } } func describe(r: Result) -> string = match r { .ok(v) { "value={v}" } .err(e) { "err:{e}" } } ``` [Browse `match`-heavy examples →](/examples/choice/1/) ## defer `defer { ... }` schedules cleanup that runs when the scope exits (it lowers to `try`/`finally`). Multiple defers run in LIFO order. ```es let handle = openFile(path) defer { handle.Close() } // runs on the way out, however the scope exits ``` ## return Standard `return`. The thing to remember is the **definite-return** rule: every path of a non-void function must return, and the analysis understands exhaustive `match` and `if`/`else` where both branches return, plus `while true { ... }` with no break. Correct exhaustive code needs no filler trailing return. ## Errors: Result & ? E# treats errors as **values**, not control flow. A fallible function returns `Result`, and the `?` operator threads the failure path for you. Exceptions (`try`/`catch`) exist, but they're for the boundary with the BCL — not how E# code talks to itself. ## Result<T, E> `Result` is either an `ok(value)` or an `error(value)`. The error type is yours to design — very often a `choice` enumerating exactly what can go wrong. ```es choice DbError { notFound connectionFailed(message: string) timeout } func findUser(id: Guid, db: DbContext) -> Result { let user = db.Users.Find(id) if user == nil { return error(.notFound) } return ok(user) } ``` `ok(...)` and `error(...)` construct the two sides; `.dotCase` shorthand works inside `error(...)` when the type is known from context. You can inspect a result with `.IsOk` / `.IsError`, `.Value` / `.Error`, or the fluent combinators (`.Map`, `.Bind`, `.UnwrapOr`, `.Match`, …). [Browse `Result` examples →](/examples/result/1/) ## The ? operator `?` unwraps a `Result`: if it's `ok`, you get the value; if it's `error`, the enclosing function returns that error immediately. It collapses the usual check-and-return boilerplate into one character. ```es func getProfile(id: Guid, db: DbContext) -> Result { let user = findUser(id, db)? // returns the DbError if findUser failed let prefs = findPreferences(user.id, db)? return ok(Profile { user: user, prefs: prefs }) } ``` Because `?` returns the error from the enclosing function, that function's error type has to be compatible — which is why a module tends to share one error `choice` across its fallible functions. `?` is a real expression operator — it works **anywhere an expression can appear**, not just in a `let`. Use it in a `return`, as a call argument, or as a bare statement (where the unwrapped value is discarded but the error still propagates): ```es return ok(parse(raw)? + 1) // in a return write(parse(raw)?) // as an argument validate(input)? // bare statement — propagate on error, else continue ``` (One spelling to know: `result?.member` currently reads as the null-conditional `?.` operator, so to unwrap-then-chain you parenthesize — `(result?).member` — or use a `let`.) ## let-else guards When a value might be absent, a `let ... else` guard binds it or diverges: ```es let user = db.find(id) else { return error(.notFound) } // user is non-nil from here on ``` The `else` block must leave the scope (a `return`, `break`, etc.). ## Optionals vs. Result These are different tools: - `T?` — **optional presence**. "There might not be a value." Value types become `Nullable`; reference types stay as-is. - `Result` — **a fallible operation**. "This can fail, and here's *why* it failed." Use `T?` for "maybe there's a user"; use `Result` for "the lookup can fail with notFound / timeout / connectionFailed." ## try / catch at the boundary The BCL throws. When you call into it, catch at that seam and translate into your own model — then go back to `Result` internally. ```es func parsePort(s: string) -> Result { try { return ok(int.Parse(s)) } catch (FormatException e) { return error("bad port: {e.Message}") } } ``` There's no `finally` keyword — use [`defer`](/guide/control-flow/) inside the `try` for cleanup. A bare `catch { }` swallows anything when you don't need the exception value. The rule of thumb: **catch exceptions at the edge, pass values everywhere else.** ## Pointers & memory E# makes the value/reference distinction and the mutation story explicit, then gets out of your way. You rarely think about the heap — but when you need to share, recurse, or mutate through an alias, the tools are right there. ## The mutation triad: const / let / var Three levels of "can this change," from most to least frozen: ```es const MAX = 1024 // compile-time constant — folded to a literal at every use let name = "Ada" // runtime-immutable — computed once, never reassigned var total = 0 // mutable ``` `const` must fold to a literal at compile time (`const SUM = 10 + 20` is fine; `const NOW = DateTime.UtcNow` is not — use `let`). `let` is immutable at runtime. `var` reassigns. By convention `const` names are `SCREAMING_SNAKE_CASE`. [Browse `const` examples →](/examples/const/1/) ## Value by default A `data` value is copied on assignment and has no identity (see [Types](/guide/types/)). That's the default, and it's usually what you want — no aliasing surprises. When you *do* want sharing, recursion, or in-place mutation, you reach for a pointer. ## `*T` — the pointer `*T` is E#'s pointer, modeled on Go's: nullable, aliasing, and first-class (you can store it, return it, share it). It's how a value-shaped type reaches into recursive or shared flows. ```es data Node { value: int, next: *Node } // recursive shape needs the pointer func sum(head: *Node) -> int { var total = 0 var cur = head while cur != nil { total += cur.value // auto-deref — no explicit *cur cur = cur.next } return total } ``` The semantic is fixed; the **representation is the compiler's choice.** A whole-module escape analysis decides per binding: a pointer that never escapes the frame becomes a plain managed pointer (`ref T`) — zero allocation, aliasing the caller's storage directly; one that escapes or goes nullable gets a small heap wrapper so it can outlive the frame. A by-ref parameter that doesn't escape costs nothing. `*T` works for value `data` (any size) and primitives (`*int`). It does **not** apply to `ref data` — that's already a reference; pointing at it is meaningless. [Browse pointer examples →](/examples/pointers/1/) ## new vs. & — the clean seam This is worth holding onto: > **`new` allocates something that doesn't exist yet. `&` takes the address of something that > already does.** `new T { ... }` heap-allocates a value `data` and hands back a `*T`. It's the one allocation expression in the language, and the only way to mint a fresh pointer: ```es let n: *Node = new Node { value: 7, next: nil } let v: *Vec2 = new Vec2(3, 4) // positional form, for positional data ``` `&` only ever takes addresses — of a variable (`&x`), or of a function (`&func`): ```es var x = 10 var p = &x // address of an existing local → a pointer p += 5 // writes through it — x is now 15 ``` (`new` on a `ref data` is an error — it's already heap-allocated; construct it bare, `Connection { ... }`.) ## Passing by reference A `*T` parameter takes a pointer; at the call site, mark it with `&` or `*` so the mutation is visible to the reader: ```es func increment(counter: *int) { counter += 1 } var count = 0 increment(&count) // count is now 1 ``` For a large struct you only want to *read*, `readonly *T` is a zero-copy borrow (it emits as CLR `in T`) — you get the pointer's cheapness without granting mutation. And `out x: T` is the plain CLR `out` parameter, for the `Try…` pattern at the BCL boundary. ## with — non-destructive update Copy a value and overwrite a few fields, producing a new value — no mutation, no allocation: ```es let p1 = Point { x: 3, y: 4 } let p2 = p1 with { x: 10 } // p1.x == 3, p2.x == 10 ``` `with` is value-only — it's the idiomatic way to "change" an immutable `data`. ## Allocation, handled for you You don't hand-tune struct-vs-class. The compiler measures each `data` type and silently picks the CLR form — small/simple stays a struct, large/reference-heavy/heavily-copied becomes a class — while preserving the value contract. The one case it *won't* paper over is genuine recursion (`data Node { next: Node }`): that's physically impossible as a value type and is a hard error, with the fix (`*Node`) named in the message. [Browse allocation examples →](/examples/allocation/1/) ## Async & concurrency E# async has two properties that normally pull against each other — plus a separate concurrency axis: - **Uncolored by default** — suspension carries no `async` keyword and doesn't propagate up the call chain. - **Semi-colored by choice** — the *return type* lets you pick the async machinery at the function-declaration site, the way C# does — optional, and without touching the call site. - **Go-style concurrency** — channels, `select`, structured scopes (further down). All of it sits directly on `System.Threading` — nothing is hidden from you. ## Uncolored by default There is no `async` keyword. If a function uses `await`, the compiler makes it asynchronous — presence of `await` is the only signal. The declared return type is the **unwrapped value**; callers write against that value, and the awaitable is generated underneath. ```es func fetchUser(id: Guid) -> User { let response = await httpClient.GetAsync("/users/{id}") let json = await response.Content.ReadAsStringAsync() return parseUser(json) // returns User, not Task } func displayName(id: Guid) -> string { let user = await fetchUser(id) // await an E# async fn — unwraps to User return user.name // displayName isn't "colored" by fetchUser being async } ``` This is the half that Bob Nystrom's *"what color is your function?"* is about. In C#, `async` is a **color**: you write it at the declaration, every caller must `await`, and the async-ness propagates up the whole chain. In E# it doesn't — any function can `await`, `displayName` above is not marked or typed differently from a synchronous function, and you never thread `async`/`await` annotations up a call tree just because something deep down suspends. ## Semi-colored by choice Here's the other half. The return-type slot does double duty: normally it names the **value** (`User`); name the **machinery** instead and you've made a deliberate, *function-site* coloring decision — exactly where C# puts it — without the call site ever changing. ```es func fetchUser(id: Guid) -> User { ... } // ValueTask (default) func loadConfig() -> Task { ... } // Task — for a Task-typed slot func onClick(e: ClickEvent) -> void { ... } // async-void — an event handler func quotes(xs: List) -> IAsyncEnumerable { ... } // async stream ``` | Declared return | CLR shape | Builder | When | |---|---|---|---| | bare `T` / `ValueTask` | `ValueTask` | `AsyncValueTaskMethodBuilder` | default — no alloc on sync completion | | `-> Task` / `-> Task` | `Task` / `Task` | `AsyncTaskMethodBuilder` | a C# API/interface slot typed `Task` | | `-> void` (explicit) | `void` | `AsyncVoidMethodBuilder` | event handlers (fire-and-forget) | | `-> IAsyncEnumerable` + `yield` | `IAsyncEnumerable` | channel-backed | async streams | The **body is identical** across the first three — it just `await`s and returns the unwrapped value. Only the emitted wrapper changes, and the call site never does: `await`ing any of them unwraps to `T`. So **suspension stays uncolored, while the shape that crosses the boundary is a one-token, function-site choice.** Omit the machinery and you get the uncolored `ValueTask` default; name it when an interop boundary demands a particular shape. `-> void` is the one with a sharp edge: async-void is fire-and-forget, so an unobserved exception escapes to the synchronization context — reach for it only for event handlers. ### Async streams A function returning `IAsyncEnumerable` whose body `yield`s is an async stream — it can interleave `yield` (produce the next element) and `await` (suspend), and is consumed with `await foreach`: ```es func quotes(symbols: List) -> IAsyncEnumerable { for s in symbols { let q = await fetchQuote(s) // suspend yield q // produce } } func report() { await foreach q in quotes(["AAPL", "MSFT"]) { log("{q.symbol}: {q.price}") } } ``` (The stream is channel-backed — the producer runs one element ahead with backpressure — so it behaves like a pull-iterator without being a pure lazy one.) The whole BCL async surface is directly callable too — `await Task.Delay(1)`, `Task.Run(...)`, handing a `CancellationToken` to an API, consuming any `IAsyncEnumerable` — no ceremony. [Browse async examples →](/examples/async/1/) ## async let — concurrent bindings `async let` starts its initializer concurrently at the declaration; the first time you reference the binding, it's awaited. Swift-style structured fan-out, written against the unwrapped type. ```es async let aapl = fetchQuote("AAPL") async let msft = fetchQuote("MSFT") log("got {aapl.symbol}") // both fetches ran in parallel; awaits here log("got {msft.symbol}") ``` ## spawn & task func `spawn { ... }` runs a block as a job and hands back a `Job` handle: ```es let job = spawn { for event in ch { process(event) } } job.Wait() ``` `task func` is the function-shaped version — calling it *is* a spawn, returning a `Job` / `Job`: ```es task func produce() -> int { return 42 } let job = produce() let n = job.Wait() // 42 ``` Shared state crosses a spawn boundary through channels, not captured `var`s (capturing a mutable `var` across the boundary is an error — `let` captures are fine). ## Channels Typed, Go-style channels, backed by `System.Threading.Channels`: ```es let ch = chan(4) // bounded, capacity 4 let unbounded = chan() let producer = spawn { defer { ch.Close() } // close on the way out, however the block exits ch.Send(1) ch.Send(2) ch.Send(3) } var total = 0 for v in ch { // drains until the channel closes total += v } ``` ## select Wait on several channel operations at once (Go's `select`): ```es select { .recv(msg, requests) { handle(msg) } .send(reply, responses) { /* fires when responses has capacity */ } .timeout(500) { /* nothing was ready within 500ms */ } default { /* non-blocking: taken if nothing else is ready */ } } ``` If any recv/send arm is ready, one fires (with a fairness shuffle); without `default`, the select blocks until something completes or a `.timeout` elapses. ## Structured concurrency `TaskScope` owns its child tasks and channels, propagates cancellation in and out, and won't exit until every child has finished — so you don't leak tasks or forget to close a channel: ```es TaskScope.RunAsync(async scope => { let ch = scope.Chan(8) // auto-completed when the scope exits scope.Spawn(ct => produce(ch, ct)) // a child exception cancels siblings and rethrows scope.Defer(() => cleanup()) }) ``` Inside a `spawn` body, the job's cancellation token is threaded into `select` and channel iteration automatically, so a cancelled task unwinds in bounded time instead of hanging. ## Interop & delegates Interop is the soul of E#, not an afterthought. The language exists so you can bring a different shape into a .NET project without leaving the runtime — so this is where it pays off. ## E# types from C# E# compiles to standard assemblies, so a C# project just references the `.dll` and uses the types. There's no marker, no shim, no `[ESharpInterop]` — a C# consumer can't tell it wasn't C#. ```csharp // C# consuming an E# assembly var client = new Client { name = "Alice", age = 30 }; Console.WriteLine(client.describe()); var session = Auth.login(request, store, hasher, tokens); if (session.IsOk) Console.WriteLine(session.Value.token); ``` A `data` crosses as whatever CLR form the compiler chose (struct or class); a `ref data` is a sealed class; an `interface` is a CLR interface a C# class can implement with `: IFoo`; an `enum` is a real enum. If a `data`'s exact form matters to a caller, pin it with `[StackAlloc]` / `[HeapAlloc]`. ## C# types from E# The other direction is just as direct — name any .NET type, with or without a `using`: ```es using "System.Net.Http" func fetch(url: string) -> string { let client = HttpClient() return client.GetStringAsync(url).Result } ``` The compiler resolves a generous BCL surface on its own — properties, indexers, LINQ extension methods, `out` parameters, `params`, attributes, generic methods, `try`/`catch`/`throw`. Common namespaces (`System`, `System.Collections.Generic`, `System.Text`, …) are searched implicitly, so `Dictionary()`, `StringBuilder()`, and `FormatException` resolve with no `using`. **Optional parameters use their declared defaults.** Omit a trailing optional at a C# call site and the callee's *declared* default is supplied — not `default(T)`. This holds across BCL/reference methods, sibling `.cs` methods, instance methods, and constructors: ```es let sb = StringBuilder() let s = "a,b,c".Split(',') // omitted options arg → the method's declared default ``` [Browse interop examples →](/examples/interop/1/) ## One assembly, two languages The headline case: `.es` and `.cs` files compile **into a single assembly** with references flowing both ways. Drop both kinds in a directory and point the compiler at it — ```bash dotnet run --project src/Esharp.Cli -- compile-il ``` — the E# half emits IL through Mono.Cecil, Roslyn compiles the C# half, and ILRepack fuses both PEs into one DLL. A C# class can inherit an E# `ref data` and vice versa; both halves share internal visibility after the fusion. This is the JVM-style in-project polyglot the CLR was missing, and it's why E# can slot into an existing C# codebase a file at a time. ## using, static using, and aliases ```es using "System.Net.Http" // import a .NET namespace using "Geometry" // import an E# namespace (types + free funcs) using static "System.Math" // call Max(...) unqualified using SB = "System.Text.StringBuilder" // type alias ``` Importing an E# namespace brings both its types *and* its free functions into bare scope. An alias is the clean fix for a cross-namespace name collision — name the one you mean once and use the short form. ## Delegates E# has two callable tiers, picked by intent: - **Function pointer** — `&func`, zero-allocation, single-target, `ldftn` + `calli`. Hot paths, dispatch tables. - **Delegate** — heap-allocated, multicast. Framework interop, callbacks, events. A bare function name converts to a delegate when the target type is known — bound directly to the real method, so reflection and interop see the actual target: ```es func dbl(x: int) -> int = x * 2 let f: Func = dbl // method group → delegate let n = f(21) // 42 ``` ### Nominal delegates — delegate func `delegate func` mints a **nominal** delegate type — distinct from any structurally-identical `Func<>`, the same way E#'s interfaces are nominal. You can't pass a generic `Func` where a `BinOp` is meant by accident: ```es delegate func BinOp(a: int, b: int) -> int func add(a: int, b: int) -> int = a + b func apply(f: BinOp, a: int, b: int) -> int = f(a, b) let op: BinOp = add // method group → nominal delegate let r = apply(op, 20, 22) // 42 ``` The emitted type is exactly what C# emits for `delegate int BinOp(int, int)`, so it's usable across the assembly boundary in both directions. ## Events An event is a controlled subscription point over a delegate — declared field-style on `ref data` or `interface` (they imply identity, which value `data` doesn't have): ```es ref data Counter { var total: int event OnChanged: Action func add(n: int) { self.total = self.total + n raise OnChanged(self.total) // null-safe: a no-op with no subscribers } } let c = Counter { total: 0 } c.OnChanged += func(v) { log("now {v}") } ``` `raise` is null-safe by construction (it captures then invokes, so a handler unsubscribing mid-raise can't cause a null call). Subscribe/unsubscribe with `+=` / `-=`, on E#-declared and C#-declared events alike. The CLR shape is exactly what C# emits, so a C# consumer subscribes to an E# event — and E# subscribes to a C# event — with no glue. [Browse delegate & event examples →](/examples/delegates-events/1/) --- # Specification ## Specification This is the **normative** half of the docs. Where the [Guide](/guide/what-is-esharp/) is a narrative tour, the Specification is the reference you reach for when you need the exact rule — the keyword table, the resolution precedence, the IL a construct lowers to, the diagnostic a mistake triggers. Terse and tabular by design; the prose lives in the Guide. ## What is authoritative **The IL compiler is the language.** E# has two backends over one typed IR — the IL compiler (`.es` → Mono.Cecil → `.dll`) and a secondary transpiler (`.es` → C# → Roslyn). The IL compiler owns the semantics; when the two disagree, the IL compiler is correct and the transpiler is the bug. Every claim here is demonstrable. The [corpus](/examples/) is drawn from the language's own test suite and samples — passing test cases, showcases, and integration tests (some sizeable, multi-file) — and each entry earns its place: it compiles cleanly (or, for the negative cases, is rejected with exactly its expected diagnostic) and either produces its asserted output or stands as a real, well-formed program. The [Diagnostics catalog](/spec/diagnostics/) deep-links each error code to the negative examples that provoke it, so the corpus is browsable *by diagnostic*. ## Casing is significant E# uses initial case to carry the value/type distinction, which keeps the grammar unambiguous (a bare uppercase name is always a type, so `Foo { ... }` always reads as construction). | Kind | Casing | Enforced by | |---|---|---| | Types — `data`, `ref data`, `choice`, `ref choice`, `enum`, `interface`, `static func`, `delegate func` | **PascalCase** | [ES2160](/spec/diagnostics/#es2160) (hard error) | | Free functions | **camelCase** | [ES2161](/spec/diagnostics/#es2161) (hard error) | | Methods (first param is a `data` receiver) and `static func` members | PascalCase allowed (to match .NET) | — | | `const` | `SCREAMING_SNAKE_CASE` | convention only | ## Notation Grammar is given in EBNF, in the style of the Go specification: ```ebnf Production = production_name "=" [ Expression ] "." . Expression = Term { "|" Term } . Term = Factor { Factor } . Factor = production_name | token | "(" Expression ")" | "[" Expression "]" | "{" Expression "}" . ``` `[ x ]` is optional, `{ x }` is zero-or-more repetition, `( x )` groups, `a | b` alternates, `"x"` is a literal token, and `a … b` is a character range. Lower-case names are lexical (token) productions; upper-case names are syntactic. "It is an error if …" and "shall" introduce normative static-semantic rules, each cross-referenced to the [diagnostic](/spec/diagnostics/) it raises. ## Conformance A conforming program is one the **IL compiler** accepts and whose emitted assembly passes ILVerify. A program that violates a static-semantic rule is *ill-formed*; the compiler shall reject it with the named diagnostic. Behaviour the compiler accepts but this document does not describe is unspecified. ## The pages | Page | Covers | |---|---| | [Lexical structure](/spec/lexical/) | encoding, comments, identifiers, keyword tables, operators, literals, string interpolation | | [Names & resolution](/spec/names-and-resolution/) | namespaces, `using` forms, the 3-tier resolution precedence, ambiguity, per-file scope | | [CLR mapping](/spec/clr-mapping/) | the full E# → C# → IL lowering table | | [Diagnostics](/spec/diagnostics/) | every `ES####` code — trigger, fix, and the corpus examples that demonstrate it | More pages (types, inheritance, allocation & representation, functions, pointers & by-ref, expressions & statements, errors, concurrency, delegates & events, interop, limitations) extend the same normative treatment to the rest of the language. ## Status E# is **pre-alpha**: no LSP, no operator overloading, type inference only in trivial cases, a young `.esproj` build. The language is real and tested, but the surface still moves. Where a feature is absent or a C# convenience is missing, the relevant page says so plainly rather than dressing the gap as a design statement — see [Limitations & roadmap](/spec/limitations/). ## Lexical structure ## Comments Line comments only — `//` to end of line. There is no block-comment form. ```es // this is a comment ``` ## Identifiers ```ebnf identifier = ( letter | "_" ) { letter | digit | "_" } . letter = "A" … "Z" | "a" … "z" . digit = "0" … "9" . ``` A letter or underscore, followed by letters, digits, or underscores. Case-sensitive. **Initial case is significant by kind** — it carries the value/type distinction so the grammar stays unambiguous (a bare uppercase name is always a type, so `Foo { ... }` and `NS.Foo { ... }` always read as construction, never as a value's member-then-block): - **Types are PascalCase.** `data`, `ref data`, `choice`, `ref choice`, `enum`, `interface`, `static func`, and `delegate func` names must start uppercase. A lower-case type name is a hard error ([ES2160](/spec/diagnostics/#es2160)) — it would collide with value/local syntax and could not be constructed with `Name { ... }`. - **Free functions are camelCase.** A receiverless free function must start lowercase ([ES2161](/spec/diagnostics/#es2161)). Two exceptions may be PascalCase to match .NET convention: a **method** (first parameter is a `data` receiver, value or `*T`) and a **`static func` member** — neither is ever a bare name, so neither can be mistaken for a type. ## Keywords **Always reserved** — never usable as identifiers: | Group | Keywords | |---|---| | Control flow | `if` `else` `return` `while` `for` `in` `match` `default` `defer` `select` `break` `continue` | | Declarations | `namespace` `data` `func` `const` `let` `var` `enum` `choice` `interface` `using` `derive` `ref` `pub` `readonly` `with` | | Concurrency | `spawn` `chan` `await` | | Errors / boundary | `try` `catch` `throw` `out` `params` | | Operator words | `and` `or` `not` | | Constants | `true` `false` `nil` | **Contextual keywords** — matched by text in a specific position only; valid identifiers everywhere else (so `let static = 1` is legal): | Keyword | Reserved position | |---|---| | `static` `abstract` `open` `virtual` `task` `base` `returns` | declaration position | | `delegate` | before `func` at member scope — mints a nominal delegate type | | `event` | before `name :` in a `ref data` / `interface` body | | `raise` | before `EventName(` in statement position | | `new` | expression position, immediately before an upper-case type name followed by `{`, `(`, or `<` | | `init` | member position in a `ref data` body — a constructor | | `yield` | statement start inside an `IAsyncEnumerable` function | `new` is the sharpest case: it is recognized **only** before `Type{` / `Type(` / `Type<` in expression position (`new Point { x: 1 }`, `new Vec2(3, 4)`), and is an ordinary identifier everywhere else (`let new = 1` compiles). There is no `async` keyword — `await` alone makes a function asynchronous (see [Concurrency](/guide/concurrency/)). ## Operators | Category | Operators | |---|---| | Arithmetic | `+` `-` `*` `/` `%` | | Comparison | `==` `!=` `<` `>` `<=` `>=` | | Logical | `&&` `\|\|` `!` (or `and` `or` `not`) | | Compound assignment | `+=` `-=` `*=` `/=` | | Error propagation | `?` (postfix) | | Ternary | `? :` | | Null-coalescing | `??` | | Null-conditional | `?.` | | Range | `..` | | Index-from-end | `^` | | Heap construction | `new` (contextual keyword) | | Address-of | `&` | | By-ref pass (call site) | `*` / `&` | | Return type | `->` or `returns` | | Expression body | `=` (after the signature) | | Arrow lambda | `=>` | | Assignment | `=` | The postfix `?` (try-unwrap) is disambiguated from the ternary `?` by lookahead: if the next token can start an expression, it is a ternary. ## Literals ```ebnf int_lit = digit { digit | "_" } . float_lit = digit { digit | "_" } "." digit { digit | "_" } [ exponent ] | digit { digit | "_" } exponent . exponent = ( "e" | "E" ) [ "+" | "-" ] digit { digit } . string_lit = `"` { string_char | interpolation } `"` . char_lit = "'" ( char_char | escape ) "'" . bool_lit = "true" | "false" . nil_lit = "nil" . ``` | Type | Examples | |---|---| | Integer | `42` · `0` · `1_000_000` (underscore separators) | | Float | `3.14` · `0.5` · `1.0e10` | | String | `"hello"` · `"hello {name}"` (interpolated) | | Char | `'a'` · `'\n'` | | Boolean | `true` · `false` | | Null | `nil` | A leading `-` is the unary negation operator, not part of the literal. ## String interpolation ```ebnf interpolation = "{" Expr "}" . ``` No prefix required. `{ expr }` inside a string inserts the value of **any** expression — a variable, a member chain (`{x.field}`), an operator expression (`{a + b}`), a call (`{f(x)}`), a ternary (`{x > 0 ? "+" : "-"}`), an index (`{xs[0]}`). Each hole is handed to the expression parser and type-checked like any other expression; value types are boxed into the underlying `string.Concat` call. Braces nest, so object/collection literals inside a hole balance. **The hole rule:** a `{` opens a hole only when the next character can start an expression — a letter, `_`, `(`, or `!`. A leading digit is excluded, so `{0}` and `{0:d}` stay literal and BCL format strings pass through to `string.Format` unchanged. ```es let msg = "user {u.name} has {u.count} items" // holes let fmt = "progress: {0:p1}" // literal — passes to string.Format ``` ## Names & resolution ## Namespace declaration Every file begins with a namespace declaration. It emits as a `public static partial class` of the same name; top-level functions become static methods on it (unless promoted to instance methods, or nested in a `static func`). `partial` lets multiple files contribute to one namespace. ```es namespace Auth ``` The name may be **dotted** — nested namespaces in flattened form, as in C#: ```es namespace Acme.Billing.Invoicing ``` A `static func` / `data` / `enum` / `choice` emits into the full namespace under its own name (`Acme.Billing.Invoicing.Invoice`). Bare top-level functions land on the **module class**, named after the namespace's *last segment* (a CLR type name can't contain `.`): `namespace A.B.C` → module class `A.B.C.C`. ### Quoting A namespace **declaration** takes a bare, dotted identifier — never quoted: ```ebnf NamespaceDecl = "namespace" QualifiedName . // namespace Acme.Billing (no quotes) QualifiedName = identifier { "." identifier } . ``` A **`using`** (and `using static`, and an alias target) takes a **quoted string literal**, because its operand is an arbitrary external path the E# grammar does not otherwise parse as an identifier chain: ```es using "System.Net.Http" // import target — quoted using static "System.Math" // quoted using SB = "System.Text.StringBuilder" // alias target — quoted ``` In short: **declare unquoted, import quoted.** A qualifier *inside* code (`Acme.Billing.Invoice`, `Geometry.Point`) is likewise unquoted — quotes appear only on a `using` operand. ## Resolution is namespace-scoped Multiple namespaces compile into one assembly, but resolution follows C#, **not** a flat global registry: - **Same namespace → bare.** A type or free function in the current namespace (any file — `partial` spans files) is referenced by bare name. - **Cross namespace → import or qualify.** Reach a name from another namespace by importing it (`using "NS"`) or qualifying it (`NS.Type` in type position, `NS.fn(args)` in call position). - **A bare cross-namespace reference with neither is a hard error** — [ES2150](/spec/diagnostics/#es2150) for a type, [ES2152](/spec/diagnostics/#es2152) for a free function, each naming the namespace to import or qualify. ```es namespace Geometry data Point { x: int, y: int } namespace App using "Geometry" // Point now bare func go() -> int { let p = Point { x: 3, y: 4 } // bare — Geometry imported let q = Geometry.Point { x: 1, y: 2 } // qualified — works with or without the using return p.x + q.y } ``` ## The `using` forms | Form | Meaning | |---|---| | `using "System.Net.Http"` | import an **external** .NET namespace — name its types unqualified | | `using "Geometry"` | import an **internal E#** namespace — its types **and** free functions | | `using static "System.Math"` | import a type so its static methods are callable bare (`Max(2.5, 4.5)`) | | `using SB = "System.Text.StringBuilder"` | a **type alias** — `SB()` everywhere a bare type name is legal | For an **external** namespace, `using` emits as a C# `using` directive — it adds the directive, not the assembly reference (the consuming project must still reference the assembly). For an **internal E#** namespace, `using "Acme"` expands to **both** `using Acme` *and* `using static Acme.Acme` — implicitly, always. An E# namespace `Acme` compiles to a host static class *also* named `Acme` (so its module-level free functions live at `Acme.Acme.fn`); importing the namespace static-imports that host class in the same step. So `using "Acme"` brings the namespace's **types** and its **free functions** into bare scope together — `total(...)`, never `Acme.total(...)` and never the double-segment `Acme.Acme.total(...)`. This is what makes the `namespace`/host-class double-name (`Acme.Acme`) a non-issue from E#: you never write the doubled path, and you never hit a "which `Acme`?" resolution error, because the single `using "Acme"` has already pulled both the namespace and its static host into scope. (The double name is only visible to a C# consumer reaching in without the static import — see [CLR mapping](/spec/clr-mapping/).) A **type alias** is pure bind-time substitution (no runtime cost) and short-circuits the whole search — the aliased path is taken verbatim. It is the cleanest fix for a cross-namespace collision. ## Resolution precedence An unqualified type name resolves in a fixed precedence; each tier is searched across **all** loaded assemblies before the next is tried, so a match in one assembly never shadows a better-tier match in another: 1. **Exact / already-qualified** — a fully-qualified name (`System.Text.Json.JsonElement`) or an exact top-level type name. 2. **Explicit `using` imports** — namespaces brought in with `using "NS"`, in import order. Always win over the implicit set. 3. **Implicit standard namespaces** — a built-in set of common BCL namespaces (`System`, `System.Collections.Generic`, `System.Text`, `System.Threading`, … — see the [interop namespace-search list](/spec/clr-mapping/)), searched last, so `Dictionary<…>`, `StringBuilder`, and `FormatException` resolve with no `using`. A type alias short-circuits all three. The implicit tier can be dropped per-project with `disable` in the `.esproj`, after which only exact names, explicit `using`s, and aliases resolve. ## Ambiguity The same simple name may be declared in more than one namespace; the two are distinct CLR types and coexist in one assembly. A **bare** reference visible from two in-scope namespaces at once — the current namespace plus an import, or two imports — is **ambiguous** ([ES2151](/spec/diagnostics/#es2151)). Resolve by qualifying (`A.Widget`) or aliasing one (`using W = "A.Widget"`). The same rule applies to external BCL types: `Timer` under both `using "System.Threading"` and `using "System.Timers"` is ES2151 — the compiler will not silently bind whichever assembly the search hits first. ## Per-file scope, one assembly Multiple files may declare the same namespace (all emit into one partial class) or different namespaces (one assembly, C#-scoped resolution as above). **Each file's `using`s are scoped to that file** — a bare external name in file A resolves only through file A's imports, never file B's, even though both compile into one assembly. So file A's `using "System.Timers"` (`Timer` → `System.Timers.Timer`) and file B's `using "System.Threading"` (`Timer` → `System.Threading.Timer`) coexist with no cross-pollination. Both the binder and the IL backend enforce per-file scope. ## Declarations ## Compilation unit ```ebnf SourceFile = NamespaceDecl { Using } { Declaration } . NamespaceDecl = "namespace" QualifiedName . QualifiedName = identifier { "." identifier } . Using = "using" string_lit | "using" "static" string_lit | "using" identifier "=" string_lit . Declaration = [ "pub" ] ( DataDecl | RefDataDecl | ChoiceDecl | RefChoiceDecl | EnumDecl | InterfaceDecl | DelegateFuncDecl | StaticFuncDecl | FuncDecl | ConstDecl | DeriveDecl ) . ``` Every source file begins with exactly one `NamespaceDecl`. Name resolution and the semantics of `Using` are specified in [Names & resolution](/spec/names-and-resolution/). A declaration is *internal* unless prefixed with `pub`. ## Types ```ebnf Type = QualifiedName [ TypeArgs ] [ "?" ] // named type, optional generic args, optional nullable | "*" Type // pointer | "readonly" "*" Type // read-only by-ref (parameter position) | "(" TypeList ")" // tuple | FuncPtrType . FuncPtrType = "&" "(" [ TypeList "->" ] Type ")" . // &(int, int -> int) , &(-> bool) TypeArgs = "<" TypeList ">" . TypeList = Type { "," Type } . ``` A type name in declaration position shall be PascalCase ([ES2160](/spec/diagnostics/#es2160)). `*T` is a [pointer](/spec/pointers/); `*RefData` is ill-formed ([ES2003](/spec/diagnostics/#es2003)). `T?` denotes an optional (see [Types → nullable](/guide/types/#nullable-t)). ## data ```ebnf DataDecl = [ "readonly" ] "data" TypeName [ Generics ] ( "{" [ FieldList ] "}" | "(" [ ParamList ] ")" ) . FieldList = Field { ( "," | newline ) Field } . Field = [ "let" | "var" | "pub" ] identifier ":" Type [ "=" Expr ] | [ "pub" ] [ "*" ] TypeName . // embedded (anonymous) field Generics = "<" identifier { "," identifier } ">" . ``` A `data` introduces a **value type**: assignment copies it, and two values are equal iff their fields are equal. The representation (CLR struct or class) is implementation-defined and unobservable ([Allocation](/spec/clr-mapping/)). The following are ill-formed: - a field whose type contains the enclosing type by value — [ES2002](/spec/diagnostics/#es2002); break the cycle with `*T`. - an `init` block — [ES3012](/spec/diagnostics/#es3012); construct with a composite literal or factory. `readonly data` makes every field immutable and emits `[IsReadOnly]`. The positional form `data T(params)` adds positional construction. An embedded field promotes the embedded type's members to the enclosing type. Generic type parameters are reified. ## ref data ```ebnf RefDataDecl = [ "open" | "abstract" ] "ref" "data" TypeName [ Generics ] [ ":" BaseList ] "{" { Member } "}" . BaseList = TypeName { "," TypeName } . // base class, if any, is first Member = Field | Init | Method | EventDecl | ConstDecl | ReturnsClause . Init = "init" "(" [ ParamList ] ")" [ ":" "base" "(" [ ArgList ] ")" ] Block . Method = [ "virtual" | "abstract" | ":" ] "func" identifier "(" [ ParamList ] ")" [ ReturnType ] ( Block | "=" Expr | ε ) . ReturnsClause = "returns" Type . // class-level default return ``` A `ref data` is a CLR class (identity, reference equality). It is **sealed by default** — emitted as a `sealed` class, with no modifier to write; `open` makes it inheritable, `abstract` makes it non-instantiable and inheritable. `open` is the only shape that is *both* instantiable and inheritable; E#'s OO stance is that a class is **either `abstract` or sealed**, so `open` is slated to become an explicit `.esproj` opt-in, disabled by default. Field defaults run before the `init` body. Inheritance — the member forms, the `: func` role inference, `: base(...)`, and the ES2120–2128 diagnostics — is specified in the guide page [Inheritance](/guide/inheritance/). `EventDecl` is specified in [Delegates & events](/spec/delegates-events/). ## choice / ref choice ```ebnf ChoiceDecl = "choice" TypeName [ Generics ] "{" { Case } "}" . RefChoiceDecl = "ref" "choice" TypeName [ Generics ] "{" { Case } "}" . Case = identifier [ "(" ParamList ")" ] . ``` A `choice` is a tagged union — a value is exactly one case, each with zero or more payload fields. A value `choice` emits as a tag enum plus a struct (always a struct). A `ref choice` emits an abstract base with one sealed subclass per case; the per-case CLR type is `Outer_case`. Generic choice is reified. Cases are constructed by factory (`T.case(args)`) or dot-case shorthand (`.case(args)`) and consumed by [`match`](/spec/statements/#match). ## enum ```ebnf EnumDecl = "enum" TypeName "{" { EnumCase } "}" . EnumCase = identifier [ "=" int_lit ] . ``` Emits as a CLR `System.Enum` with `int32` underlying type. A case without an explicit value takes the previous value + 1 (the first defaults to 0). Cases are constructed with a trailing `()` (`Dir.north()`). ## interface ```ebnf InterfaceDecl = "interface" TypeName [ Generics ] "{" { InterfaceMember } "}" . InterfaceMember = "func" identifier "(" [ ParamList ] ")" [ ReturnType ] | EventDecl . ``` Emits as a CLR interface. Conformance is **nominal**: a type conforms only if it names the interface after `:`, and the match is exact (name, parameter types, return type). A type that would satisfy an undeclared interface raises [ES2153](/spec/diagnostics/#es2153). Where only the pointer method set conforms, the `__Ptr_T` wrapper implements the interface (see [Pointers](/spec/pointers/)). ## Functions, static func, delegate func ```ebnf FuncDecl = "func" identifier [ Generics ] "(" [ ParamList ] ")" [ ReturnType ] ( Block | "=" Expr ) . ReturnType = ( "->" | "returns" ) Type . ParamList = Param { "," Param } . Param = [ "out" ] [ "readonly" ] identifier ":" Type | identifier ":" "*" Type . StaticFuncDecl = "static" "func" TypeName "{" { StaticMember } "}" . StaticMember = ConstDecl | "let" identifier [ ":" Type ] "=" Expr | "var" identifier [ ":" Type ] "=" Expr | FuncDecl | ReturnsClause . DelegateFuncDecl = "delegate" "func" TypeName "(" [ ParamList ] ")" [ ReturnType ] . ``` A free function's name shall be camelCase ([ES2161](/spec/diagnostics/#es2161)); a method (first parameter a `data` receiver) and a `static func` member may be PascalCase. A function whose first parameter is an E#-declared `data` value is promoted to a method on that type and shall be called as `recv.f(...)`; calling it free is [ES2142](/spec/diagnostics/#es2142). Promotion, by-ref/`out` parameters, function pointers, and the `returns` default-return clause are specified in [Functions](/spec/functions/) and [Pointers & by-ref](/spec/pointers/). A `static func` body shall contain only fields, `const`, and functions; a bare statement is [ES1010](/spec/diagnostics/#es1010). A `delegate func` mints a nominal delegate type ([Delegates & events](/spec/delegates-events/)). ## const and derive ```ebnf ConstDecl = "const" identifier [ ":" Type ] "=" Expr . DeriveDecl = "derive" identifier { "," identifier } . // precedes a data declaration ``` A `const` initializer shall fold to a compile-time literal; otherwise [ES1011](/spec/diagnostics/#es1011) (use `let`). `const` is valid at namespace, `static func`, `ref data`, and function-body scope. `derive` generates members at compile time: `equality` emits `Equals` / `GetHashCode` / `==` / `!=`; `debug` emits `ToString()`. ## Expressions ## Precedence From tightest to loosest binding. All binary operators are left-associative except `??` (right) and the ternary `? :`. | Level | Operators | |---|---| | primary | literals · names · `(…)` · `f(…)` · `.member` · `[index]` · `T { … }` · `new T { … }` · `.case(…)` | | postfix | `expr?` (try-unwrap) · `?.member` (null-conditional) · `with { … }` | | unary | `!` `not` · unary `-` · `&` (address-of) · `*` (deref / by-ref) | | multiplicative | `*` `/` `%` | | additive | `+` `-` | | range | `..` | | comparison | `<` `<=` `>` `>=` | | equality | `==` `!=` | | logical and | `&&` `and` | | logical or | `\|\|` `or` | | null-coalescing | `??` | | ternary | `? :` | (Assignment and compound assignment are [statements](/spec/statements/), not expressions.) ## Grammar ```ebnf Expr = Coalesce [ "?" Expr ":" Expr ] . // ternary Coalesce = OrExpr { "??" OrExpr } . OrExpr = AndExpr { ( "||" | "or" ) AndExpr } . AndExpr = Equality { ( "&&" | "and" ) Equality } . Equality = Comparison { ( "==" | "!=" ) Comparison } . Comparison = Range { ( "<" | "<=" | ">" | ">=" ) Range } . Range = Additive [ ".." Additive ] . Additive = Multiplicative { ( "+" | "-" ) Multiplicative } . Multiplicative = Unary { ( "*" | "/" | "%" ) Unary } . Unary = ( "!" | "not" | "-" | "&" | "*" ) Unary | Postfix . Postfix = Primary { Selector } . Selector = "." identifier // member access | "(" [ ArgList ] ")" // call | "<" TypeList ">" "(" [ ArgList ] ")" // generic call | "[" Expr "]" // index | "?" // try-unwrap | "?." identifier // null-conditional | "with" "{" FieldInitList "}" . // non-destructive update Primary = literal | identifier | "(" Expr { "," Expr } ")" // parenthesised / tuple | CompositeLit | NewExpr | ListLit | DotCase | Lambda | MatchExpr | "ok" "(" Expr ")" | "error" "(" Expr ")" | "await" Unary | "spawn" Block . CompositeLit = TypeName [ TypeArgs ] "{" [ FieldInitList ] "}" . FieldInitList = FieldInit { ( "," | newline ) FieldInit } . FieldInit = identifier ":" Expr . NewExpr = "new" TypeName ( "{" [ FieldInitList ] "}" | "(" [ ArgList ] ")" ) . ListLit = "[" [ Expr { "," Expr } ] "]" . DotCase = "." identifier [ "(" [ ArgList ] ")" ] . Lambda = "func" "(" [ ParamList ] ")" [ ReturnType ] ( Block | "=" Expr ) | "(" [ identifier { "," identifier } ] ")" "=>" Expr . ArgList = Arg { "," Arg } . Arg = [ "out" | "&" | "*" ] Expr . ``` ## Semantics (selected) **Try-unwrap `expr?`.** If `expr` is a `Result`, `?` yields the `ok` value or returns the `error` from the enclosing function. It is an expression operator — valid anywhere an expression appears (a `let`, a `return`, a call argument, a bare statement). The enclosing function's error type shall be compatible. The spelling `expr?.member` parses as the null-conditional operator; to unwrap-then-access, parenthesise (`(expr?).member`) or bind with a `let`. See [Errors](/spec/errors/). **Ternary vs. try-unwrap.** `?` is disambiguated by lookahead: if the next token can begin an expression, `?` is the ternary operator; otherwise it is postfix try-unwrap. **Null-coalescing `a ?? b`** yields `a` if non-null, else `b`. **Null-conditional `a?.m`** yields `a.m` if `a` is non-null, else null/default; it chains (`a?.b?.c`). **Composite literal `T { f: v }`** constructs a value of type `T`; field initializers are comma- or newline-separated. **`new T { … }` / `new T(…)`** heap-allocates a value `data` and yields `*T` — the only allocation expression; `new` on a non-`data` type is [ES2144](/spec/diagnostics/#es2144), on a `ref data` is [ES2003](/spec/diagnostics/#es2003). **Address-of `&x`** yields a managed pointer to a variable, or a function pointer for a function name; **`*x`** / **`&x`** at a call site pass by reference. See [Pointers & by-ref](/spec/pointers/). **`.case` / `ok` / `error`** construct a [choice](/spec/declarations/#choice--ref-choice) variant or a `Result` side when the target type is known from context. **Collection literal `[a, b]`** constructs a `List` with `T` inferred from the elements; `[]` is `List`. A parenthesised comma list `(a, b)` constructs a `ValueTuple`. **Lambdas.** `func(…) -> T { … }` and the arrow form `(x) => expr` are function literals; arrow-parameter types are inferred when a delegate type is expected. Both close over the enclosing scope; captures are mutable, and a closure over a `let` may read but not write it. **`match` as an expression** appears in any expression position; every arm produces a value of one common type. Its grammar is given with the [statement form](/spec/statements/#match). ## Statements ## Grammar ```ebnf Block = "{" { Statement } "}" . Statement = Binding | Assignment | If | While | For | Match | Defer | Return | Break | Continue | Try | Raise | ExprStmt . Binding = ( "let" | "var" ) BindTarget [ ":" Type ] "=" Expr | "let" BindTarget "=" Expr "else" Block // let-else | "async" "let" identifier [ ":" Type ] "=" Expr | ConstDecl . BindTarget = identifier | "(" identifier { "," identifier } ")" . // tuple destructure Assignment = Lvalue ( "=" | "+=" | "-=" | "*=" | "/=" ) Expr . Lvalue = identifier { "." identifier | "[" Expr "]" } . If = "if" Expr Block { "else" "if" Expr Block } [ "else" Block ] . While = "while" Expr Block . For = "for" BindTarget "in" Expr Block . Defer = "defer" Block . Return = "return" [ Expr ] . Try = "try" Block CatchClause { CatchClause } . CatchClause = "catch" [ "(" Type [ identifier ] ")" ] Block . Raise = "raise" identifier "(" [ ArgList ] ")" . ExprStmt = Expr . ``` Conditions take no parentheses; braces are mandatory on every block. ## Bindings & mutation `let` binds an immutable name; `var` a mutable one; `const` a compile-time literal (folding rules and [ES1011](/spec/diagnostics/#es1011) in [Declarations](/spec/declarations/#const-and-derive)). Immutability of `let` is enforced by the compiler, not the CLR. A binding may destructure a tuple: `let (a, b) = pair`. `async let` starts its initializer concurrently and is awaited at first reference; its initializer shall be a call or awaitable ([ES3005](/spec/diagnostics/#es3005)), and a sync user-function initializer is auto-wrapped in `Task.Run` with [ES3004](/spec/diagnostics/#es3004). Assignment targets are locals, parameters, member chains, and index expressions. ## let-else ```es let user = db.find(id) else { return error(.notFound) } ``` If the initializer is `nil`, the `else` block runs and shall leave the scope (`return`, `break`, …); after the statement the bound name is non-nil. ## Control flow `for … in` iterates collections, ranges (`0..n`), and channels. A `for` target may destructure a tuple (`for (k, v) in entries`). `defer` runs its block on scope exit, LIFO; it lowers to `try`/`finally` and is the cleanup mechanism (there is no `finally` keyword). ## match ```ebnf Match = "match" ( Expr | "(" Expr ":" Type ")" ) "{" { Arm } "}" . Arm = Pattern Block | Pattern Expr . // statement body or expression body Pattern = DotCase [ "(" [ Binding { "," Binding } ] ")" ] // choice / enum case | literal // int / string / bool literal pattern | "default" . ``` `match` dispatches over a `choice`, `ref choice`, `enum`, or literal value. The type annotation `(expr: T)` is required only when the scrutinee's static type is ambiguous (e.g. a value flowing through `object`, or an enum reached via dot-case); otherwise the bare form suffices. - **Destructuring.** A case arm binds payloads positionally (`.message(lvl, txt)`); a value-`choice` arm may instead bind a single **case-view** name whose members are the payloads (`.pair(p)` → `p.a`, `p.b`). For a single-payload case the view is *transparent* — the binding doubles as the payload value. A `ref choice` arm matches with an `isinst` type pattern. - **Literal patterns** (`int`, `string`, `bool`) match by value; exhaustiveness does not apply to them, so `default` handles the open set. - **Exhaustiveness.** A `match` over a `choice` / `ref choice` / `enum` that omits a variant is warned; `default` suppresses it. - **As an expression.** `match` in expression position requires every arm to yield one common type (see [Expressions](/spec/expressions/)). ## return and definite return A non-void function shall return on every path; a fall-through is [ES2140](/spec/diagnostics/#es2140). The analysis is exhaustive-match-aware: an `if`/`else` whose arms all return, or an exhaustive `match` whose arms all terminate, counts as returning — no redundant trailing `return` is required. `return`, `throw`, and an infinite loop with no `break` are terminators. ## try / catch / throw `try`/`catch` is the BCL boundary mechanism; in-language flow uses [`Result`](/spec/errors/). Three catch shapes are accepted: ```es catch (FormatException e) { ... } // typed + bound catch (Exception e) { ... } // base type + bound catch { ... } // bare — any exception, no binding ``` There is no `finally` (use `defer` inside the `try`). `throw` with no operand rethrows, and is valid only inside a `catch`. ## raise `raise Name(args)` fires the field-style event `Name` declared on the enclosing `ref data`; it is null-safe (a capture-then-invoke lowering) and a no-op with no subscribers. `raise` on an undeclared event is [ES2142](/spec/diagnostics/#es2142). See [Delegates & events](/spec/delegates-events/). ## Functions Function declaration grammar is given in [Declarations](/spec/declarations/#functions-static-func-delegate-func). ## Instance-method promotion A function whose first parameter is an **E#-declared `data`** (value or `*T`) is promoted to a method on that type. Promotion is by-attachment across files; it does not apply to `choice`, `enum`, primitives, or external/C# types. The call shape depends on the receiver kind: | Receiver | Free call `f(x)` | Method call `x.f()` | In method set of | |---|---|---|---| | value `func f(x: T)` | ill-formed — [ES2142](/spec/diagnostics/#es2142) | required | `T` and `*T` | | pointer `func f(x: *T)` | valid | valid | `*T` only | A value-receiver method has no static host: it is reachable wherever its receiver type is in scope, regardless of declaring namespace. A pointer-receiver function remains a namespace-scoped free function that *also* joins `*T`'s method set. A function with a `readonly *T` first parameter is **not** promoted (a value-type `this` is always mutable). ## returns clause ```ebnf ReturnType = ( "->" | "returns" ) Type . ReturnsClause = "returns" Type . // class-level, inside ref data / static func ``` `returns T` is a synonym for `-> T` in a signature. As a standalone clause inside a `ref data` or `static func` body it sets the **default return type** for member functions that omit their own annotation; an explicit `-> T` on a member overrides it. ## Method chaining A promoted call chains when a method returns a value the next call lands on. A method returning its receiver yields a fluent API; for a `ref data` this returns the same instance (mutation threads through), for a value `data` a fresh value each step. A chain may break across lines with a **leading dot** — a newline before `.` continues the chain. A method returning `Result` does not chain; unwrap each step with `?`. ## Lambdas and closures ```ebnf Lambda = "func" "(" [ ParamList ] ")" [ ReturnType ] ( Block | "=" Expr ) | "(" [ identifier { "," identifier } ] ")" "=>" Expr . ``` A function literal closes over the enclosing scope. Captures are mutable — a write inside the closure is visible outside and vice versa; a closure over a `let` binding may read but not assign it (compiler- enforced). Arrow-lambda parameter types are inferred when a delegate type is expected at the call site. Captured variables are hoisted into a generated display class shared by the outer scope and all closures over those captures. ## Function pointers ```ebnf FuncPtrType = "&" "(" [ TypeList "->" ] Type ")" . // &(int, int -> int) , &(string -> void) , &(-> bool) ``` `&f` takes a function's address — zero allocation, single-target, emitted as `ldftn` + `calli`. A function-pointer type is first-class (struct fields, parameters, locals). The binder verifies signature compatibility at the call site. Function pointers are the systems tier; heap-allocated, multicast delegates are the interop tier — see [Delegates & events](/spec/delegates-events/). The disambiguation between `&f` (function pointer) and `&x` (address-of a variable) is by what the name resolves to; see [Pointers & by-ref](/spec/pointers/). ## Pointers & by-ref ## `*T` `*T` is E#'s pointer: nullable, aliasing, and first-class (storable, returnable, shareable). It applies to value `data` (any size) and primitives (`*int`); `*RefData` is ill-formed ([ES2003](/spec/diagnostics/#es2003)) — a `ref data` is already a reference. Member access through a `*T` auto-dereferences. **Representation is implementation-defined.** A whole-module escape analysis chooses per binding: | Condition | Representation | |---|---| | escapes the frame (returned, stored, captured) or is nullable | `__Ptr_T` — a heap reference cell shared by every holder | | provably neither | a managed pointer `ref T` — zero allocation, aliases the caller's storage | Conversions between the two forms are inserted automatically where they meet at a call. Neither is observable from source. ## new vs. & ```ebnf NewExpr = "new" TypeName ( "{" [ FieldInitList ] "}" | "(" [ ArgList ] ")" ) . ``` `new T { … }` heap-allocates a value `data` and yields a fresh `*T` — the only allocation expression, and the only way to mint a fresh pointer. `new` on a non-`data` is [ES2144](/spec/diagnostics/#es2144). The deprecated `&T { … }` spelling warns [ES2143](/spec/diagnostics/#es2143). `&` otherwise only takes addresses: **`new` allocates something that does not yet exist; `&` takes the address of something that does.** ## The managed-pointer foundation The CLR has one underlying by-ref primitive, the **managed pointer** `T&` (`ByReferenceType`). `ref`, `out`, and `in` are the *same* IL type, distinguished only by parameter metadata. E#'s by-ref family maps onto it: | Form | CLR emission | Direction | Deref | Call site | |---|---|---|---|---| | `x: T` | `T` | in (by value) | — | `f(x)` | | `x: *T` | `ref T` or `__Ptr_T` | in / out | explicit | `f(&x)` / `f(*x)` | | `x: readonly *T` | `in T` (`[In]`) | in (zero-copy) | explicit, read-only | `f(&x)` | | `out x: T` | `[Out] T&` | out | implicit | `f(out x)` | A `*T` parameter emits `ref T`; both `&expr` and `*expr` at the call site pass by reference. `readonly *T` is a zero-copy read-only borrow (`in T`) — assigning through it is a binder error, and such a first parameter is not promoted. `out x: T` is the C# `out` shape (`[Out] T&`): assignment writes through the slot, reads load through it, and it interoperates one-to-one with C# `out`. Definite assignment of `out` is a documented obligation, not yet a hard error. ## Address-of and ref locals `&name` yields a managed pointer to a local, parameter, or field (`ldloca`/`ldarga`/`ldflda`); if `name` resolves to a function it is instead a [function pointer](/spec/functions/#function-pointers). A local initialized from `&expr` becomes a **ref local** (a `ByReferenceType` variable); reads and writes through it transparently dereference. Managed pointers are GC-tracked, cannot dangle, and cannot escape the frame. ## Method sets and interface conformance `*T` has its own method set: value-receiver functions (`func f(x: T)`) are in both `T`'s and `*T`'s sets; pointer-receiver functions (`func f(x: *T)`) are in `*T`'s set only. When a declared interface is satisfied only by the pointer method set, the generated `__Ptr_T` wrapper implements the interface and forwards to the underlying functions — so `*T` flows through interface-typed parameters without repeatedly boxing the value. The wrapper is generated only when a `*T` is actually used as an interface. ## Errors E# treats errors as values. In-language flow uses `Result` and `?`; `try`/`catch` is reserved for the BCL boundary. ## Result<T, E> `Result` is a built-in type: either `ok(value)` or `error(value)`. The error type is user-chosen, commonly a `choice`. Inspect it with `.IsOk` / `.IsError`, `.Value` / `.Error`, or the combinators `.Map`, `.MapErr`, `.Bind`, `.Match`, `.Inspect`, `.InspectErr`, `.UnwrapOr`, `.UnwrapOrElse`, `.Unwrap`, `.UnwrapErr`. The constructors `ok(...)` / `error(...)` are expressions; inside `error(...)` the `.case` dot-shorthand resolves against a known error type. ## The `?` operator `expr?` unwraps a `Result`: it yields the `ok` value, or returns the `error` from the enclosing function. It is a real expression operator, valid anywhere an expression appears: ```es let user = findUser(id)? // in a let return ok(parse(raw)? + 1) // in a return write(parse(raw)?) // as an argument validate(input)? // bare statement — propagate on error, else continue ``` The enclosing function's error type shall be compatible with the propagated error; this is why a module tends to share one error `choice`. The spelling `expr?.member` is parsed as the null-conditional operator, not unwrap-then-access; parenthesise (`(expr?).member`) or bind with a `let`. ## Optionals vs. Result | Tool | Meaning | |---|---| | `T?` | optional presence — "there might not be a value" | | `Result` | a fallible operation — "this can fail, and here is why" | See [Types → nullable](/guide/types/#nullable-t). ## let-else A `let … else` guard binds a value or diverges; the `else` block shall leave the scope. Grammar and rules are in [Statements](/spec/statements/#let-else). ## try / catch boundary The BCL throws; catch at that seam and translate into a `Result`, then return to value-based flow. There is no `finally` — use [`defer`](/spec/statements/#control-flow) inside the `try`. `throw` with no operand rethrows and is valid only inside a `catch`. The three catch shapes and grammar are in [Statements → try / catch / throw](/spec/statements/#try--catch--throw). The rule of thumb: catch exceptions at the edge, pass values everywhere else. ## Concurrency ## Grammar ```ebnf Await = "await" Unary . AsyncLet = "async" "let" identifier [ ":" Type ] "=" Expr . Yield = "yield" Expr . Spawn = "spawn" Block . // expression → Job TaskFunc = "task" "func" identifier "(" [ ParamList ] ")" [ ReturnType ] Block . Select = "select" "{" { SelectArm } "}" . SelectArm = ".recv" "(" identifier "," Expr ")" Block | ".send" "(" Expr "," Expr ")" Block | ".timeout" "(" Expr ")" Block | "default" Block . ``` `chan(n)` is a construction expression yielding `Chan`. `await foreach … in …` consumes an async stream. `spawn`, `chan`, `await` are reserved; `task` and `yield` are contextual. ## Uncolored async A function is asynchronous iff its body contains `await` — there is no `async` keyword, and asyncness does not propagate up the call chain. The declared return type is the **unwrapped value**; the awaitable is generated. The return type selects the builder ("semi-coloring"): | Declared return | CLR return | Builder | |---|---|---| | bare `T` / `ValueTask` | `ValueTask` (default) | `AsyncValueTaskMethodBuilder` | | `-> Task` / `-> Task` | `Task` / `Task` | `AsyncTaskMethodBuilder` | | `-> void` (explicit) | `void` (async-void) | `AsyncVoidMethodBuilder` | | `-> IAsyncEnumerable` + `yield` | `IAsyncEnumerable` | channel-backed | The body is identical across the first three; only the wrapper changes, and the call site never does. Explicit `-> void` is async-void (event handlers) and carries the unobserved-exception caveat. ## Async streams A function declared `-> IAsyncEnumerable` whose body uses `yield` is an async stream; it may interleave `yield e` (produce) and `await` (suspend), and is consumed with `await foreach`. The lowering is channel-backed (a capacity-1 `Chan` plus a producer task): it gives backpressure, cancellation on early consumer exit, and producer-exception propagation, and runs one element ahead (not a pure lazy pull). A `yield` outside such a function is [ES2131](/spec/diagnostics/#es2131). ## async let `async let name = init` starts `init` concurrently at the declaration; the first textual reference awaits it (Swift-style fan-out, written against the unwrapped type). The initializer shall be a call or awaitable ([ES3005](/spec/diagnostics/#es3005)); a sync user-function initializer is auto-wrapped in `Task.Run` with [ES3004](/spec/diagnostics/#es3004). Lowering happens before either backend sees the tree. ## spawn / task func `spawn { … }` runs a block as a job, yielding a `Job`. `task func f()` makes the call site a spawn: calling `f()` runs the body as a task and returns `Job` / `Job`. A function literal inside a `task func` body shall not capture a `var` from the surrounding scope ([ES2130](/spec/diagnostics/#es2130)); thread shared state through `chan` parameters. `let` captures are permitted. ## Channels and select `chan(n)` constructs a bounded channel (unbounded if `n` omitted), backed by `System.Threading.Channels`. `for v in ch` drains until the channel completes. `select` waits on multiple channel operations: a ready `.recv`/`.send` arm fires (fairness shuffle across ready arms); `default` is held back on the non-blocking pass so a ready operation always wins; without `default`, `select` blocks until an operation completes or a `.timeout` elapses. Inside a `spawn` body the job's cancellation token is threaded into `select` and channel iteration, so a cancelled task unwinds in bounded time. ## Structured concurrency — TaskScope `TaskScope` owns child tasks and channels, propagates cancellation in and out, and does not exit until every child completes; a child's first exception cancels its siblings and is rethrown on exit. ## Stdlib types | Type | Key members | |---|---| | `Job` | `Cancel()` · `Wait()` · `WaitAsync() -> ValueTask` · `AsTask()` | | `Job` | `Wait() -> T` · `WaitAsync() -> ValueTask` · `AsTask()` · `Cancel()` | | `Chan` | `Send` · `SendAsync` · `ReceiveAsync` · `TrySend` · `TryReceive` · `Complete`/`Close` · `for..in` / `await foreach` | | `TaskScope` | `RunAsync(...)` · `Spawn(ct => …)` · `Token` · `Chan(n)` (auto-completed) · `Defer(() => …)` | Prefer `scope.Chan(n)` for auto-completion on scope exit. The language-level `spawn { }` currently lowers to `Job.Spawn`; a scope-aware lowering is future work. ## Delegates & events E# has two callable tiers, chosen by intent. Function pointers are specified in [Functions](/spec/functions/#function-pointers); this page covers delegates and events. | Tier | Form | CLR | Cost | |---|---|---|---| | function pointer | `&f`, type `&(int, int -> int)` | `ldftn` + `calli` | zero-alloc, single-target | | delegate | `Func`/`Action`/`EventHandler`, `delegate func`, lambdas | `MulticastDelegate` subclass | heap, GC, multicast | ## Method-group conversion A bare function name where a delegate type is expected converts to that delegate, bound directly to the real method (no synthesized forwarder, so reflection sees the actual target): ```es func dbl(x: int) -> int = x * 2 let f: Func = dbl // ldnull; ldftn dbl; newobj Func`2::.ctor ``` It fires **only when the target delegate type is known** — a typed parameter, a typed `let`, a return type, or an event. An un-annotated `let f = dbl` is an error (ambiguous: delegate or function pointer?); write the delegate type, or `&dbl` for a pointer. It works for any delegate type, including bridging to a nominally distinct BCL delegate (`let p: Predicate = isEven`). Lambdas convert the same way, with parameter types inferred from the target's `Invoke` signature. ## Nominal delegate types — delegate func ```ebnf DelegateFuncDecl = "delegate" "func" TypeName "(" [ ParamList ] ")" [ ReturnType ] . ``` `delegate func Name(...)` mints a **nominal** delegate type — a sealed `MulticastDelegate` subclass, distinct from any structurally-identical `Func<>`. The emitted type is exactly what C# emits for `delegate R Name(...)`, so it crosses the assembly boundary both ways. A `Func` is **not** a `BinOp` even though both wrap `(int) -> int` — the same nominal philosophy as E#'s interfaces. `delegate` is contextual (only before `func` at member scope). ## Events ```ebnf EventDecl = "event" identifier ":" Type . // Type shall be a delegate ``` An event is a member — a controlled subscription point over a delegate. Events are declared field-style on **`ref data`** or **`interface`** only (they imply identity); an event on a value `data` is [ES2140](/spec/diagnostics/#es2140). The type after `:` shall be a delegate, else [ES2141](/spec/diagnostics/#es2141). `event` is contextual (only before `name :` in a type body). **Raise.** `raise Name(args)` fires the event; it lowers to a thread-safe capture-then-invoke and is null-safe (a no-op with no subscribers). `raise` naming an event not declared on the enclosing `ref data` is [ES2142](/spec/diagnostics/#es2142). `raise` is contextual (the event name between `raise` and `(` distinguishes it from a call). **Subscribe / unsubscribe** with `+=` / `-=`, on E#-declared and external (C#) events alike. The emitted CLR shape is exactly what C# emits for a field-style event — backing field, `add_`/`remove_` accessors (lock-free `Delegate.Combine`/`Remove` + `Interlocked.CompareExchange`), and an `EventDefinition` — so a C# consumer subscribes with no glue, and E# subscribes to C# events the same way. ## CLR mapping E# is a first-class CLR citizen: every construct lowers to ordinary metadata and IL, indistinguishable from what C# emits. This is that lowering, end to end. The **IL** column is what the primary backend emits; the **C#** column is the equivalent a reader (or the secondary transpiler) would write. ## Types & members | E# | C# | IL | |---|---|---| | `namespace Foo` | `public static partial class Foo` | static class holding namespace methods | | `data Point { x: int, y: int }` | `struct Point` **or** `sealed class Point` (compiler's choice) | value type **or** reference type — value-semantic contract preserved either way | | `pub data Point { ... }` | public variant of the above | public variant | | `readonly data R { ... }` | `readonly struct R` (+ generated equality) | `ValueType` + `[IsReadOnly]` | | `let field: T` | `readonly T field` | `initonly` field | | `expr with { f: v }` | IIFE copy + assign | `ldobj` + `stfld` | | `ref data Config { ... }` | `sealed partial class Config` | sealed class | | `open ref data Foo` | `class Foo` (not sealed) | inheritable class | | `abstract ref data Foo` | `abstract class Foo` | abstract class | | `choice Error { ... }` | tag enum + `partial struct` with factories | ValueType + tag enum | | `ref choice Expr { ... }` | abstract base + sealed subclass per case | abstract class + sealed subclasses | | `enum Direction { ... }` | `public enum Direction` | `System.Enum` (int32) | | `interface IDrawable { ... }` | `public interface IDrawable` | interface | | `delegate func BinOp(...)` | `delegate int BinOp(int, int)` | sealed `MulticastDelegate` subclass | | `static func Foo { ... }` | `public static partial class Foo` (sibling to the namespace class) | static class: const/static fields + static methods | | `T?` (value type) | `Nullable` | `System.Nullable` | | `T?` (ref type) | `T?` annotation | same reference type | | `nil` (value context) | `default(Nullable)` | `initobj Nullable` | | `[Serializable]` | `[Serializable]` | CLR custom attribute | ## Methods, inheritance & constructors | E# | C# | IL | |---|---|---| | `func add(a: int, b: int) -> int` | `public static int add(int a, int b)` | `call` (direct) | | `func describe(p: Point) -> string` | instance method on `Point` | instance `call` | | `func move(p: *Point, dx: int)` | `static void move(ref Point p, int dx)` | managed pointer `&` | | `func f() -> T = expr` | `T f() { return expr; }` | expression-body desugar | | `virtual func name(...)` | `public virtual T name(...)` | `Virtual` + `NewSlot` | | `abstract func name(...)` | `public abstract T name(...)` | `Virtual` + `NewSlot` + `Abstract`, no body | | `: func name(...)` (override of `virtual`) | `public override T name(...)` | `Virtual` (ReuseSlot) — same vtable slot | | `: func name(...)` (fulfill of `abstract`) | `public override T name(...)` | `Virtual` (ReuseSlot) | | `init(args) { body }` on `ref data` | parameterized constructor | `.ctor` with args | | `init(args) : base(b)` | `: base(b)` chain | `.ctor` with explicit `call BaseType::.ctor` | | `init(...)` on `data` | — | [ES3012](/spec/diagnostics/#es3012): use composite literal / factory | | `returns T` clause | default return type for nested `func`s missing `-> T` | — | ## Control flow, errors & match | E# | C# | IL | |---|---|---| | `let x = 42` | `var x = 42;` (immutable by E#) | `stloc` | | `var x = 0` | `var x = 0;` | `stloc` | | `a ? b : c` | `a ? b : c` | conditional branch | | `x ?? y` | `x ?? y` | null check + branch | | `x?.Member` | `x?.Member` | null-conditional access | | `match x { .a { } }` | `switch (x.Tag)` | IL `switch` (jump table) | | `match x { .a(v1, v2) { } }` | multi-field destructure | field loads after tag check | | `match x { .a(v) { } }` (ref choice) | `is` type pattern | `isinst` + field extraction | | `let x = f()?` | unwrap with early error return | conditional branch | | `let x = f() else { return }` | null guard, early return | `brfalse` | | `defer { f() }` | `try { ... } finally { f(); }` | exception handler block | | `"hello {name}"` | `$"hello {name}"` | `String.Concat` (value types boxed) | ## Pointers, delegates & literals | E# | C# | IL | |---|---|---| | `&funcName` | `delegate*<...>` | `ldftn` + `calli` | | `&varName` | `ref varName` | `ldloca` / `ldarga` / `ldflda` | | `var p = &x` | `ref var p = ref x` | `ByReferenceType` local | | `&(int, int -> int)` | `delegate*` | `FunctionPointerType` | | `x: *T` param | `ref T` | managed pointer | | `readonly *T` param | `in T` | `ByReferenceType` + `[In]` | | `out x: T` param | `out T` | `[Out] T&` | | `[1, 2, 3]` | `new List { 1, 2, 3 }` | `List` + `Add` | | `(a, b)` | `new ValueTuple(a, b)` | `System.ValueTuple` | | `let (a, b) = expr` | temp + `.Item1`/`.Item2` | field extraction | | `derive equality` | `Equals` / `GetHashCode` / `==` / `!=` | generated methods | | `derive debug` | `ToString()` | generated method | ## Concurrency & interop | E# | C# | IL | |---|---|---| | `await expr` | `await expr` | `IAsyncStateMachine` struct | | `spawn { ... }` | `Job.Spawn(_ => { ... })` | `Task.Run` | | `chan(n)` | `new Chan(n)` | `Channel.CreateBounded(n)` | | `task func name() -> T` | `static Job name()` → `Job.Spawn(__inner)` | `Esharp.Stdlib.Job` | | `List()` | `new List()` | `newobj List`1::.ctor` | | `Dictionary` | `Dictionary` | `GenericInstanceType` | | `using static "System.Math"` | `using static System.Math;` | static type import | | `data Foo(x: int)` | positional sugar | fields + positional construction | ## Implicit BCL namespace search These namespaces are searched for an unqualified type name as the **last** resolution tier (after exact names and explicit `using`s — see [Names & resolution](/spec/names-and-resolution/)), so `Dictionary<…>`, `StringBuilder`, `ObservableCollection`, and `FormatException` resolve with no `using`: ``` System System.Linq System.Collections.Generic System.Diagnostics System.Collections.ObjectModel System.Timers System.Collections.Specialized System.ComponentModel System.Text System.Threading System.Text.Json System.Threading.Tasks System.Text.Json.Serialization System.Threading.Channels System.IO ``` Disable the whole tier with `disable`, after which only explicitly imported namespaces resolve. ## Limitations & roadmap E# is **pre-alpha**. The language is real and tested — every assembly the harness emits passes ILVerify — but the surface still moves. This page states the gaps normatively rather than implying completeness. ## Not implemented - **No type inference** beyond trivial cases — types must be annotated or trivially resolved. - **No operator overloading.** - **No stable IDE / LSP yet.** A syntax-highlighting extension exists, and a language server is in progress on a branch — likely to be rewritten in E# itself (dogfooding) before it lands. - **No flow analysis** — no dead-code detection, unused-variable warnings, or definite-assignment enforcement for `out` parameters (the rule is documented but not yet a hard error). - **No escape-analysis surfacing** — `--show-alloc` style diagnostics are planned, not present. ## Unsupported constructs and workarounds | Construct | Status | Workaround | |---|---|---| | `async` keyword | n/a by design | uncolored — `await` promotes the function; the return type selects the shape | | explicit struct layout `@offset` | not a keyword | `[StructLayout(LayoutKind.Explicit)]` + `[FieldOffset(N)]` | | `ref` returns (`-> *T`) | unsupported | return a wrapper struct | | `await` of a bare non-generic `ValueTask` | emits bad IL | call `.AsTask()` and await the `Task` | | external generic type in a non-referenced BCL assembly | may resolve to `object` | reference the assembly, or use `Chan` (special-cased) | | `for..in` over `chan` (closed generic, user element) | limited | a Cecil limitation; mirrors the pre-`ChanOps` dispatch gap | | `ref choice` elements in `chan` | limited | the subclass-ctor call path doesn't resolve | | function literal that captures-and-returns inside an async state machine | limited | the lambda return value doesn't propagate at IL level | ## Mixed `.es` + `.cs` — known gaps `.es` and `.cs` fuse into one assembly with bidirectional references. Still limited: - **Cross-language method-impl bridge** — `data Foo : ICSharpInterface` plus a promoted `func describe(f: Foo)` writes the `InterfaceImplementation` metadata but not yet the body forwarder. - **Choice-from-C#** — C# reads the discriminator and payload accessors but pattern-matches with a C# `switch`, not E# `match` (by design). - **Generic constraints across the boundary** — simple cases work; nested/numeric-constrained generics may surface gaps. ## Planned (near-term) - **Local type inference** via `:=` — `x := expr` declares a local and infers its type from the initializer (annotation-free local binding), plus generic-argument inference at call sites. - **Operator overloading** for numeric types. - Auto by-ref parameter passing for large structs (`in` insertion at call sites). - `task func` **parameters** (currently thread shared state through channel parameters). - `github/linguist` registration of E# (so `.es` is not mislabeled as ECMAScript at the source level). --- # Roadmap — design in flight The sections below are **proposals**: designed and argued against the compiler, but **not committed** — shapes will move and some may drop. The substantial sections are the firm, load-bearing direction; the short list at the end is sketched in passing. ## Union types — `choice` grows up The largest item — and the one where today's spec is already strong, so it's worth being precise about the baseline. **Today.** E# has two union kinds, and they already do a lot (see [Types](/guide/types/#choice--tagged-unions)): - **value `choice`** — a tag + payload struct with factory methods, dot-case shorthand, multi-payload cases, and **reified generics** (`Option` is a real closed generic struct, not erased to `object`). Always a struct. - **`ref choice`** — an abstract base with a sealed subclass per case (`Outer_case`), for recursive / polymorphic shapes (ASTs, trees); it carries identity and a shared base, and `match` dispatches via `isinst`. - **`match`** over either is exhaustiveness-checked, usable as an expression, and already supports multi-payload positional binding and the transparent single-payload **case view**. What a `choice` **cannot** do today: carry its own **methods** (instance-method promotion is `data`-only), **conform to an interface**, hold a case that *is* an existing type, or be written inline as `A | B`. And the value-`choice` layout is naive — `SequentialLayout` carrying *every* case's payload at once (a 5-case choice is as wide as all five payloads combined). **The direction** closes exactly those gaps, making `choice` the one union primitive — tagged, discriminated, and pseudo-anonymous, that also carries members and conforms to interfaces. **Members & methods on a `choice`.** In-body methods, plus instance-method promotion extended to `choice` receivers — so a free `func area(s: Shape)` attaches as `shape.area()`, the same attachment `data` gets today: ```es choice Shape : IShape { Circle, Square func area() -> int = match self { // in-body method satisfies IShape.area() .Circle(c) { c.r * c.r * 3 } .Square(s) { s.s * s.s } } } ``` **Interface conformance (nominal).** A `choice : I` conforms two ways: **own methods** (in-body or promoted), or **auto-forward** — when every member already conforms, the compiler synthesizes the `match`-and-dispatch: ```es data Circle : IShape { r: int } data Square : IShape { s: int } choice Shape : IShape { Circle, Square } // verified: each member : IShape → IShape forwarded, no bodies ``` A value `choice` **boxes** at the interface boundary — so conformance is "potentially not by direct dispatch"; reach for `ref choice` when it's hot. Conformance stays nominal and exact (consistent with the shipped `data`/`ref data` rule). **Type-member cases** — a case that *is* an existing type (your `data`/`ref data`, or an external CLR type), mixable with inline cases: ```es choice Event { Click(MouseEvent), key(code: int), closed } // type-member + inline + payload-less ``` **Inline `A | B`** in any type position, desugaring to an anonymous `choice` — the pseudo-anonymous form: ```es func format(v: int | string | bool) -> string = match v { .int(n) { "n={n}" } .string(s) { s } .bool(b) { b ? "on" : "off" } } ``` **The headline — composable error sets.** Two functions with different error types compose under `?` with no wrapper `choice` and no `.MapErr`, because `?` widens each error into the declared set (an explicit `into` / `derive convert` covers genuine cross-type conversions): ```es func load(id: Guid) -> Result { let row = dbFind(id)? // DbError widens into the set let prof = netFetch(url)? // NetError widens in too return ok(build(row, prof)) } ``` It earns the name with a real **layout** — overlapped (not summed) payloads, niche-filling when a payload is a nullable ref or `*T`, tagless for ref-only unions — **common fields** shared across value-`choice` cases (a `ref choice` already gets this today through its base class), and a doubling as a **generic type-set bound** (`func max(…)`). ## Pattern matching Pulled along by the union work, and **already half-landed** (transparent single-payload case views ship today). The rest is field-level binding, so an arm reads in domain terms instead of accessor noise: ```es match o { .limit { side, qty, price } { qty > 0 && price > 0.0 } // not .limit(l), then l.qty … .market { side, qty } { qty > 0 } } ``` Plus positional deconstruct (`.point(x, y)`), guards (`.Circle(c) if c.r > 100`), and or-patterns (`.Circle | .Square`). Field patterns are pure sugar — identical IL to the whole-value-plus-`.field` arm. ## Colorless async The uncolored half **already ships** (see [Concurrency](/spec/concurrency/)): there is no `async` keyword, `await` alone makes a function async, the declared return type picks the machinery (`ValueTask` default · `Task` / `Task` · async-`void` · `IAsyncEnumerable` streams), and `async let` runs bindings concurrently and awaits at first use. So async is uncolored *save for the return type* today. The proposal completes it at the **synchronous boundary** — the corner `async`/`await` omits. Today a value/`void`-returning async function is awaited from an async caller; the proposal makes it **callable from a sync caller** with no ceremony, as a *force-on-use future*: the call starts eagerly and overlaps the caller's following work, and blocks only at the **first use** of its result. A function returning an explicit async type (`Task`, `ValueTask`, `IAsyncEnumerable`) still must be awaited or handled — no silent sync-over-async. ```es func work() -> int { // a sync function — no await of its own let a = fetch() // uncolored async call — starts now, work() runs on doStuff() // fetch() overlaps this return a + 1 // first use → join: read if ready, block only on the remainder } ``` | caller | spelling | start | join at first use | thread | |---|---|---|---|---| | async | `async let a = f()` *(today)* | eager | `await` (suspend) | released | | sync | `let a = f()` *(proposed)* | eager | block (remainder only) | held | The return type stays the only knob: value/`void` is the caller's choice (auto-bridged at the sync join); an async type is yours to handle. It buys overlap *without* coloring — paying a parked thread at the join rather than propagating color up the call chain — uncolored for CLI / app code, colored when a server is trying not to park threads. The **sync-join half is proposed, not implemented**; the uncolored-`await` and return-shape halves already ship. ## Constructor parity — the `init` surface **Today.** Construction already differs by kind, and the value side is well covered: - A **value `data`** is built with a **composite literal** `Point { x: 1, y: 2 }` (fields comma- or newline-separated), an optional **positional form** (`data Vec2(x, y)` → `Vec2(3, 4)`), or a **factory function**. `with { … }` does non-destructive update, `readonly data` / `let` fields control mutability, and a `data` has **no constructor** at all — an `init` block on it is [ES3012](/spec/diagnostics/#es3012). - A **`ref data`** is built with an **`init(args)`** block (a real `.ctor`), with **`: base(args)`** chaining to a parent ([ES2128](/spec/diagnostics/#es2128) on mismatch) and **field defaults** that run before the body; methods live in the body, and a composite literal works too. What's missing today is on the `ref data` side: effectively **one** constructor — no overloading, no `: this` delegation, no `required` fields (an omitted field silently defaults), no `Deconstruct`, no sub-public constructor visibility (ctors are pub/internal only), and no default / named arguments. **The direction** brings the `ref data` construction surface to C# parity — the 1 way today → 5–6 principled birth-shapes, contained to `ref data`: - **Overloaded `init`** — multiple blocks distinguished by signature (exact-match resolution; ambiguity is an error, no C#-style "better conversion" ranking). - **`: this(...)` delegation** — a secondary `init` chains to a sibling (the dual of today's `: base(...)`). - **Default + named arguments** — `connect("localhost", useTls: false)`; the main "vary one input" tool, so most cases need no overload. E# materializes defaults at the call site, and also emits `[Optional]` / `.param` so a **C# caller** sees them. - **`required` fields** — a composite literal must supply them; omission becomes an error, emitted with `[RequiredMember]` for C# interop. - **`Deconstruct`** — the inverse of positional construction, so `let (a, b) = point` works from E# **and** C# (today only tuples destructure, via `.ItemN`). - **Sub-public constructor visibility** — `private` / `protected` constructors, for factory-enforced or base-only construction. It dovetails with DI: a **single-ctor** `ref data` is unambiguous for `ActivatorUtilities`, so overloading is opt-in for types that genuinely have distinct birth shapes — a registered service stays single-ctor (or annotates `[ActivatorUtilitiesConstructor]`). ## Primary-constructor capture The bigger ergonomic win, separate from the parity batch: a `ref data` declares its construction parameters in a **header**, and any parameter used in a method body is **captured** — the compiler synthesizes the backing field, with no field declaration and no `self.x = x`: ```es ref data UserService(store: IUserStore, cache: ICache, maxRetries: int) { func lookup(id: Guid) -> Result { let hit = cache.get(id) // captured — a field is synthesized because it is used here if hit != nil { return ok(hit) } return store.find(id) } } ``` Capture is **on-use**: a header parameter referenced only in `init` / field defaults stays a plain parameter and produces **no** field (no courier). Synthesized fields are `let` and non-public; the header *is* the primary constructor, and an explicit `init` becomes a secondary that delegates with `: this(...)`. Constructor-injected dependencies — the single largest source of boilerplate — collapse from three mentions to one. (Value `data` keeps its positional `data Vec2(x, y)` DTO form, deliberately distinct.) ## Also in flight Firmer but smaller, in passing: - **Dependency injection** — first-class `Microsoft.Extensions.DependencyInjection`: services are `ref data` with `init(deps)`, interface registration rides nominal conformance, no E# container. - **Leaner concurrency stdlib** — `Job` retired; `task func` returns `Task`; the stdlib keeps only what the BCL lacks (`Result`, `select`, `TaskScope`). - **Newline-insignificant parameter & argument lists** — a newline separates like a comma inside `( … )`. - **More auto-derives** — `order` / `hash` / `json` / `convert` via a user-extensible provider, plus a `must_use` warning on a discarded `Result`. - **C#-facing extension methods** — a non-escaping pointer-receiver function emitted with `[Extension]`, so a C# consumer calls `v.Bump()` instead of `Host.bump(ref v)`. - **`open` as an `.esproj` opt-in** — E#'s OO stance is that a class is **either `abstract` or sealed**; `open ref data` (both instantiable *and* inheritable) is the deliberate exception, so it becomes an explicit project setting, disabled by default — explicitness over habit. (Earlier and rougher — `impl Trait` opaque returns, typestate-style markers — are parked.) ## Cadence The corpus is the contract, and it grows fast — the working target is **~500–1,000 new tests per week**, more when the work shifts to focused, dogfooded programs. E# is increasingly written in E#: the corpus extractor that produced the published [corpus](/examples/) is an E# program, and the language server is being rewritten in it. The corpus and this specification track that growth. --- # Compiler & contributing The E# compiler — the lexer, binder, the Mono.Cecil IL backend, the C# transpiler, and the standard library (stdlib) — is the language. While E# is in **active development**, that source lives in a **private repository**. The surface still moves week to week, and keeping the compiler private during this phase lets the design change without breaking people who'd otherwise be building against a moving target. What *is* public is the [corpus](/examples/): a large, growing set of `.es` programs drawn straight from the language's own **test suite and samples** — including integration tests, some of them sizeable multi-file programs. These are not illustrative sketches; they're the exact programs the compiler is held to. Every entry is one of three things: a **passing test case**, a **sample or integration test**, or a **compilable program** that builds to a real executable. Each one earns its place: - It **compiles cleanly** — or, for the negative cases, fails with exactly the **expected error or diagnostic** (deliberate ill-formed syntax exists in the corpus precisely to pin down what the compiler must reject, and it's verified as rejected the right way). - It **produces its expected output** — a positive test asserts a known-good result, so the program's behaviour is verified, not just its compilation — or, where there's no asserted output, it's verified to be a **real, well-formed program** rather than filler or accidental garbage. The corpus is the compiler's actual contract, made public. It's public precisely because it's the easy thing to make public — no build secrets, no in-flight design, no half-finished backend. The compiler that produces it is the part still under the knife. ## Requesting access If you'd like to read or build the compiler, **message me on GitHub** — [@khayzz13](https://github.com/khayzz13) — and I'll send you access. There's no form and no waitlist; it's a private repo, not a closed one. Researchers, prospective contributors, and the merely curious are all welcome to ask. ## Contributing — soon, and tests first I would love contributors. As the project opens up, the **first and most valuable contribution will be tests** — `.es` programs that exercise corners of the language, pin down behaviour, and grow the corpus that the whole specification is anchored to. The corpus is the contract; every test that lands makes the contract sharper. The plan is to set up a clear path for people to **generate and submit tests**, and — importantly — to keep contributed tests in a **separate folder that remains the contributor's own copyrighted work**, cleanly partitioned from the core compiler maintenance and the work I do on the language itself. Your tests stay yours; they ride alongside the project without being absorbed into it. That separation is the point: it keeps contribution low-friction and unambiguous about ownership. Compiler-internals contribution — the binder, the IL emitter, diagnostics — will follow once the test-contribution path is established and the surface settles. For now, if you want to help, the best way is to **ask for access, write programs, and break things**. --- # Examples ## ILEmitterTests2__Enum_ExplicitValues_CorrectConstants (enum, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_ExplicitValues_CorrectConstants topic: enum status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test enum Priority { low = 1 medium = 5 high = 10 } func test() -> int { return 0 } ``` ## ILEmitterTests2__Enum_MixedAutoAndExplicit (enum, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_MixedAutoAndExplicit topic: enum status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test enum Level { a b = 10 c } func test() -> int { return 0 } ``` ## ILEmitterTests2__Enum_Match_BasicDispatch (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_Match_BasicDispatch topic: choice status: verified // verified behavior: Test.test(...) == "g" namespace Test enum Color { red green blue } func describe(c: Color) -> string { match (c: Color) { .red { return "r" } .green { return "g" } .blue { return "b" } default { return "?" } } } func test() -> string { return describe(Color.green()) } ``` ## ILEmitterTests2__Enum_Match_WithDefault (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_Match_WithDefault topic: choice status: verified // verified behavior: Test.test(...) == "other" namespace Test enum Size { small medium large } func label(s: Size) -> string { match (s: Size) { .small { return "S" } default { return "other" } } } func test() -> string { return label(Size.large()) } ``` ## ILEmitterTests2__Enum_Match_ExplicitValues_Dispatch (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_Match_ExplicitValues_Dispatch topic: choice status: verified // verified behavior: Test.test(...) == "warn" namespace Test enum Code { ok = 0 warn = 10 fail = 20 } func name(c: Code) -> string { match (c: Code) { .ok { return "ok" } .warn { return "warn" } .fail { return "fail" } default { return "?" } } } func test() -> string { return name(Code.warn()) } ``` ## ILEmitterTests2__Literal_Match_Int (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Literal_Match_Int topic: choice status: verified // verified behavior: Test.test(...) == "two" namespace Test func describe(n: int) -> string { match n { 1 { return "one" } 2 { return "two" } 3 { return "three" } default { return "other" } } } func test() -> string { return describe(2) } ``` ## ILEmitterTests2__Literal_Match_Int_Default (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Literal_Match_Int_Default topic: choice status: verified // verified behavior: Test.test(...) == "other" namespace Test func describe(n: int) -> string { match n { 1 { return "one" } default { return "other" } } } func test() -> string { return describe(99) } ``` ## ILEmitterTests2__Literal_Match_String (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Literal_Match_String topic: choice status: verified // verified behavior: Test.test(...) == "hola" namespace Test func greet(lang: string) -> string { match lang { "en" { return "hello" } "es" { return "hola" } "fr" { return "bonjour" } default { return "hi" } } } func test() -> string { return greet("es") } ``` ## ILEmitterTests2__Literal_Match_Bool (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Literal_Match_Bool topic: choice status: verified // verified behavior: Test.test(...) == "no" namespace Test func label(b: bool) -> string { match b { true { return "yes" } false { return "no" } default { return "?" } } } func test() -> string { return label(false) } ``` ## ILEmitterTests2__Literal_Match_NegativeInt (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Literal_Match_NegativeInt topic: choice status: verified // verified behavior: Test.test(...) == "neg" namespace Test func sign(n: int) -> string { match n { -1 { return "neg" } 0 { return "zero" } 1 { return "pos" } default { return "other" } } } func test() -> string { return sign(-1) } ``` ## ILEmitterTests2__Match_Expression_IntLiteral (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_IntLiteral topic: choice status: verified // verified behavior: Test.test(...) == "two" namespace Test func test() -> string { let x = match 2 { 1 { "one" } 2 { "two" } default { "other" } } return x } ``` ## ILEmitterTests2__Match_Expression_Enum (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_Enum topic: choice status: verified // verified behavior: Test.test(...) == "N" namespace Test enum Dir { north south } func test() -> string { let d = Dir.north() let name = match (d: Dir) { .north { "N" } .south { "S" } default { "?" } } return name } ``` ## ILEmitterTests2__Match_Expression_ExpressionBody (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_ExpressionBody topic: choice status: verified // verified behavior: Test.test(...) == "two" namespace Test func label(n: int) -> string = match n { 1 { "one" } 2 { "two" } default { "?" } } func test() -> string { return label(2) } ``` ## ILEmitterTests2__Match_Expression_Choice (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_Choice topic: choice status: verified // verified behavior: Test.test(...) == 42 namespace Test choice Option { some(value: int) none } func unwrap(o: Option) -> int { let v = match o { .some(x) { x } .none { 0 } } return v } func test() -> int { return unwrap(Option.some(42)) } ``` ## ILEmitterTests2__Match_Expression_StringLiteral (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_StringLiteral topic: choice status: verified // verified behavior: Test.test(...) == "hola" namespace Test func greet(lang: string) -> string = match lang { "en" { "hello" } "es" { "hola" } default { "hi" } } func test() -> string { return greet("es") } ``` ## ILEmitterTests2__Enum_ExplicitValues_MatchExpression (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_ExplicitValues_MatchExpression topic: choice status: verified // verified behavior: Test.test(...) == "H" namespace Test enum Priority { low = 1 medium = 5 high = 10 } func label(p: Priority) -> string { match (p: Priority) { .low { return "L" } .medium { return "M" } .high { return "H" } default { return "?" } } } func test() -> string { return label(Priority.high()) } ``` ## ILEmitterTests2__Enum_StoredInLocal_ThenPassedToFunc (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_StoredInLocal_ThenPassedToFunc topic: choice status: verified // verified behavior: Test.test(...) == "S" namespace Test enum Dir { north south } func label(d: Dir) -> string { match (d: Dir) { .north { return "N" } .south { return "S" } default { return "?" } } } func test() -> string { let d = Dir.south() return label(d) } ``` ## ILEmitterTests2__Match_Expression_ChoiceString (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_ChoiceString topic: choice status: verified // verified behavior: Test.test(...) == "ok" namespace Test choice Result { ok(value: int) err(message: string) } func unwrap(r: Result) -> string = match r { .ok(v) { "ok" } .err(msg) { "err" } default { "?" } } func test() -> string { return unwrap(Result.ok(42)) } ``` ## ILEmitterTests2__Match_Expression_InlineLetAssignment (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_InlineLetAssignment topic: choice status: verified // verified behavior: Test.test(...) == "seven" namespace Test func test() -> string { let x = 7 let tag = match x { 1 { "one" } 7 { "seven" } default { "other" } } return tag } ``` ## ILEmitterTests2__Sample_MatchPatterns_Full (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Sample_MatchPatterns_Full topic: choice status: verified // verified behavior: Test.test(...) == "medium,hola,CRIT,ok,seven,negative" namespace Test func levelName(n: int) -> string = match n { 1 { "low" } 2 { "medium" } 3 { "high" } default { "unknown" } } func greet(lang: string) -> string = match lang { "en" { "hello" } "es" { "hola" } "fr" { "bonjour" } default { "hi" } } enum Priority { low = 1 medium = 5 high = 10 critical = 100 } func priorityLabel(p: Priority) -> string { match (p: Priority) { .low { return "LOW" } .medium { return "MED" } .high { return "HIGH" } .critical { return "CRIT" } default { return "?" } } } choice Result { ok(value: int) err(message: string) } func unwrap(r: Result) -> string = match r { .ok(v) { "ok" } .err(msg) { "err" } default { "?" } } enum Color { red green = 10 blue } func test() -> string { let a = levelName(2) let b = greet("es") let c = priorityLabel(Priority.critical()) let d = unwrap(Result.ok(42)) let x = 7 let tag = match x { 1 { "one" } 7 { "seven" } default { "other" } } let n = -1 let sign = match n { -1 { "negative" } 0 { "zero" } 1 { "positive" } default { "other" } } return "{a},{b},{c},{d},{tag},{sign}" } ``` ## ILEmitterTests2__Match_ExpressionBody_ResultInInterpolation (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_ExpressionBody_ResultInInterpolation topic: choice status: verified // verified behavior: Test.test(...) == "level: medium" namespace Test func levelName(n: int) -> string = match n { 1 { "low" } 2 { "medium" } default { "?" } } func test() -> string { let name = levelName(2) return "level: {name}" } ``` ## ILEmitterTests2__Match_Expression_NegativeLiteral (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Match_Expression_NegativeLiteral topic: choice status: verified // verified behavior: Test.test(...) == "neg" namespace Test func sign(n: int) -> string = match n { -1 { "neg" } 0 { "zero" } 1 { "pos" } default { "other" } } func test() -> string { return sign(-1) } ``` ## ILEmitterTests2__Float_Add_Double (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Float_Add_Double topic: core status: verified // verified behavior: Test.test(...) == 3.5 namespace Test func test(a: double, b: double) -> double = a + b ``` ## ILEmitterTests2__Float_Sub_Double (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Float_Sub_Double topic: core status: verified // verified behavior: Test.test(...) == 0.75 namespace Test func test(a: double, b: double) -> double = a - b ``` ## ILEmitterTests2__Float_Mul_Double (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Float_Mul_Double topic: core status: verified // verified behavior: Test.test(...) == 6.0 namespace Test func test(a: double, b: double) -> double = a * b ``` ## ILEmitterTests2__Float_Div_Double (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Float_Div_Double topic: core status: verified // verified behavior: Test.test(...) == 2.5 namespace Test func test(a: double, b: double) -> double = a / b ``` ## ILEmitterTests2__Modulo_Zero_Result (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Modulo_Zero_Result topic: core status: verified // verified behavior: Test.test(...) == 0 namespace Test func test(a: int, b: int) -> int = a % b ``` ## ILEmitterTests2__Break_From_Inner_Of_Nested_Loops (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Break_From_Inner_Of_Nested_Loops topic: core status: verified // verified behavior: Test.test(...) == 6 namespace Test func test() -> int { var outer = 0 var i = 0 while i < 3 { var j = 0 while j < 10 { if j == 2 { break } outer = outer + 1 j = j + 1 } i = i + 1 } return outer } ``` ## ILEmitterTests2__Continue_From_Inner_Of_Nested_Loops (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Continue_From_Inner_Of_Nested_Loops topic: core status: verified // verified behavior: Test.test(...) == 9 namespace Test func test() -> int { var total = 0 var i = 0 while i < 3 { var j = 0 while j < 4 { j = j + 1 if j == 2 { continue } total = total + 1 } i = i + 1 } return total } ``` ## ILEmitterTests2__Defer_LIFO_Ordering (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Defer_LIFO_Ordering topic: core status: verified // verified behavior: Test.test(...) == "X" namespace Test func test() -> string { var s = "" defer { s = s + "C" } defer { s = s + "B" } defer { s = s + "A" } s = s + "X" return s } ``` ## ILEmitterTests2__Defer_Runs_On_Early_Return (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Defer_Runs_On_Early_Return topic: core status: verified // verified behavior: Test.test(...) == ".early" namespace Test func test() -> string { var trace = "" defer { trace = trace + "D" } if true { return trace + ".early" } return trace } ``` ## ILEmitterTests2__While_False_Initial_Empty_Execution (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::While_False_Initial_Empty_Execution topic: core status: verified // verified behavior: Test.test(...) == 0 namespace Test func test() -> int { var count = 0 var i = 10 while i < 0 { count = count + 1 i = i + 1 } return count } ``` ## ILEmitterTests2__While_Equal_Endpoints_Empty_Execution (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::While_Equal_Endpoints_Empty_Execution topic: core status: verified // verified behavior: Test.test(...) == 0 namespace Test func test() -> int { var count = 0 var i = 5 while i < 5 { count = count + 1 i = i + 1 } return count } ``` ## ILEmitterTests2__Composite_Nested_Literal (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Composite_Nested_Literal topic: data status: verified // verified behavior: Test.test(...) == 111 namespace Test data Outer { x: int, inner: Inner } data Inner { a: int, b: int } func test() -> int { let o = Outer { x: 1, inner: Inner { a: 10, b: 100 } } return o.x + o.inner.a + o.inner.b } ``` ## ILEmitterTests2__Composite_Partial_With_Rebinds_One_Field (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Composite_Partial_With_Rebinds_One_Field topic: data status: verified // verified behavior: Test.test(...) == 103 namespace Test data Point { x: int, y: int, z: int } func test() -> int { let p = Point { x: 1, y: 2, z: 3 } let q = p with { y: 99 } return q.x + q.y + q.z } ``` ## ILEmitterTests2__Logical_And_Both_True (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Logical_And_Both_True topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(a: bool, b: bool) -> bool = a && b ``` ## ILEmitterTests2__Logical_Or_Truth_Table (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Logical_Or_Truth_Table topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(a: bool, b: bool) -> bool = a || b ``` ## ILEmitterTests2__String_Concat_With_Plus (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::String_Concat_With_Plus topic: core status: verified // verified behavior: Test.test(...) == "hello world" namespace Test func test(a: string, b: string) -> string = a + b ``` ## ILEmitterTests2__String_Concat_With_Int_Via_ToString (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::String_Concat_With_Int_Via_ToString topic: core status: verified // verified behavior: Test.test(...) == "count=42" namespace Test func test(label: string, n: int) -> string = label + n.ToString() ``` ## ILEmitterTests2__String_Interpolation_Single_Var (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::String_Interpolation_Single_Var topic: interpolation status: verified // verified behavior: Test.test(...) == "n is 42" namespace Test func test(n: int) -> string = "n is {n}" ``` ## ILEmitterTests2__String_Interpolation_Field_Access (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::String_Interpolation_Field_Access topic: interpolation status: verified // verified behavior: Test.test(...) == "point 3,4" namespace Test data P { x: int, y: int } func test() -> string { let p = P { x: 3, y: 4 } return "point {p.x},{p.y}" } ``` ## ILEmitterTests2__String_Interpolation_Two_Variables (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::String_Interpolation_Two_Variables topic: interpolation status: verified // verified behavior: Test.test(...) == "7:hello" namespace Test func test(a: int, b: string) -> string = "{a}:{b}" ``` ## ILEmitterTests2__String_Equality_Same_Content (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::String_Equality_Same_Content topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(a: string, b: string) -> bool = a == b ``` ## ILEmitterTests2__If_As_Statement_Returns_From_Branch (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::If_As_Statement_Returns_From_Branch topic: core status: verified // verified behavior: Test.test(...) == "zero" namespace Test func test(n: int) -> string { if n > 0 { return "positive" } if n < 0 { return "negative" } return "zero" } ``` ## ILEmitterTests2__While_Sum_To_N_Idiom (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::While_Sum_To_N_Idiom topic: core status: verified // verified behavior: Test.test(...) == 0 namespace Test func test(n: int) -> int { var total = 0 var i = 1 while i <= n { total = total + i i = i + 1 } return total } ``` ## ILEmitterTests2__Function_Returns_Data_Used_By_Caller (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Function_Returns_Data_Used_By_Caller topic: data status: verified // verified behavior: Test.test(...) == 30 namespace Test data Pair { left: int, right: int } func make(a: int, b: int) -> Pair = Pair { left: a, right: b } func test() -> int { let p = make(10, 20) return p.left + p.right } ``` ## ILEmitterTests2__Function_Multiple_Returns_Via_If_Else (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Function_Multiple_Returns_Via_If_Else topic: core status: verified // verified behavior: Test.sign(...) == 0 namespace Test func sign(n: int) -> int { if n > 0 { return 1 } if n < 0 { return -1 } return 0 } ``` ## ILEmitterTests2__Negative_Literal_As_Initializer (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Negative_Literal_As_Initializer topic: core status: verified // verified behavior: Test.test(...) == -42 namespace Test func test() -> int { let n = -42 return n } ``` ## ILEmitterTests2__Negative_Literal_Comparison (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Negative_Literal_Comparison topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(n: int) -> bool = n < -10 ``` ## ILEmitterTests2__Range_Check_With_And (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Range_Check_With_And topic: core status: verified // verified behavior: Test.in_range(...) == false namespace Test func in_range(n: int) -> bool = n >= 0 && n <= 100 ``` ## ILEmitterTests2__Function_Returning_Bool_From_Comparison (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Function_Returning_Bool_From_Comparison topic: core status: verified // verified behavior: Test.is_even(...) == true namespace Test func is_even(n: int) -> bool = n % 2 == 0 ``` ## ILEmitterTests2__Fibonacci_Iterative_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Fibonacci_Iterative_Pin topic: core status: verified // verified behavior: Test.fib(...) == 6765 namespace Test func fib(n: int) -> int { if n < 2 { return n } var a = 0 var b = 1 var i = 2 while i <= n { let next = a + b a = b b = next i = i + 1 } return b } ``` ## ILEmitterTests2__Fibonacci_Recursive_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Fibonacci_Recursive_Pin topic: core status: verified // verified behavior: Test.fib(...) == 55 namespace Test func fib(n: int) -> int { if n < 2 { return n } return fib(n - 1) + fib(n - 2) } ``` ## ILEmitterTests2__Factorial_Recursive_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Factorial_Recursive_Pin topic: core status: verified // verified behavior: Test.fact(...) == 3628800 namespace Test func fact(n: int) -> int { if n <= 1 { return 1 } return n * fact(n - 1) } ``` ## ILEmitterTests2__GCD_Euclidean_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::GCD_Euclidean_Pin topic: core status: verified // verified behavior: Test.gcd(...) == 7 namespace Test func gcd(a: int, b: int) -> int { var x = a var y = b while y != 0 { let t = y y = x % y x = t } return x } ``` ## ILEmitterTests2__IsPrime_Trial_Division_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::IsPrime_Trial_Division_Pin topic: core status: verified // verified behavior: Test.is_prime(...) == true namespace Test func is_prime(n: int) -> bool { if n < 2 { return false } if n == 2 { return true } if n % 2 == 0 { return false } var d = 3 while d * d <= n { if n % d == 0 { return false } d = d + 2 } return true } ``` ## ILEmitterTests2__Power_Of_Two_Via_While_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Power_Of_Two_Via_While_Pin topic: core status: verified // verified behavior: Test.pow2(...) == 65536 namespace Test func pow2(n: int) -> int { var result = 1 var i = 0 while i < n { result = result * 2 i = i + 1 } return result } ``` ## ILEmitterTests2__DigitSum_Via_While_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::DigitSum_Via_While_Pin topic: core status: verified // verified behavior: Test.digit_sum(...) == 1 namespace Test func digit_sum(n: int) -> int { var total = 0 var x = n while x > 0 { total = total + x % 10 x = x / 10 } return total } ``` ## ILEmitterTests2__IntegerSquareRoot_BinarySearch_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::IntegerSquareRoot_BinarySearch_Pin topic: core status: verified // verified behavior: Test.isqrt(...) == 31 namespace Test func isqrt(n: int) -> int { if n < 2 { return n } var lo = 0 var hi = n while lo < hi { let mid = (lo + hi + 1) / 2 if mid * mid <= n { lo = mid } if mid * mid > n { hi = mid - 1 } } return lo } ``` ## ILEmitterTests2__Bank_Account_With_Data_Type_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Bank_Account_With_Data_Type_Pin topic: data status: verified // verified behavior: Test.run(...) == 75 namespace Test data Account { balance: int } func deposit(a: Account, amount: int) -> Account = a with { balance: a.balance + amount } func withdraw(a: Account, amount: int) -> Account = a with { balance: a.balance - amount } func run() -> int { let opened = Account { balance: 0 } let after_deposit = opened.deposit(100) let after_withdraw = after_deposit.withdraw(30) let final = after_withdraw.deposit(5) return final.balance } ``` ## ILEmitterTests2__State_Machine_With_Var_Field_Pin (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::State_Machine_With_Var_Field_Pin topic: static-func status: verified // verified behavior: Test.test(...) == 1201 namespace Test static func Light { var state: int = 0 func next() -> int { state = (state + 1) % 3 return state } func reset() -> int { state = 0 return state } } func test() -> int { let a = Light.next() let b = Light.next() let c = Light.next() let d = Light.next() return a * 1000 + b * 100 + c * 10 + d } ``` ## ILEmitterTests2__Counter_Closure_Via_StaticFunc_Pin (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Counter_Closure_Via_StaticFunc_Pin topic: static-func status: verified // verified behavior: Test.test(...) == 1221 namespace Test static func Counter { var n: int = 0 func bump() -> int { n = n + 1 return n } func peek() -> int = n func reset() -> int { n = 0 return n } } func test() -> int { let a = Counter.bump() let b = Counter.bump() let c = Counter.peek() let _ = Counter.reset() let d = Counter.bump() return a * 1000 + b * 100 + c * 10 + d } ``` ## ILEmitterTests2__Conditional_Chain_With_StringConcat_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Conditional_Chain_With_StringConcat_Pin topic: core status: verified // verified behavior: Test.describe(...) == "grade: F" namespace Test func describe(score: int) -> string { var label = "" if score >= 90 { label = "A" } if score >= 80 && score < 90 { label = "B" } if score >= 70 && score < 80 { label = "C" } if score < 70 { label = "F" } return "grade: " + label } ``` ## ILEmitterTests2__Data_Method_Chain_Via_With_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Data_Method_Chain_Via_With_Pin topic: data status: verified // verified behavior: Test.test(...) == 321 namespace Test data Vec3 { x: int, y: int, z: int } func with_x(v: Vec3, nx: int) -> Vec3 = v with { x: nx } func with_y(v: Vec3, ny: int) -> Vec3 = v with { y: ny } func with_z(v: Vec3, nz: int) -> Vec3 = v with { z: nz } func test() -> int { let origin = Vec3 { x: 0, y: 0, z: 0 } let stepped = origin.with_x(1).with_y(2).with_z(3) return stepped.x + stepped.y * 10 + stepped.z * 100 } ``` ## ILEmitterTests2__Recursive_Mutual_Functions_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Recursive_Mutual_Functions_Pin topic: core status: verified // verified behavior: Test.is_odd(...) == false namespace Test func is_even(n: int) -> bool { if n == 0 { return true } return is_odd(n - 1) } func is_odd(n: int) -> bool { if n == 0 { return false } return is_even(n - 1) } ``` ## ILEmitterTests2__Promoted_Instance_Methods_On_Data_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Promoted_Instance_Methods_On_Data_Pin topic: data status: verified // verified behavior: Test.describe(...) == 38 namespace Test data Rect { width: int, height: int } func area(r: Rect) -> int = r.width * r.height func perimeter(r: Rect) -> int = (r.width + r.height) * 2 func is_square(r: Rect) -> bool = r.width == r.height func describe() -> int { let r = Rect { width: 4, height: 5 } var score = 0 if r.is_square() { score = score + 1000 } return r.area() + r.perimeter() + score } ``` ## ILEmitterTests2__Choice_Bare_Variants_Tag_Discrimination_Pin (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Choice_Bare_Variants_Tag_Discrimination_Pin topic: choice status: verified // verified behavior: Test.test(...) == "busy" namespace Test choice Status { idle busy done } func describe(s: Status) -> string { match (s: Status) { .idle { return "idle" } .busy { return "busy" } .done { return "done" } default { return "unknown" } } return "unknown" } func test() -> string { return describe(Status.busy()) } ``` ## ILEmitterTests2__Choice_Many_Bare_Variants_Pin (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Choice_Many_Bare_Variants_Pin topic: choice status: verified // verified behavior: Test.test(...) == "west" namespace Test choice Direction { north south east west } func opposite(d: Direction) -> string { match (d: Direction) { .north { return "south" } .south { return "north" } .east { return "west" } .west { return "east" } default { return "?" } } return "?" } func test() -> string { return opposite(Direction.east()) } ``` ## ILEmitterTests2__Enum_Member_Access_And_Comparison_Pin (enum, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Enum_Member_Access_And_Comparison_Pin topic: enum status: verified // verified behavior: Test.test(...) == 2 namespace Test enum Suit { hearts, diamonds, clubs, spades } func is_red(s: Suit) -> bool { if s == .hearts { return true } if s == .diamonds { return true } return false } func test() -> int { var red = 0 if is_red(.hearts) { red = red + 1 } if is_red(.diamonds) { red = red + 1 } if is_red(.clubs) { red = red + 1 } if is_red(.spades) { red = red + 1 } return red } ``` ## ILEmitterTests2__RefData_Identity_Equal_To_Self_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::RefData_Identity_Equal_To_Self_Pin topic: data status: verified // verified behavior: Test.test(...) == true namespace Test ref data Box { pub value: int init(v: int) { self.value = v } } func test() -> bool { let a = Box(5) let b = a return a == b } ``` ## ILEmitterTests2__RefData_Different_Instances_Not_Identity_Equal_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::RefData_Different_Instances_Not_Identity_Equal_Pin topic: data status: verified // verified behavior: Test.test(...) == false namespace Test ref data Box { pub value: int init(v: int) { self.value = v } } func test() -> bool { let a = Box(5) let b = Box(5) return a == b } ``` ## ILEmitterTests2__Tuple_Construction_And_Field_Access (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Tuple_Construction_And_Field_Access topic: core status: verified // verified behavior: Test.test(...) == 42 namespace Test func make() -> (int, string) = (42, "hi") func test() -> int { let t = make() return t.Item1 } ``` ## ILEmitterTests2__Tuple_String_Element_Access (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Tuple_String_Element_Access topic: core status: verified // verified behavior: Test.test(...) == "hi" namespace Test func make() -> (int, string) = (42, "hi") func test() -> string { let t = make() return t.Item2 } ``` ## ILEmitterTests2__Tuple_Three_Element (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Tuple_Three_Element topic: core status: verified // verified behavior: Test.test(...) == 6 namespace Test func make() -> (int, int, int) = (1, 2, 3) func test() -> int { let t = make() return t.Item1 + t.Item2 + t.Item3 } ``` ## ILEmitterTests2__Function_Literal_Captures_Let (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Function_Literal_Captures_Let topic: core status: verified // verified behavior: Test.test(...) == 10 namespace Test func test() -> int { let x = 10 let read = func() -> int = x return read() } ``` ## ILEmitterTests2__Function_Literal_Passed_To_Function (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Function_Literal_Passed_To_Function topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test func apply(f: &(int -> int), n: int) -> int = f(n) func test() -> int { let double: &(int -> int) = func(x: int) -> int = x * 2 return apply(double, 21) } ``` ## ILEmitterTests2__Function_Literal_Inline_Argument (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Function_Literal_Inline_Argument topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test func apply(f: &(int -> int), n: int) -> int = f(n) func test() -> int = apply(func(x: int) -> int = x + 1, 41) ``` ## ILEmitterTests2__Generic_Identity_Function_Int (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Generic_Identity_Function_Int topic: generics status: verified // verified behavior: Test.test(...) == 42 namespace Test func id(x: T) -> T = x func test() -> int = id(42) ``` ## ILEmitterTests2__Generic_Identity_Function_String (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Generic_Identity_Function_String topic: generics status: verified // verified behavior: Test.test(...) == "hello" namespace Test func id(x: T) -> T = x func test() -> string = id("hello") ``` ## ILEmitterTests2__Generic_Identity_Function_Int_LetBinding (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Generic_Identity_Function_Int_LetBinding topic: generics status: verified // verified behavior: Test.test(...) == 43 namespace Test func id(x: T) -> T = x func test() -> int { let b = id(42) return b + 1 } ``` ## ILEmitterTests2__Generic_Identity_Function_String_LetBinding (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Generic_Identity_Function_String_LetBinding topic: generics status: verified // verified behavior: Test.test(...) == "hi!" namespace Test func id(x: T) -> T = x func test() -> string { let s = id("hi") return s + "!" } ``` ## ILEmitterTests2__Generic_Identity_Function_UserData_LetBinding (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Generic_Identity_Function_UserData_LetBinding topic: generics status: verified // verified behavior: Test.test(...) == 7 namespace Test data Box { n: int } func id(x: T) -> T = x func test() -> int { let b = id(Box { n: 7 }) return b.n } ``` ## ILEmitterTests2__Generic_Data_Type_Construction (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Generic_Data_Type_Construction topic: generics status: verified // verified behavior: Test.test(...) == 42 namespace Test data Box { value: T } func test() -> int { let b = Box { value: 42 } return b.value } ``` ## ILEmitterTests2__Nested_Data_Field_Access_Two_Deep (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Nested_Data_Field_Access_Two_Deep topic: data status: verified // verified behavior: Test.test(...) == 99 namespace Test data Inner { v: int } data Outer { inner: Inner } func test() -> int { let o = Outer { inner: Inner { v: 99 } } return o.inner.v } ``` ## ILEmitterTests2__Triple_Nested_Data_Field_Access (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Triple_Nested_Data_Field_Access topic: data status: verified // verified behavior: Test.test(...) == 42 namespace Test data A { v: int } data B { a: A } data C { b: B } func test() -> int { let c = C { b: B { a: A { v: 42 } } } return c.b.a.v } ``` ## ILEmitterTests2__Comparison_All_Operators (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Comparison_All_Operators topic: core status: verified // verified behavior: Test.test(...) == 101010 namespace Test func test(a: int, b: int) -> int { var result = 0 if a == b { result = result + 1 } if a != b { result = result + 10 } if a < b { result = result + 100 } if a > b { result = result + 1000 } if a <= b { result = result + 10000 } if a >= b { result = result + 100000 } return result } ``` ## ILEmitterTests2__Block_Scoped_Let_Visible_After_Block (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Block_Scoped_Let_Visible_After_Block topic: core status: verified // verified behavior: Test.test(...) == 30 namespace Test func test() -> int { var total = 0 var i = 0 while i < 3 { let inner = i * 10 total = total + inner i = i + 1 } return total } ``` ## ILEmitterTests2__If_Mutates_Outer_Var (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::If_Mutates_Outer_Var topic: core status: verified // verified behavior: Test.test(...) == 0 namespace Test func test(n: int) -> int { var result = 0 if n > 0 { result = 1 } if n < 0 { result = -1 } return result } ``` ## ILEmitterTests2__Absolute_Value_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Absolute_Value_Pin topic: core status: verified // verified behavior: Test.abs(...) == 0 namespace Test func abs(n: int) -> int { if n < 0 { return -n } return n } ``` ## ILEmitterTests2__Min_Max_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Min_Max_Pin topic: core status: verified // verified behavior: Test.minimum(...) == 5 namespace Test func minimum(a: int, b: int) -> int { if a < b { return a } return b } func maximum(a: int, b: int) -> int { if a > b { return a } return b } ``` ## ILEmitterTests2__Clamp_Idiom_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Clamp_Idiom_Pin topic: core status: verified // verified behavior: Test.clamp(...) == 7 namespace Test func clamp(n: int, lo: int, hi: int) -> int { if n < lo { return lo } if n > hi { return hi } return n } ``` ## ILEmitterTests2__String_Length_Property (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::String_Length_Property topic: core status: verified // verified behavior: Test.test(...) == 11 namespace Test func test(s: string) -> int = s.Length ``` ## ILEmitterTests2__Field_With_Function_Pointer_Type_Pin (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Field_With_Function_Pointer_Type_Pin topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test data Dispatch { handler: &(int -> int) } func double_it(x: int) -> int = x * 2 func test() -> int { let d = Dispatch { handler: double_it } return d.handler(21) } ``` ## ILEmitterTests2__Both_Branches_Return_Same_Type_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Both_Branches_Return_Same_Type_Pin topic: core status: verified // verified behavior: Test.choose(...) == 200 namespace Test func choose(flag: bool) -> int { if flag { return 100 } return 200 } ``` ## ILEmitterTests2__Reverse_Digits_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Reverse_Digits_Pin topic: core status: verified // verified behavior: Test.reverse(...) == 0 namespace Test func reverse(n: int) -> int { var result = 0 var x = n while x > 0 { result = result * 10 + x % 10 x = x / 10 } return result } ``` ## ILEmitterTests2__Count_Set_Bits_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Count_Set_Bits_Pin topic: core status: verified // verified behavior: Test.popcount(...) == 1 namespace Test func popcount(n: int) -> int { var count = 0 var x = n while x > 0 { if x % 2 == 1 { count = count + 1 } x = x / 2 } return count } ``` ## ILEmitterTests2__Multiply_Without_Star_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Multiply_Without_Star_Pin topic: core status: verified // verified behavior: Test.mul(...) == 0 namespace Test func mul(a: int, b: int) -> int { var result = 0 var i = 0 while i < b { result = result + a i = i + 1 } return result } ``` ## ILEmitterTests2__Collatz_Length_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Collatz_Length_Pin topic: core status: verified // verified behavior: Test.collatz_steps(...) == 8 namespace Test func collatz_steps(n: int) -> int { var x = n var steps = 0 while x > 1 { if x % 2 == 0 { x = x / 2 } else { x = x * 3 + 1 } steps = steps + 1 } return steps } ``` ## ILEmitterTests2__Helper_Function_Side_Effects_Through_Return_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Helper_Function_Side_Effects_Through_Return_Pin topic: core status: verified // verified behavior: Test.sum_squares(...) == 385 namespace Test func square(n: int) -> int = n * n func sum_squares(n: int) -> int { var total = 0 var i = 1 while i <= n { total = total + square(i) i = i + 1 } return total } ``` ## ILEmitterTests2__Interface_Dispatch_Through_Promoted_Method_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::Interface_Dispatch_Through_Promoted_Method_Pin topic: data status: verified // verified behavior: Test.test(...) == 73 namespace Test interface IShape { func area() -> int } data Square : IShape { side: int } data Circle : IShape { radius: int } func area(s: Square) -> int = s.side * s.side func area(c: Circle) -> int = 3 * c.radius * c.radius func test() -> int { let sq = Square { side: 5 } let ci = Circle { radius: 4 } return sq.area() + ci.area() } ``` ## ILEmitterTests2__LinkedList_Length_Via_HeapPointer_Pin (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests2.cs::LinkedList_Length_Via_HeapPointer_Pin topic: pointers status: verified // verified behavior: Test.test(...) == 3 namespace Test data Node { value: int, next: *Node } func length(n: *Node) -> int { var count = 0 var cursor = n while cursor != nil { count = count + 1 cursor = cursor.next } return count } func test() -> int { let c = new Node { value: 3, next: nil } let b = new Node { value: 2, next: c } let a = new Node { value: 1, next: b } return length(a) } ``` ## ILEmitterTests_Nominal__ExplicitConformance_ExactMatch_Works (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::ExplicitConformance_ExactMatch_Works topic: data status: verified // verified behavior: Test.go(...) == 11 namespace Test interface ISized { func size() -> int } data Crate : ISized { items: int } func size(c: Crate) -> int { return c.items + 1 } func measure(s: ISized) -> int { return s.size() } func go() -> int { let c = Crate { items: 10 } return measure(c) } ``` ## ILEmitterTests_Nominal__Declared_ReturnTypeMismatch_IsError (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Declared_ReturnTypeMismatch_IsError topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test interface ISized { func size() -> int } data Crate : ISized { items: int } func size(c: Crate) -> string { return "x" } ``` ## ILEmitterTests_Nominal__Declared_ParamTypeMismatch_IsError (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Declared_ParamTypeMismatch_IsError topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IAdder { func add(n: int) -> int } data Box : IAdder { v: int } func add(b: Box, n: string) -> int { return b.v } ``` ## ILEmitterTests_Nominal__Undeclared_StructuralMatch_RejectedAndSuggested (data, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Undeclared_StructuralMatch_RejectedAndSuggested topic: data status: verified // verified behavior: reports diagnostic ES2153 namespace Test interface ISized { func size() -> int } data Crate { items: int } func size(c: Crate) -> int { return c.items + 1 } func measure(s: ISized) -> int { return s.size() } func go() -> int { let c = Crate { items: 10 } return measure(c) } ``` ## ILEmitterTests_Nominal__PointerOnlyReceiver_Declared_SatisfiedViaWrapper (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::PointerOnlyReceiver_Declared_SatisfiedViaWrapper topic: pointers status: verified // verified behavior: Test.go(...) == 60 namespace Test data Node : ISummable { value: int, next: *Node } func sum(head: *Node) -> int { var total = 0 var current = head while current != nil { total += current.value current = current.next } return total } interface ISummable { func sum() -> int } func report(s: ISummable) -> int { return s.sum() } func go() -> int { var list: *Node = nil list = new Node { value: 10, next: nil } list = new Node { value: 20, next: list } list = new Node { value: 30, next: list } return report(list) } ``` ## ILEmitterTests_Nominal__Added_RefData_DeclaresInterface_Works (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_RefData_DeclaresInterface_Works topic: data status: verified // verified behavior: Test.go(...) == 7 namespace Test interface ICounter { func get() -> int } ref data Counter : ICounter { value: int init(v: int) { self.value = v } func get() -> int = self.value } func read(c: ICounter) -> int = c.get() func go() -> int { let c = Counter(7) return read(c) } ``` ## ILEmitterTests_Nominal__Added_TwoInterfaces_BothSatisfied (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_TwoInterfaces_BothSatisfied topic: data status: verified // verified behavior: Test.go(...) == 30 namespace Test interface INamed { func label() -> int } interface ISized { func size() -> int } data Widget : INamed, ISized { a: int, b: int } func label(w: Widget) -> int = w.a func size(w: Widget) -> int = w.b func both(n: INamed, s: ISized) -> int = n.label() + s.size() func go() -> int { let w = Widget { a: 10, b: 20 } return both(w, w) } ``` ## ILEmitterTests_Nominal__Added_UndeclaredStructuralMatch_WarnsES2153 (data, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_UndeclaredStructuralMatch_WarnsES2153 topic: data status: verified // verified behavior: reports diagnostic ES2153 namespace Test interface ISized { func size() -> int } data Crate { items: int } func size(c: Crate) -> int = c.items ``` ## ILEmitterTests_Nominal__Added_UndeclaredStructuralMatch_IsNotConformance (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_UndeclaredStructuralMatch_IsNotConformance topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test interface ISized { func size() -> int } data Crate { items: int } func size(c: Crate) -> int = c.items func measure(s: ISized) -> int = s.size() func go() -> int { let c = Crate { items: 3 } return measure(c) } ``` ## ILEmitterTests_Nominal__Added_ParamTypeMismatch_IsError (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_ParamTypeMismatch_IsError topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IAdder { func add(x: int) -> int } data Calc : IAdder { base: int } func add(c: Calc, x: string) -> int = c.base ``` ## ILEmitterTests_Nominal__Added_MarkerInterface_NoMethods_Conforms (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_MarkerInterface_NoMethods_Conforms topic: data status: verified // verified behavior: Test.go(...) == 5 namespace Test interface ITag { } data Item : ITag { v: int } func tagged(t: ITag) -> int = 5 func go() -> int { let i = Item { v: 1 } return tagged(i) } ``` ## ILEmitterTests_Nominal__Added_InterfaceReturnedFromFunction (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_InterfaceReturnedFromFunction topic: data status: verified // verified behavior: Test.go(...) == 8 namespace Test interface ISized { func size() -> int } ref data Crate : ISized { n: int init(n: int) { self.n = n } func size() -> int = self.n } func make() -> ISized = Crate(8) func go() -> int { let s = make() return s.size() } ``` ## ILEmitterTests_Nominal__Added_PointerOnlyConformance_Wrapper (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_PointerOnlyConformance_Wrapper topic: pointers status: verified // verified behavior: Test.go(...) == 43 namespace Test data Inner { var n: int } func bump(i: *Inner) { i.n += 1 } func value(i: Inner) -> int = i.n data Counter : ICounter { *Inner } interface ICounter { func bump(), func value() -> int } func tick(c: ICounter) -> int { c.bump() return c.value() } func go() -> int { var c: *Counter = new Counter { Inner: new Inner { n: 42 } } return tick(c) } ``` ## ILEmitterTests_Nominal__Added_InterfaceMethodViaPromotion (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_InterfaceMethodViaPromotion topic: data status: verified // verified behavior: Test.go(...) == 15 namespace Test interface IArea { func area() -> int } data Rect : IArea { w: int, h: int } func area(r: Rect) -> int = r.w * r.h func go() -> int { let r = Rect { w: 3, h: 5 } let a: IArea = r return a.area() } ``` ## ILEmitterTests_Nominal__Added_GenericConformance (data, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Nominal.cs::Added_GenericConformance topic: data status: unverified // verified behavior: Test.go(...) == 9 generic value data implementing an interface (promoted generic-method self-param) not yet supported ``` ## ILEmitterTests_StringEquality__ConcatEqualsLiteral (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::ConcatEqualsLiteral topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let a = "ab" let b = "a" + "b" return a == b } ``` ## ILEmitterTests_StringEquality__ParamEqualsLiteral_True (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::ParamEqualsLiteral_True topic: core status: verified // verified behavior: Test.go(...) == true func eq(s: string) -> bool = s == "hello" func go() -> bool = eq("hello") ``` ## ILEmitterTests_StringEquality__ParamEqualsLiteral_False (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::ParamEqualsLiteral_False topic: core status: verified // verified behavior: Test.go(...) == false func eq(s: string) -> bool = s == "hello" func go() -> bool = eq("world") ``` ## ILEmitterTests_StringEquality__NotEqual_True (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::NotEqual_True topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let a = "x" let b = "y" return a != b } ``` ## ILEmitterTests_StringEquality__NotEqual_False (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::NotEqual_False topic: core status: verified // verified behavior: Test.go(...) == false func go() -> bool { let a = "x" let b = "x" + "" return a != b } ``` ## ILEmitterTests_StringEquality__EqualityInIfCondition (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::EqualityInIfCondition topic: core status: verified // verified behavior: Test.go(...) == 1 func classify(s: string) -> int { if s == "fail" { return 1 } return 0 } func go() -> int = classify("fail") ``` ## ILEmitterTests_StringEquality__EqualityInIfCondition_NotTaken (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::EqualityInIfCondition_NotTaken topic: core status: verified // verified behavior: Test.go(...) == 0 func classify(s: string) -> int { if s == "fail" { return 1 } return 0 } func go() -> int = classify("ok") ``` ## ILEmitterTests_StringEquality__SubstringEqualsLiteral (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::SubstringEqualsLiteral topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let s = "hello" let h = s.Substring(0, 3) return h == "hel" } ``` ## ILEmitterTests_StringEquality__ChainedEquality (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::ChainedEquality topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let a = "a" let b = "a" let c = "a" return a == b && b == c } ``` ## ILEmitterTests_StringEquality__EqualityInWhileGuard (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::EqualityInWhileGuard topic: core status: verified // verified behavior: Test.go(...) == 3 func go() -> int { var n = 0 var s = "go" while s == "go" { n += 1 if n >= 3 { s = "stop" } } return n } ``` ## ILEmitterTests_StringEquality__TwoRuntimeStringsEqual (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::TwoRuntimeStringsEqual topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let a = "foo" + "bar" let b = "foob" + "ar" return a == b } ``` ## ILEmitterTests_StringEquality__CharComparisonStillCeq (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::CharComparisonStillCeq topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let s = "a b" return s[1] == ' ' } ``` ## ILEmitterTests_StringEquality__CharComparisonNotEqual (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::CharComparisonNotEqual topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let s = "abc" return s[0] != 'z' } ``` ## ILEmitterTests_StringEquality__EqualityFeedingReturn (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::EqualityFeedingReturn topic: core status: verified // verified behavior: Test.go(...) == false func go() -> bool { let a = "abc" let b = "abd" return a == b } ``` ## ILEmitterTests_StringEquality__EmptyStringEquality (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StringEquality.cs::EmptyStringEquality topic: core status: verified // verified behavior: Test.go(...) == true func go() -> bool { let a = "" let b = "x".Substring(0, 0) return a == b } ``` ## RefChoiceCaseViewTests__SinglePayload_BareName_IsPayloadValue (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::SinglePayload_BareName_IsPayloadValue topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice E { lit(value: int) neg(inner: E) } func eval(e: E) -> int { match e { .lit(v) { return v } .neg(inner) { return 0 - eval(inner) } } } func go() -> int = eval(E.lit(42)) ``` ## RefChoiceCaseViewTests__SinglePayload_Recursion_ThroughBareName (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::SinglePayload_Recursion_ThroughBareName topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice E { lit(value: int) neg(inner: E) } func eval(e: E) -> int { match e { .lit(v) { return v } .neg(inner) { return 0 - eval(inner) } } } func go() -> int = eval(E.neg(E.lit(7))) ``` ## RefChoiceCaseViewTests__SinglePayload_DotField_StillResolves (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::SinglePayload_DotField_StillResolves topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Box { full(value: int) empty } func read(b: Box) -> int { match b { .full(c) { return c.value } // c.value still works (aliases the bare binding) .empty { return 0 } } } func go() -> int = read(Box.full(9)) ``` ## RefChoiceCaseViewTests__SinglePayload_BoolTransparent (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::SinglePayload_BoolTransparent topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Flag { on(value: bool) off } func read(f: Flag) -> bool { match f { .on(v) { return v } .off { return false } } } func go() -> bool = read(Flag.on(true)) ``` ## RefChoiceCaseViewTests__SinglePayload_ListTransparent_Indexing (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::SinglePayload_ListTransparent_Indexing topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Seq { arr(items: List) empty } func total(s: Seq) -> int { match s { .arr(items) { var sum = 0 var i = 0 while i < items.Count { sum += items[i] i += 1 } return sum } .empty { return 0 } } } func go() -> int { let xs = List() xs.Add(10) xs.Add(20) return total(Seq.arr(xs)) } ``` ## RefChoiceCaseViewTests__MultiPayload_CaseView_StillWorks (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::MultiPayload_CaseView_StillWorks topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice E { lit(value: int) add(left: E, right: E) } func eval(e: E) -> int { match e { .lit(v) { return v } .add(n) { return eval(n.left) + eval(n.right) } } } func go() -> int = eval(E.add(E.lit(5), E.lit(7))) ``` ## RefChoiceCaseViewTests__MultiPayload_Positional_StillWorks (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::MultiPayload_Positional_StillWorks topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice E { lit(value: int) add(left: E, right: E) } func eval(e: E) -> int { match e { .lit(v) { return v } .add(l, r) { return eval(l) + eval(r) } } } func go() -> int = eval(E.add(E.lit(8), E.lit(12))) ``` ## RefChoiceCaseViewTests__Json_Transparent_EndToEnd (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: RefChoiceCaseViewTests.cs::Json_Transparent_EndToEnd topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> string { ``` ## ILEmitterTests_Coverage_Collections__String_Concatenation (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_Concatenation topic: core status: verified // verified behavior: Test.go(...) == "hello world" namespace Test func go() -> string { let a = "hello" let b = "world" return a + " " + b } ``` ## ILEmitterTests_Coverage_Collections__String_Length (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_Length topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { return "hello".Length } ``` ## ILEmitterTests_Coverage_Collections__String_Substring (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_Substring topic: core status: verified // verified behavior: Test.go(...) == "ell" namespace Test func go() -> string { return "hello".Substring(1, 3) } ``` ## ILEmitterTests_Coverage_Collections__String_ToUpper (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_ToUpper topic: core status: verified // verified behavior: Test.go(...) == "HELLO" namespace Test func go() -> string { return "hello".ToUpper() } ``` ## ILEmitterTests_Coverage_Collections__String_Contains (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_Contains topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool { return "hello world".Contains("world") } ``` ## ILEmitterTests_Coverage_Collections__String_StartsWith (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_StartsWith topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool { return "hello".StartsWith("he") } ``` ## ILEmitterTests_Coverage_Collections__String_IndexOf (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_IndexOf topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { return "hello world".IndexOf("world") } ``` ## ILEmitterTests_Coverage_Collections__String_Replace (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_Replace topic: core status: verified // verified behavior: Test.go(...) == "hexxo" namespace Test func go() -> string { return "hello".Replace("l", "x") } ``` ## ILEmitterTests_Coverage_Collections__String_EqualityComparison (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_EqualityComparison topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool { let a = "abc" let b = "abc" return a == b } ``` ## ILEmitterTests_Coverage_Collections__String_Inequality (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_Inequality topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool { return "abc" != "abd" } ``` ## ILEmitterTests_Coverage_Collections__String_TrimAndEmpty (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::String_TrimAndEmpty topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { return " ".Trim().Length } ``` ## ILEmitterTests_Coverage_Collections__Interp_SimpleVariable (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_SimpleVariable topic: interpolation status: verified // verified behavior: Test.go(...) == "hi alice" namespace Test func go() -> string { let name = "alice" return "hi {name}" } ``` ## ILEmitterTests_Coverage_Collections__Interp_IntegerBoxing (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_IntegerBoxing topic: interpolation status: verified // verified behavior: Test.go(...) == "count=3" namespace Test func go() -> string { let n = 3 return "count={n}" } ``` ## ILEmitterTests_Coverage_Collections__Interp_ArithmeticExpression (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_ArithmeticExpression topic: interpolation status: verified // verified behavior: Test.go(...) == "sum=7" namespace Test func go() -> string { let a = 3 let b = 4 return "sum={a + b}" } ``` ## ILEmitterTests_Coverage_Collections__Interp_MemberAccess (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_MemberAccess topic: interpolation status: verified // verified behavior: Test.go(...) == "x=10" namespace Test data Pt { x: int, y: int } func go() -> string { let p = Pt { x: 10, y: 20 } return "x={p.x}" } ``` ## ILEmitterTests_Coverage_Collections__Interp_MethodCall (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_MethodCall topic: interpolation status: verified // verified behavior: Test.go(...) == "len=5" namespace Test func go() -> string { let s = "hello" return "len={s.Length}" } ``` ## ILEmitterTests_Coverage_Collections__Interp_TernaryInsideHole (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_TernaryInsideHole topic: interpolation status: verified // verified behavior: Test.go(...) == "sign=+" namespace Test func go() -> string { let n = 5 return "sign={n > 0 ? "+" : "-"}" } ``` ## ILEmitterTests_Coverage_Collections__Interp_MultipleHoles (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_MultipleHoles topic: interpolation status: verified // verified behavior: Test.go(...) == "a1b2" namespace Test func go() -> string { let x = 1 let y = 2 return "a{x}b{y}" } ``` ## ILEmitterTests_Coverage_Collections__Interp_LiteralBraces (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Interp_LiteralBraces topic: interpolation status: verified // verified behavior: Test.go(...) == "{x}" namespace Test func go() -> string { return "{{x}}" } ``` ## ILEmitterTests_Coverage_Collections__List_Count (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::List_Count topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3] return xs.Count } ``` ## ILEmitterTests_Coverage_Collections__List_AddThenCount (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::List_AddThenCount topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = List() xs.Add(1) xs.Add(2) return xs.Count } ``` ## ILEmitterTests_Coverage_Collections__List_MutateElement (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::List_MutateElement topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3] xs[0] = 99 return xs[0] } ``` ## ILEmitterTests_Coverage_Collections__List_ForInSum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::List_ForInSum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [10, 20, 30] var total = 0 for x in xs { total += x } return total } ``` ## ILEmitterTests_Coverage_Collections__List_StringElements (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::List_StringElements topic: core status: verified // verified behavior: Test.go(...) == "b" namespace Test func go() -> string { let xs = ["a", "b", "c"] return xs[1] } ``` ## ILEmitterTests_Coverage_Collections__List_Contains (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::List_Contains topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool { let xs = [1, 2, 3] return xs.Contains(2) } ``` ## ILEmitterTests_Coverage_Collections__List_OfData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::List_OfData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Pt { x: int, y: int } func go() -> int { let pts = List() pts.Add(Pt { x: 10, y: 20 }) let p = pts[0] return p.x + p.y } ``` ## ILEmitterTests_Coverage_Collections__Linq_Sum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Linq_Sum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3, 4, 5] return xs.Sum() } ``` ## ILEmitterTests_Coverage_Collections__Linq_Count (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Linq_Count topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3, 4] return xs.Count() } ``` ## ILEmitterTests_Coverage_Collections__Linq_Max (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Linq_Max topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [10, 30, 20] return xs.Max() } ``` ## ILEmitterTests_Coverage_Collections__Linq_Min (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Linq_Min topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [30, 10, 20] return xs.Min() } ``` ## ILEmitterTests_Coverage_Collections__Dict_Count (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Dict_Count topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let d = Dictionary() d["a"] = 1 d["b"] = 2 return d.Count } ``` ## ILEmitterTests_Coverage_Collections__Dict_ContainsKey (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Dict_ContainsKey topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool { let d = Dictionary() d["k"] = 1 return d.ContainsKey("k") } ``` ## ILEmitterTests_Coverage_Collections__Dict_OverwriteValue (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Dict_OverwriteValue topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let d = Dictionary() d["k"] = 1 d["k"] = 2 return d["k"] } ``` ## ILEmitterTests_Coverage_Collections__Dict_TryGetValue (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Dict_TryGetValue topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let d = Dictionary() d["k"] = 7 if d.TryGetValue("k", out var v) { return v } return -1 } ``` ## ILEmitterTests_Coverage_Collections__Dict_IntKey (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Dict_IntKey topic: interop status: verified // verified behavior: Test.go(...) == "hello" namespace Test func go() -> string { let d = Dictionary() d[1] = "hello" return d[1] } ``` ## ILEmitterTests_Coverage_Collections__Nested_ListOfList (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Nested_ListOfList topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let outer = List>() let inner = [1, 2, 3] outer.Add(inner) return outer[0].Count } ``` ## ILEmitterTests_Coverage_Collections__Nested_DictOfList (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Nested_DictOfList topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let d = Dictionary>() d["nums"] = [10, 20] return d["nums"].Count } ``` ## ILEmitterTests_Coverage_Collections__Tuple_ReturnFromFunc (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Tuple_ReturnFromFunc topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func swap(a: int, b: int) -> (int, int) { return (b, a) } func go() -> int { let t = swap(2, 3) return t.Item1 + t.Item2 } ``` ## ILEmitterTests_Coverage_Collections__Tuple_DestructureInLet (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Tuple_DestructureInLet topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func swap(a: int, b: int) -> (int, int) { return (b, a) } func go() -> int { let (x, y) = swap(2, 1) return x } ``` ## ILEmitterTests_Coverage_Collections__Tuple_MixedTypes (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Tuple_MixedTypes topic: interpolation status: verified // verified behavior: Test.go(...) == "alice:30" namespace Test func go() -> string { let t = ("alice", 30) return "{t.Item1}:{t.Item2}" } ``` ## ILEmitterTests_Coverage_Collections__Tuple_DestructureInFor (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Tuple_DestructureInFor topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let pairs = List<(int, int)>() pairs.Add((10, 20)) pairs.Add((30, 0)) var total = 0 for (a, b) in pairs { total += a + b } return total } ``` ## ILEmitterTests_Coverage_Collections__Nullable_ValuePresent (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Nullable_ValuePresent topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func find(id: int) -> int? { if id == 0 { return nil } return 42 } func go() -> int { let v = find(1) return v ?? -1 } ``` ## ILEmitterTests_Coverage_Collections__Nullable_NilFallback (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Nullable_NilFallback topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func find(id: int) -> int? { if id == 0 { return nil } return 42 } func go() -> int { let v = find(0) return v ?? -1 } ``` ## ILEmitterTests_Coverage_Collections__Nullable_RefTypeString (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Nullable_RefTypeString topic: core status: verified // verified behavior: Test.go(...) == "fallback" namespace Test func find(id: int) -> string? { if id == 0 { return nil } return "found" } func go() -> string { return find(0) ?? "fallback" } ``` ## ILEmitterTests_Coverage_Collections__Nullable_HasValueViaCoalesce (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Nullable_HasValueViaCoalesce topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func maybe(present: bool) -> int? { if present { return 100 } return nil } func go() -> int { let a = maybe(true) ?? 0 let b = maybe(false) ?? 0 return a + b } ``` ## ILEmitterTests_Coverage_Collections__Algo_ReverseString (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Algo_ReverseString topic: core status: verified // verified behavior: Test.go(...) == "olleh" namespace Test func reverse(s: string) -> string { var result = "" var i = s.Length - 1 while i >= 0 { result = result + s[i].ToString() i -= 1 } return result } func go() -> string { return reverse("hello") } ``` ## ILEmitterTests_Coverage_Collections__Algo_CountChar (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Algo_CountChar topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func countChar(s: string, target: char) -> int { var count = 0 for c in s { if c == target { count += 1 } } return count } func go() -> int { return countChar("banana", 'a') } ``` ## ILEmitterTests_Coverage_Collections__Algo_JoinWithSeparator (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Algo_JoinWithSeparator topic: core status: verified // verified behavior: Test.go(...) == "a-b-c" namespace Test func go() -> string { let xs = ["a", "b", "c"] var result = "" var first = true for x in xs { if first { result = x first = false } else { result = result + "-" + x } } return result } ``` ## ILEmitterTests_Coverage_Collections__Algo_StringBuilderAccumulate (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Algo_StringBuilderAccumulate topic: interop status: verified // verified behavior: Test.go(...) == "0123" namespace Test func go() -> string { let sb = StringBuilder() for i in 0..4 { sb.Append(i.ToString()) } return sb.ToString() } ``` ## ILEmitterTests_Coverage_Collections__Added_ListOfPointers_ForInSum (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ListOfPointers_ForInSum topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } func go() -> int { let xs = [new Box { n: 10 }, new Box { n: 20 }, new Box { n: 30 }] var t = 0 for b in xs { t += b.n } return t } ``` ## ILEmitterTests_Coverage_Collections__Added_ListOfStrings_Concat (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ListOfStrings_Concat topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { let xs = ["a", "b"] return xs[0] + "," + xs[1] } ``` ## ILEmitterTests_Coverage_Collections__Added_TupleOfValueData_Item (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_TupleOfValueData_Item topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } func go() -> int { let t = (Box { n: 2 }, Box { n: 5 }) return t.Item2.n } ``` ## ILEmitterTests_Coverage_Collections__Added_DictStringToPointer (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_DictStringToPointer topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } func go() -> int { var m = Dictionary() m["k"] = new Box { n: 99 } return m["k"].n } ``` ## ILEmitterTests_Coverage_Collections__Added_DictStringToInt (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_DictStringToInt topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var m = Dictionary() m["a"] = 3 return m["a"] } ``` ## ILEmitterTests_Coverage_Collections__Added_NestedListOfLists (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_NestedListOfLists topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var outer = List>() var inner = List() inner.Add(1) inner.Add(2) outer.Add(inner) return outer[0].Count } ``` ## ILEmitterTests_Coverage_Collections__Added_ListOfInts_ForInSum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ListOfInts_ForInSum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3, 4, 5] var t = 0 for x in xs { t += x } return t } ``` ## ILEmitterTests_Coverage_Collections__Added_ListOfDoubles_Index (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ListOfDoubles_Index topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { let xs = [1.5, 2.5, 3.5] return xs[1] } ``` ## ILEmitterTests_Coverage_Collections__Added_ListLiteral_Count (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ListLiteral_Count topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [9, 8, 7, 6] return xs.Count } ``` ## ILEmitterTests_Coverage_Collections__Added_ListOfInts_LastViaIndexFromEnd (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ListOfInts_LastViaIndexFromEnd topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [3, 5, 7] return xs[^1] } ``` ## ILEmitterTests_Coverage_Collections__Added_ListOfBools_Index (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ListOfBools_Index topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool { let xs = [false, true] return xs[1] } ``` ## ILEmitterTests_Coverage_Collections__Added_ValueDataList_ForInSum (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::Added_ValueDataList_ForInSum topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } func go() -> int { let xs = [Box { n: 10 }, Box { n: 20 }, Box { n: 30 }] var t = 0 for b in xs { t += b.n } return t } ``` ## ILEmitterTests_Coverage_Collections__RP_Dict_ComparerCtor_IsCaseInsensitive (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_Dict_ComparerCtor_IsCaseInsensitive topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var d = Dictionary(StringComparer.OrdinalIgnoreCase) d["A"] = "1" d["a"] = "2" return d.Count } ``` ## ILEmitterTests_Coverage_Collections__RP_ReadOnlyDict_CovariantAssign_AndCount (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_ReadOnlyDict_CovariantAssign_AndCount topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var d = Dictionary() d["a"] = "x" d["b"] = "y" let ro: IReadOnlyDictionary = d return ro.Count } ``` ## ILEmitterTests_Coverage_Collections__RP_StringJoin_OverList (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_StringJoin_OverList topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { var built = List() built.Add("a") built.Add("b") built.Add("c") return string.Join('/', built) } ``` ## ILEmitterTests_Coverage_Collections__RP_TrimStart_Split_Count (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_TrimStart_Split_Count topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let segs = "/users/42".TrimStart('/').Split('/', StringSplitOptions.RemoveEmptyEntries) return segs.Length } ``` ## ILEmitterTests_Coverage_Collections__RP_StringEquals_OrdinalIgnoreCase (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_StringEquals_OrdinalIgnoreCase topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool = string.Equals("Users", "users", StringComparison.OrdinalIgnoreCase) ``` ## ILEmitterTests_Coverage_Collections__RP_FuncParam_Invoke (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_FuncParam_Invoke topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func apply(f: Func, x: string) -> string = f(x) func go() -> string = apply((s) => s + "!", "hi") ``` ## ILEmitterTests_Coverage_Collections__RP_OutParam_TryPattern (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_OutParam_TryPattern topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func try_thing(input: int, out result: int) -> bool { result = input + 1 return true } func go() -> int { var r = 0 if try_thing(42, out r) { return r } return -1 } ``` ## ILEmitterTests_Coverage_Collections__RP_NilDict_ReassignThenSet (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_NilDict_ReassignThenSet topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var d: Dictionary = nil if d == nil { d = Dictionary() } d["k"] = "v" return d.Count } ``` ## ILEmitterTests_Coverage_Collections__RP_FullRoutePattern_TryMatchAndBuild (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_FullRoutePattern_TryMatchAndBuild topic: static-func status: verified // verified behavior: Test.lenArgs(...) == false namespace Test pub static func RoutePattern { let EmptyParams: IReadOnlyDictionary = Dictionary(0) pub func TryMatch(pattern: string, path: string, out result: IReadOnlyDictionary) -> bool { let pSegs = pattern.TrimStart('/').Split('/', StringSplitOptions.RemoveEmptyEntries) let hSegs = path.TrimStart('/').Split('/', StringSplitOptions.RemoveEmptyEntries) if pSegs.Length != hSegs.Length { result = EmptyParams return false } var captured: Dictionary = nil var i = 0 while i < pSegs.Length { let seg = pSegs[i] if seg.Length >= 2 && seg[0] == '{' && seg[seg.Length - 1] == '}' { if captured == nil { captured = Dictionary(StringComparer.OrdinalIgnoreCase) } captured[seg.Substring(1, seg.Length - 2)] = hSegs[i] } else { if !string.Equals(seg, hSegs[i], StringComparison.OrdinalIgnoreCase) { result = EmptyParams return false } } i += 1 } if captured == nil { result = EmptyParams } else { result = captured } return true } pub func Build(pattern: string, valueFor: Func) -> string? { let pSegs = pattern.TrimStart('/').Split('/', StringSplitOptions.RemoveEmptyEntries) var built = List() var i = 0 while i < pSegs.Length { let seg = pSegs[i] if seg.Length >= 2 && seg[0] == '{' && seg[seg.Length - 1] == '}' { let v = valueFor(seg.Substring(1, seg.Length - 2)) if v == nil { return nil } built.Add(v) } else { built.Add(seg) } i += 1 } return "/" + string.Join('/', built) } } ``` ## ILEmitterTests_Coverage_Collections__RP_StringJoin_StringSeparator_OverList (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_StringJoin_StringSeparator_OverList topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { var xs = List() xs.Add("a") xs.Add("b") xs.Add("c") return string.Join(", ", xs) } ``` ## ILEmitterTests_Coverage_Collections__RP_InterfaceInheritedMember_ReadOnlyListCount (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Collections.cs::RP_InterfaceInheritedMember_ReadOnlyListCount topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var xs = List() xs.Add(1) xs.Add(2) let ro: IReadOnlyList = xs return ro.Count } ``` ## ILEmitterTests_Coverage_Data__Data_ConstructAndFieldAccess (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Data_ConstructAndFieldAccess topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Point { x: int, y: int } func go() -> int { let p = Point { x: 10, y: 20 } return p.x + p.y } ``` ## ILEmitterTests_Coverage_Data__Data_PositionalConstruction (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Data_PositionalConstruction topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec2(x: int, y: int) func go() -> int { let v = Vec2(3, 4) return v.x + v.y } ``` ## ILEmitterTests_Coverage_Data__Data_MutableField (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Data_MutableField topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Counter { var n: int } func go() -> int { var c = Counter { n: 10 } c.n += 5 return c.n } ``` ## ILEmitterTests_Coverage_Data__Data_InstanceMethodPromotion (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Data_InstanceMethodPromotion topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Sq { side: int } func area(s: Sq) -> int { return s.side * s.side } func go() -> int { let s = Sq { side: 5 } return s.area() } ``` ## ILEmitterTests_Coverage_Data__Data_FactoryFunction (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Data_FactoryFunction topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { v: int } func makeBox(n: int) -> Box { return Box { v: n * 2 } } func go() -> int { return makeBox(21).v } ``` ## ILEmitterTests_Coverage_Data__Generic_Pair (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Generic_Pair topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Pair { first: A, second: B } func go() -> int { let p = Pair { first: 3, second: 5 } return p.first + p.second } ``` ## ILEmitterTests_Coverage_Data__Generic_IdentityFunction (generics, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Generic_IdentityFunction topic: generics status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func identity(value: T) -> T { return value } func go() -> int { return identity(99) } ``` ## ILEmitterTests_Coverage_Data__Generic_SwapPair (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Generic_SwapPair topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Pair { first: A, second: B } func go() -> int { let p = Pair { first: 2, second: 1 } let q = Pair { first: p.second, second: p.first } return q.first } ``` ## ILEmitterTests_Coverage_Data__ReadonlyData_With (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::ReadonlyData_With topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test readonly data P { x: int, y: int } func go() -> int { let a = P { x: 3, y: 4 } let b = a with { x: 9 } return b.x + b.y } ``` ## ILEmitterTests_Coverage_Data__Tuple_Construction (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Tuple_Construction topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let t = (3, 4) return t.Item1 + t.Item2 } ``` ## ILEmitterTests_Coverage_Data__Tuple_DestructuringInLet (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Tuple_DestructuringInLet topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func swap(a: int, b: int) -> (int, int) { return (b, a) } func go() -> int { let (x, y) = swap(2, 3) return x + y } ``` ## ILEmitterTests_Coverage_Data__Collection_ListLiteralIndex (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Collection_ListLiteralIndex topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [10, 20, 30] return xs[0] + xs[1] + xs[2] } ``` ## ILEmitterTests_Coverage_Data__Collection_ListCount (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Collection_ListCount topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3, 4] return xs.Count } ``` ## ILEmitterTests_Coverage_Data__Collection_ForInSum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Collection_ForInSum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3, 4, 5] var total = 0 for x in xs { total += x } return total } ``` ## ILEmitterTests_Coverage_Data__Closure_MutableCapture (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Closure_MutableCapture topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var total = 0 let inc = func() { total = total + 1 } inc() inc() return total } ``` ## ILEmitterTests_Coverage_Data__Closure_Accumulator (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Closure_Accumulator topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var sum = 0 let addTo = func(value: int) { sum = sum + value } for i in 1..6 { addTo(i) } return sum } ``` ## ILEmitterTests_Coverage_Data__Lambda_ArrowExpression (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Lambda_ArrowExpression topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func apply(x: int, f: Func) -> int = f(x) func go() -> int { return apply(6, (x) => x * x) } ``` ## ILEmitterTests_Coverage_Data__FunctionPointer_CallThroughLocal (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::FunctionPointer_CallThroughLocal topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func add(a: int, b: int) -> int { return a + b } func go() -> int { let p = &add return p(3, 4) } ``` ## ILEmitterTests_Coverage_Data__Defer_RunsInLifoOrder (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Defer_RunsInLifoOrder topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { var n: int } func go() -> int { var b: *Box = new Box { n: 0 } bump(b) return b.n } func bump(b: *Box) { defer { b.n += 2 } defer { b.n *= 5 } b.n = 2 } ``` ## ILEmitterTests_Coverage_Data__Derive_Equality (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Derive_Equality topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test derive equality data P { x: int, y: int } func go() -> bool { let a = P { x: 1, y: 2 } let b = P { x: 1, y: 2 } return a == b } ``` ## ILEmitterTests_Coverage_Data__Derive_Equality_Distinct (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Derive_Equality_Distinct topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test derive equality data P { x: int, y: int } func go() -> bool { let a = P { x: 1, y: 2 } let b = P { x: 1, y: 9 } return a == b } ``` ## ILEmitterTests_Coverage_Data__StructEmbedding_PromotedAccess (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::StructEmbedding_PromotedAccess topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec2 { var x: int var y: int } data Transform { Vec2 var scale: int } func go() -> int { var t = Transform { x: 10, y: 20, scale: 5 } t.x += 5 return t.x + t.y } ``` ## ILEmitterTests_Coverage_Data__NullCoalescing_Fallback (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::NullCoalescing_Fallback topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func find(id: int) -> string? { if id == 0 { return nil } return "x" } func go() -> int { let s = find(0) ?? "fallback" return s.Length } ``` ## ILEmitterTests_Coverage_Data__NullConditional_Access (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::NullConditional_Access topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let s: string? = nil return s?.Length ?? 0 } ``` ## ILEmitterTests_Coverage_Data__StaticFunc_Bag (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::StaticFunc_Bag topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Password { let MIN: int = 8 func strong(s: string) -> bool { return s.Length > MIN } } func go() -> bool { return Password.strong("hunter2hunter2") } ``` ## ILEmitterTests_Coverage_Data__ExpressionBodied_Function (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::ExpressionBodied_Function topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func double(x: int) -> int = x * 2 func go() -> int { return double(10) } ``` ## ILEmitterTests_Coverage_Data__Dictionary_PutGet (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::Dictionary_PutGet topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let d = Dictionary() d["answer"] = 42 return d["answer"] } ``` ## ILEmitterTests_Coverage_Data__RefData_IdentityMutation (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::RefData_IdentityMutation topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Counter { var value: int init() { self.value = 0 } func inc() { self.value += 1 } } func go() -> int { let c = Counter() c.inc() c.inc() c.inc() return c.value } ``` ## ILEmitterTests_Coverage_Data__RefData_Inheritance_Override (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Data.cs::RefData_Inheritance_Override topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test abstract ref data Shape { init() { } abstract func area() -> int } ref data Square : Shape { side: int init(s: int) : base() { self.side = s } : func area() -> int { return self.side * self.side } } func go() -> int { let sq = Square(5) return sq.area() } ``` ## ILEmitterTests_Const__Toplevel_Const_Int_Used_In_Func (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_Int_Used_In_Func topic: const status: verified // verified behavior: Test.test(...) == 1024 namespace Test const MAX = 1024 func test() -> int = MAX ``` ## ILEmitterTests_Const__Toplevel_Const_String (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_String topic: const status: verified // verified behavior: Test.test(...) == "hello" namespace Test const GREETING = "hello" func test() -> string = GREETING ``` ## ILEmitterTests_Const__Toplevel_Const_Double (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_Double topic: const status: verified // verified behavior: Test.test(...) == 3.14 namespace Test const PI = 3.14 func test() -> double = PI ``` ## ILEmitterTests_Const__Toplevel_Const_Bool (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_Bool topic: const status: verified // verified behavior: Test.test(...) == true namespace Test const ENABLED = true func test() -> bool = ENABLED ``` ## ILEmitterTests_Const__Toplevel_Const_With_Type_Annotation (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_With_Type_Annotation topic: const status: verified // verified behavior: Test.test(...) == 42 namespace Test const N: int = 42 func test() -> int = N ``` ## ILEmitterTests_Const__Toplevel_Const_Folded_Arithmetic (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_Folded_Arithmetic topic: const status: verified // verified behavior: Test.test(...) == 60 namespace Test const SUM = 10 + 20 + 30 func test() -> int = SUM ``` ## ILEmitterTests_Const__Toplevel_Const_In_Arithmetic (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_In_Arithmetic topic: const status: verified // verified behavior: Test.test(...) == 105 namespace Test const BASE = 100 func test(x: int) -> int = BASE + x ``` ## ILEmitterTests_Const__Toplevel_Const_In_Loop_Bound (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_In_Loop_Bound topic: const status: verified // verified behavior: Test.test(...) == 10 namespace Test const COUNT = 5 func test() -> int { var total = 0 for i in 0..COUNT { total = total + i } return total } ``` ## ILEmitterTests_Const__Toplevel_Const_Negative (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_Negative topic: const status: verified // verified behavior: Test.test(...) == -7 namespace Test const NEG = -7 func test() -> int = NEG ``` ## ILEmitterTests_Const__Pub_Toplevel_Const_Emits_Public_Literal_Field (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Pub_Toplevel_Const_Emits_Public_Literal_Field topic: const status: verified // verified behavior: Test.test(...) == 7 namespace Test pub const VERSION = 7 func test() -> int = VERSION ``` ## ILEmitterTests_Const__Body_Const_Used_Locally (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Body_Const_Used_Locally topic: const status: verified // verified behavior: Test.test(...) == 42 namespace Test func test() -> int { const X = 21 return X * 2 } ``` ## ILEmitterTests_Const__Body_Const_Folded_Arithmetic (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Body_Const_Folded_Arithmetic topic: const status: verified // verified behavior: Test.test(...) == 19 namespace Test func test() -> int { const A = 3 const B = 4 return A * B + A + B } ``` ## ILEmitterTests_Const__Body_Const_Shadowed_In_Inner_Scope (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Body_Const_Shadowed_In_Inner_Scope topic: const status: verified // verified behavior: Test.test(...) == 101 namespace Test func test() -> int { const X = 1 var outer = X if true { const X = 100 outer = outer + X } return outer } ``` ## ILEmitterTests_Const__Body_Const_In_For_Range_Start (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Body_Const_In_For_Range_Start topic: const status: verified // verified behavior: Test.test(...) == 12 namespace Test func test() -> int { const FROM = 3 var sum = 0 for i in FROM..6 { sum = sum + i } return sum } ``` ## ILEmitterTests_Const__Static_Func_Const_Block_Member (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Static_Func_Const_Block_Member topic: const status: verified // verified behavior: Test.test(...) == 50 namespace Test static func Caps { const MAX_USERS = 50 func limit() -> int = MAX_USERS } func test() -> int = Caps.limit() ``` ## ILEmitterTests_Const__RefData_Const_Member (const, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::RefData_Const_Member topic: const status: unverified // verified behavior: Test.test(...) == 3 namespace Test ref data Config { const VERSION = 3 init() {} func version() -> int = self.VERSION } func test() -> int { let c = Config() return c.version() } ``` ## ILEmitterTests_Const__Toplevel_Const_References_Another_Const (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_References_Another_Const topic: const status: verified // verified behavior: Test.test(...) == 10 namespace Test const A = 5 const B = A * 2 func test() -> int = B ``` ## ILEmitterTests_Const__Body_Const_In_Return_Expression (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Body_Const_In_Return_Expression topic: const status: verified // verified behavior: Test.test(...) == 70 namespace Test func test(n: int) -> int { const SCALE = 10 return n * SCALE } ``` ## ILEmitterTests_Const__Toplevel_Const_Bool_Expression (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_Bool_Expression topic: const status: verified // verified behavior: Test.test(...) == true namespace Test const ON = true const OFF = false func test() -> bool = ON and not OFF ``` ## ILEmitterTests_Const__Toplevel_Const_String_Concat_Folded (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_String_Concat_Folded topic: const status: verified // verified behavior: Test.test(...) == "hello, world" namespace Test const PREFIX = "hello, " const NAME = "world" const GREETING = PREFIX + NAME func test() -> string = GREETING ``` ## ILEmitterTests_Const__Body_Const_Passed_As_Arg (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Body_Const_Passed_As_Arg topic: const status: verified // verified behavior: Test.test(...) == 21 namespace Test func triple(x: int) -> int = x * 3 func test() -> int { const N = 7 return triple(N) } ``` ## ILEmitterTests_Const__Toplevel_Const_In_Comparison (const, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Const.cs::Toplevel_Const_In_Comparison topic: const status: verified // verified behavior: Test.is_big(...) == false namespace Test const THRESHOLD = 100 func is_big(n: int) -> bool = n > THRESHOLD ``` ## PdbTests__NoDebugSymbols_NoPdbFile (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: PdbTests.cs::NoDebugSymbols_NoPdbFile topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func run() -> int { return 42 } ``` ## PdbTests__DebugSymbols_DllStillRunsCorrectly (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: PdbTests.cs::DebugSymbols_DllStillRunsCorrectly topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func add(a: int, b: int) -> int { var result = a + b return result } ``` ## PdbTests__Pdb_HasSequencePoints (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: PdbTests.cs::Pdb_HasSequencePoints topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func compute(x: int) -> int { var a = x + 1 var b = a * 2 return b } ``` ## ILEmitterTests3__IfElse_Picks_Else_Branch (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::IfElse_Picks_Else_Branch topic: core status: verified // verified behavior: Test.test(...) == -1 namespace Test func test(x: int) -> int { if x > 0 { return 1 } else { return -1 } } ``` ## ILEmitterTests3__Else_If_Chain_Three_Way (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Else_If_Chain_Three_Way topic: core status: verified // verified behavior: Test.test(...) == "zero" namespace Test func test(x: int) -> string { if x > 0 { return "pos" } else if x < 0 { return "neg" } else { return "zero" } } ``` ## ILEmitterTests3__Else_If_Chain_Five_Way (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Else_If_Chain_Five_Way topic: core status: verified // verified behavior: Test.grade(...) == "F" namespace Test func grade(s: int) -> string { if s >= 90 { return "A" } else if s >= 80 { return "B" } else if s >= 70 { return "C" } else if s >= 60 { return "D" } else { return "F" } } ``` ## ILEmitterTests3__If_Nested_Inside_If (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::If_Nested_Inside_If topic: core status: verified // verified behavior: Test.test(...) == 3 namespace Test func test(a: int, b: int) -> int { if a > 0 { if b > 0 { return 1 } return 2 } return 3 } ``` ## ILEmitterTests3__For_In_Range_Sums_To_N (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::For_In_Range_Sums_To_N topic: core status: verified // verified behavior: Test.test(...) == 45 namespace Test func test(n: int) -> int { var total = 0 for i in 0..n { total = total + i } return total } ``` ## ILEmitterTests3__For_In_Range_Counts_Iterations (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::For_In_Range_Counts_Iterations topic: core status: verified // verified behavior: Test.test(...) == 100 namespace Test func test(n: int) -> int { var count = 0 for i in 0..n { count = count + 1 } return count } ``` ## ILEmitterTests3__For_In_Range_Starting_At_Nonzero (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::For_In_Range_Starting_At_Nonzero topic: core status: verified // verified behavior: Test.test(...) == 35 namespace Test func test() -> int { var total = 0 for i in 5..10 { total = total + i } return total } ``` ## ILEmitterTests3__Compound_Assign_Plus_Eq (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Compound_Assign_Plus_Eq topic: core status: verified // verified behavior: Test.test(...) == 18 namespace Test func test() -> int { var x = 10 x += 5 x += 3 return x } ``` ## ILEmitterTests3__Compound_Assign_Minus_Eq (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Compound_Assign_Minus_Eq topic: core status: verified // verified behavior: Test.test(...) == 70 namespace Test func test() -> int { var x = 100 x -= 30 return x } ``` ## ILEmitterTests3__Compound_Assign_Mul_Eq (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Compound_Assign_Mul_Eq topic: core status: verified // verified behavior: Test.test(...) == 12 namespace Test func test() -> int { var x = 3 x *= 4 return x } ``` ## ILEmitterTests3__Compound_Assign_Div_Eq (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Compound_Assign_Div_Eq topic: core status: verified // verified behavior: Test.test(...) == 25 namespace Test func test() -> int { var x = 100 x /= 4 return x } ``` ## ILEmitterTests3__Compound_Assign_In_Loop_Sum (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Compound_Assign_In_Loop_Sum topic: core status: verified // verified behavior: Test.test(...) == 55 namespace Test func test(n: int) -> int { var total = 0 var i = 0 while i < n { total += i + 1 i += 1 } return total } ``` ## ILEmitterTests3__Ternary_Basic (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Ternary_Basic topic: core status: verified // verified behavior: Test.test(...) == "neg" namespace Test func test(x: int) -> string = x > 0 ? "pos" : "neg" ``` ## ILEmitterTests3__Ternary_With_Int_Return (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Ternary_With_Int_Return topic: core status: verified // verified behavior: Test.abs(...) == 7 namespace Test func abs(n: int) -> int = n > 0 ? n : 0 - n ``` ## ILEmitterTests3__Ternary_Nested (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Ternary_Nested topic: core status: verified // verified behavior: Test.sign(...) == 0 namespace Test func sign(n: int) -> int = n > 0 ? 1 : n < 0 ? -1 : 0 ``` ## ILEmitterTests3__Tuple_Let_Destructure_Two_Element (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Tuple_Let_Destructure_Two_Element topic: core status: verified // verified behavior: Test.test(...) == 73 namespace Test func swap(a: int, b: int) -> (int, int) = (b, a) func test() -> int { let (x, y) = swap(3, 7) return x * 10 + y } ``` ## ILEmitterTests3__Tuple_Let_Destructure_Three_Element (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Tuple_Let_Destructure_Three_Element topic: core status: verified // verified behavior: Test.test(...) == 321 namespace Test func triple() -> (int, int, int) = (1, 2, 3) func test() -> int { let (a, b, c) = triple() return a + b * 10 + c * 100 } ``` ## ILEmitterTests3__Tuple_Mixed_Types (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Tuple_Mixed_Types topic: core status: verified // verified behavior: Test.test(...) == "yes:42" namespace Test func mixed() -> (int, string, bool) = (42, "yes", true) func test() -> string { let (n, s, b) = mixed() return s + ":" + n.ToString() } ``` ## ILEmitterTests3__Match_Expression_Returns_Value (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Match_Expression_Returns_Value topic: choice status: verified // verified behavior: Test.describe(...) == "fail" namespace Test enum Code { ok, warn, fail } func describe(c: Code) -> string = match (c: Code) { .ok { "ok" } .warn { "warn" } .fail { "fail" } default { "?" } } ``` ## ILEmitterTests3__Match_Literal_Int_Patterns (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Match_Literal_Int_Patterns topic: choice status: verified // verified behavior: Test.http(...) == "unknown" namespace Test func http(code: int) -> string = match code { 200 { "ok" } 404 { "not found" } 500 { "server error" } default { "unknown" } } ``` ## ILEmitterTests3__Match_Literal_String_Patterns (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Match_Literal_String_Patterns topic: choice status: verified // verified behavior: Test.role(...) == 0 namespace Test func role(name: string) -> int = match name { "admin" { 100 } "guest" { 1 } default { 0 } } ``` ## ILEmitterTests3__Match_Bool_Patterns (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Match_Bool_Patterns topic: choice status: verified // verified behavior: Test.state(...) == "off" namespace Test func state(b: bool) -> string = match b { true { "on" } false { "off" } } ``` ## ILEmitterTests3__Match_Choice_With_Payload_Destructures (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Match_Choice_With_Payload_Destructures topic: choice status: verified // verified behavior: Test.test(...) == 42 namespace Test choice Maybe { none some(value: int) } func unwrap(m: Maybe, def: int) -> int = match (m: Maybe) { .none { def } .some(v) { v } default { def } } func test() -> int = unwrap(Maybe.some(42), 0) ``` ## ILEmitterTests3__Match_Choice_Multiple_Variants_With_Payloads (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Match_Choice_Multiple_Variants_With_Payloads topic: choice status: verified // verified behavior: Test.test(...) == "num=42|word=foo" namespace Test choice Token { plus minus number(value: int) word(name: string) } func describe(t: Token) -> string = match (t: Token) { .plus { "+" } .minus { "-" } .number(n) { "num=" + n.ToString() } .word(w) { "word=" + w } default { "?" } } func test() -> string { return describe(Token.number(42)) + "|" + describe(Token.word("foo")) } ``` ## ILEmitterTests3__Function_Pointer_Param_Called_Via_Calli (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_Pointer_Param_Called_Via_Calli topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test func apply(f: &(int -> int), n: int) -> int = f(n) func double_it(x: int) -> int = x * 2 func test() -> int = apply(&double_it, 21) ``` ## ILEmitterTests3__Function_Pointer_Two_Args (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_Pointer_Two_Args topic: delegates-events status: verified // verified behavior: Test.test(...) == 37 namespace Test func apply(f: &(int, int -> int), a: int, b: int) -> int = f(a, b) func add(x: int, y: int) -> int = x + y func mul(x: int, y: int) -> int = x * y func test() -> int = apply(&add, 3, 4) + apply(&mul, 5, 6) ``` ## ILEmitterTests3__Closure_Captures_Var_For_Mutation (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Closure_Captures_Var_For_Mutation topic: core status: verified // verified behavior: Test.test(...) == 3 namespace Test func test() -> int { var total = 0 let inc = func() { total = total + 1 } inc() inc() inc() return total } ``` ## ILEmitterTests3__Closure_Accumulator_In_Loop (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Closure_Accumulator_In_Loop topic: core status: verified // verified behavior: Test.test(...) == 15 namespace Test func test() -> int { var sum = 0 let add = func(x: int) { sum = sum + x } for i in 1..6 { add(i) } return sum } ``` ## ILEmitterTests3__Closure_Captures_Let_For_Read (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Closure_Captures_Let_For_Read topic: core status: verified // verified behavior: Test.test(...) == 220 namespace Test func test() -> int { let base_val = 100 let with_base = func(x: int) -> int = base_val + x return with_base(5) + with_base(15) } ``` ## ILEmitterTests3__Arrow_Lambda_Single_Param (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Arrow_Lambda_Single_Param topic: delegates-events status: verified // verified behavior: Test.test(...) == 25 namespace Test func apply(x: int, f: &(int -> int)) -> int = f(x) func test() -> int { let sq: &(int -> int) = (x) => x * x return apply(5, sq) } ``` ## ILEmitterTests3__Arrow_Lambda_Two_Params (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Arrow_Lambda_Two_Params topic: delegates-events status: verified // verified behavior: Test.test(...) == 10 namespace Test func apply(a: int, b: int, f: &(int, int -> int)) -> int = f(a, b) func test() -> int { let add: &(int, int -> int) = (a, b) => a + b return apply(3, 7, add) } ``` ## ILEmitterTests3__Arrow_Lambda_Zero_Params (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Arrow_Lambda_Zero_Params topic: core status: unverified // verified behavior: Test.test(...) == 7 namespace Test func test() -> int { let seven = () => 7 return seven() } ``` ## ILEmitterTests3__Data_With_Single_Field_Update (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_With_Single_Field_Update topic: data status: verified // verified behavior: Test.test(...) == 1004 namespace Test data P { x: int, y: int } func test() -> int { let p = P { x: 3, y: 4 } let q = p with { x: 10 } return q.x * 100 + q.y } ``` ## ILEmitterTests3__Data_With_Preserves_Other_Fields (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_With_Preserves_Other_Fields topic: data status: verified // verified behavior: Test.test(...) == 28 namespace Test data Cfg { a: int, b: int, c: int, d: int } func test() -> int { let c = Cfg { a: 1, b: 2, c: 3, d: 4 } let c2 = c with { b: 20 } return c2.a + c2.b + c2.c + c2.d } ``` ## ILEmitterTests3__Data_With_Used_In_Return (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_With_Used_In_Return topic: data status: verified // verified behavior: Test.test(...) == 15 namespace Test data P { x: int, y: int } func translate(p: P, dx: int) -> P = p with { x: p.x + dx } func test() -> int { let start = P { x: 0, y: 5 } let moved = start.translate(10) return moved.x + moved.y } ``` ## ILEmitterTests3__Generic_Pair_Construction (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Generic_Pair_Construction topic: data status: verified // verified behavior: Test.test(...) == 7 namespace Test data Pair { first: A, second: B } func test() -> int { let p = Pair { first: 3, second: 4 } return p.first + p.second } ``` ## ILEmitterTests3__Generic_Pair_String_Int (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Generic_Pair_String_Int topic: data status: verified // verified behavior: Test.test(...) == "x7" namespace Test data Pair { first: A, second: B } func test() -> string { let p = Pair { first: "x", second: 7 } return p.first + p.second.ToString() } ``` ## ILEmitterTests3__RefData_Init_Stores_Param_To_Field (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::RefData_Init_Stores_Param_To_Field topic: data status: verified // verified behavior: Test.test(...) == 42 namespace Test ref data Box { pub n: int init(value: int) { self.n = value } } func test() -> int { let b = Box(42) return b.n } ``` ## ILEmitterTests3__RefData_Instance_Method_Accesses_Self_Field (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::RefData_Instance_Method_Accesses_Self_Field topic: data status: verified // verified behavior: Test.test(...) == 3 namespace Test ref data Counter { var n: int init() { self.n = 0 } func bump() { self.n = self.n + 1 } func value() -> int = self.n } func test() -> int { let c = Counter() c.bump() c.bump() c.bump() return c.value() } ``` ## ILEmitterTests3__RefData_Multi_Field_Construction (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::RefData_Multi_Field_Construction topic: data status: verified // verified behavior: Test.test(...) == 321 namespace Test ref data Point3 { pub x: int pub y: int pub z: int init(a: int, b: int, c: int) { self.x = a self.y = b self.z = c } } func test() -> int { let p = Point3(1, 2, 3) return p.x + p.y * 10 + p.z * 100 } ``` ## ILEmitterTests3__Virtual_Method_Default_Used_When_Not_Overridden (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Virtual_Method_Default_Used_When_Not_Overridden topic: inheritance status: verified // verified behavior: Test.test(...) == "noise" namespace Test open ref data Animal { init() {} virtual func sound() -> string = "noise" } func test() -> string { let a = Animal() return a.sound() } ``` ## ILEmitterTests3__Virtual_Method_Override_Wins (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Virtual_Method_Override_Wins topic: inheritance status: verified // verified behavior: Test.test(...) == "woof" namespace Test open ref data Animal { init() {} virtual func sound() -> string = "noise" } ref data Dog : Animal { init() : base() {} : func sound() -> string = "woof" } func test() -> string { let d = Dog() return d.sound() } ``` ## ILEmitterTests3__Abstract_Method_Implemented_By_Subclass (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Abstract_Method_Implemented_By_Subclass topic: inheritance status: verified // verified behavior: Test.test(...) == 25 namespace Test abstract ref data Shape { init() {} abstract func area() -> int } ref data Square : Shape { pub side: int init(s: int) : base() { self.side = s } : func area() -> int = self.side * self.side } func test() -> int { let sq = Square(5) return sq.area() } ``` ## ILEmitterTests3__Inheritance_Base_Constructor_With_Args (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Inheritance_Base_Constructor_With_Args topic: inheritance status: verified // verified behavior: Test.test(...) == "alice" namespace Test open ref data Named { pub name: string init(name: string) { self.name = name } } ref data Greet : Named { init(name: string) : base(name) {} } func test() -> string { let g = Greet("alice") return g.name } ``` ## ILEmitterTests3__StaticFunc_Const_Field_Read (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::StaticFunc_Const_Field_Read topic: static-func status: verified // verified behavior: Test.test(...) == 3142 namespace Test static func Math { let PI_TIMES_THOUSAND: int = 3142 } func test() -> int = Math.PI_TIMES_THOUSAND ``` ## ILEmitterTests3__StaticFunc_Method_Call (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::StaticFunc_Method_Call topic: static-func status: verified // verified behavior: Test.test(...) == 42 namespace Test static func Util { func plus_one(n: int) -> int = n + 1 } func test() -> int = Util.plus_one(41) ``` ## ILEmitterTests3__StaticFunc_Multiple_Methods (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::StaticFunc_Multiple_Methods topic: static-func status: verified // verified behavior: Test.test(...) == 17 namespace Test static func Geo { func square(n: int) -> int = n * n func cube(n: int) -> int = n * n * n } func test() -> int = Geo.square(3) + Geo.cube(2) ``` ## ILEmitterTests3__Result_Ok_Construction_And_Unwrap (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Result_Ok_Construction_And_Unwrap topic: result status: verified // verified behavior: Test.test(...) == 42 namespace Test func produce(n: int) -> Result = ok(n) func test() -> int { let r = produce(42) return r.Value } ``` ## ILEmitterTests3__Result_Err_Construction (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Result_Err_Construction topic: result status: verified // verified behavior: Test.test(...) == true namespace Test func produce(n: int) -> Result { if n < 0 { return error("negative") } return ok(n) } func test() -> bool { let r = produce(-1) return r.IsError } ``` ## ILEmitterTests3__Defer_Single_Block_Runs_On_Exit (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Defer_Single_Block_Runs_On_Exit topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func test() -> int { var x = 0 defer { x = 1 } return x } ``` ## ILEmitterTests3__Interface_Method_Resolution_On_Data (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Interface_Method_Resolution_On_Data topic: data status: verified // verified behavior: Test.test(...) == 42 namespace Test interface IGet { func get() -> int } data Box : IGet { v: int } func get(b: Box) -> int = b.v func test() -> int { let b = Box { v: 42 } return b.get() } ``` ## ILEmitterTests3__Interface_Polymorphic_Param (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Interface_Polymorphic_Param topic: data status: verified // verified behavior: Test.test(...) == 30 namespace Test interface IGet { func get() -> int } data A : IGet { x: int } data B : IGet { y: int } func get(a: A) -> int = a.x func get(b: B) -> int = b.y func consume(g: IGet) -> int = g.get() func test() -> int { let a = A { x: 10 } let b = B { y: 20 } return consume(a) + consume(b) } ``` ## ILEmitterTests3__HeapPointer_To_Data_Carries_Value (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::HeapPointer_To_Data_Carries_Value topic: pointers status: verified // verified behavior: Test.test(...) == 14 namespace Test data Atom { n: int } func test() -> int { let a: *Atom = new Atom { n: 7 } return a.n + a.n } ``` ## ILEmitterTests3__HeapPointer_Nil_Comparison_True (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::HeapPointer_Nil_Comparison_True topic: pointers status: verified // verified behavior: Test.test(...) == true namespace Test data Atom { n: int } func test() -> bool { let a: *Atom = nil return a == nil } ``` ## ILEmitterTests3__HeapPointer_NonNil_Comparison_False (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::HeapPointer_NonNil_Comparison_False topic: pointers status: verified // verified behavior: Test.test(...) == false namespace Test data Atom { n: int } func test() -> bool { let a: *Atom = new Atom { n: 1 } return a == nil } ``` ## ILEmitterTests3__Enum_Cases_Have_Sequential_Values (enum, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Enum_Cases_Have_Sequential_Values topic: enum status: verified // verified behavior: Test.test(...) == 210 namespace Test enum Code { a, b, c } func ord(c: Code) -> int { if c == .a { return 0 } if c == .b { return 1 } if c == .c { return 2 } return -1 } func test() -> int { return ord(.a) + ord(.b) * 10 + ord(.c) * 100 } ``` ## ILEmitterTests3__Enum_Equality (enum, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Enum_Equality topic: enum status: unverified // verified behavior: Test.test(...) == true namespace Test enum Code { a, b, c } func test() -> bool { let x = Code.a let y = Code.a return x == y } ``` ## ILEmitterTests3__String_Length_Comparison (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::String_Length_Comparison topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(s: string) -> bool = s.Length > 3 ``` ## ILEmitterTests3__String_Empty_Length_Zero (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::String_Empty_Length_Zero topic: core status: verified // verified behavior: Test.test(...) == 0 namespace Test func test() -> int = "".Length ``` ## ILEmitterTests3__Int_Max_Plus_One_Overflows (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Int_Max_Plus_One_Overflows topic: core status: verified // verified behavior: Test.test(...) == -2147483648 namespace Test func test() -> int { let max = 2147483647 return max + 1 } ``` ## ILEmitterTests3__Int_Division_Truncates (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Int_Division_Truncates topic: core status: verified // verified behavior: Test.test(...) == 3 namespace Test func test() -> int = 7 / 2 ``` ## ILEmitterTests3__Float_Division_Real (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Float_Division_Real topic: core status: verified // verified behavior: Test.test(...) == 3.5 namespace Test func test() -> double = 7.0 / 2.0 ``` ## ILEmitterTests3__Sum_From_1_To_100 (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Sum_From_1_To_100 topic: core status: verified // verified behavior: Test.test(...) == 5050 namespace Test func test() -> int { var total = 0 for i in 1..101 { total = total + i } return total } ``` ## ILEmitterTests3__Power_Recursive (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Power_Recursive topic: core status: verified // verified behavior: Test.pow(...) == 125 namespace Test func pow(base: int, exp: int) -> int { if exp == 0 { return 1 } return base * pow(base, exp - 1) } ``` ## ILEmitterTests3__Ackermann_Small_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Ackermann_Small_Pin topic: core status: verified // verified behavior: Test.ack(...) == 7 namespace Test func ack(m: int, n: int) -> int { if m == 0 { return n + 1 } if n == 0 { return ack(m - 1, 1) } return ack(m - 1, ack(m, n - 1)) } ``` ## ILEmitterTests3__If_No_Else_Falls_Through_Cleanly (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::If_No_Else_Falls_Through_Cleanly topic: core status: verified // verified behavior: Test.test(...) == 10 namespace Test func test(flag: bool) -> int { var x = 10 if flag { x = 100 } return x } ``` ## ILEmitterTests3__Data_Field_Read_After_Local_Assign (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_Field_Read_After_Local_Assign topic: data status: verified // verified behavior: Test.test(...) == 12 namespace Test data P { x: int, y: int } func test() -> int { var p = P { x: 0, y: 0 } p.x = 5 p.y = 7 return p.x + p.y } ``` ## ILEmitterTests3__If_With_Compound_Condition_And (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::If_With_Compound_Condition_And topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(a: int, b: int) -> bool { if a > 0 && b > 0 { return true } return false } ``` ## ILEmitterTests3__If_With_Compound_Condition_Or (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::If_With_Compound_Condition_Or topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(a: int, b: int) -> bool { if a > 0 || b > 0 { return true } return false } ``` ## ILEmitterTests3__If_With_Not_Operator (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::If_With_Not_Operator topic: core status: verified // verified behavior: Test.test(...) == 1 namespace Test func test(b: bool) -> int { if !b { return 1 } return 0 } ``` ## ILEmitterTests3__While_With_Break_Exits_Early (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::While_With_Break_Exits_Early topic: core status: verified // verified behavior: Test.test(...) == 5 namespace Test func test() -> int { var i = 0 while true { if i >= 5 { break } i = i + 1 } return i } ``` ## ILEmitterTests3__While_With_Continue_Skips_Iteration (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::While_With_Continue_Skips_Iteration topic: core status: verified // verified behavior: Test.test(...) == 25 namespace Test func test() -> int { var sum = 0 var i = 0 while i < 10 { i = i + 1 if i % 2 == 0 { continue } sum = sum + i } return sum } ``` ## ILEmitterTests3__Function_Returns_RefData_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_Returns_RefData_Pin topic: data status: verified // verified behavior: Test.test(...) == 7 namespace Test ref data Card { pub face: int init(f: int) { self.face = f } } func make(n: int) -> Card = Card(n) func test() -> int { let c = make(7) return c.face } ``` ## ILEmitterTests3__Variable_Read_In_Inner_Block (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Variable_Read_In_Inner_Block topic: core status: verified // verified behavior: Test.test(...) == 100 namespace Test func test() -> int { let outer = 100 var x = 0 if outer > 50 { x = outer } return x } ``` ## ILEmitterTests3__Function_Mixed_Param_Types (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_Mixed_Param_Types topic: core status: verified // verified behavior: Test.test(...) == "foo" namespace Test func test(a: int, b: bool, c: string) -> string { if b { return c + ":" + a.ToString() } return c } ``` ## ILEmitterTests3__Choice_Bare_Variants_Default_Arm (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Choice_Bare_Variants_Default_Arm topic: choice status: verified // verified behavior: Test.test(...) == "yes" namespace Test choice Light { off, on } func test() -> string { let l = Light.on() match (l: Light) { .on { return "yes" } default { return "no" } } return "unreachable" } ``` ## ILEmitterTests3__Choice_Helper_Constructs_Variant (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Choice_Helper_Constructs_Variant topic: choice status: verified // verified behavior: Test.test(...) == 1 namespace Test choice Status { idle, busy } func make_busy() -> Status = Status.busy() func test() -> int { let s = make_busy() match (s: Status) { .busy { return 1 } default { return 0 } } return -1 } ``` ## ILEmitterTests3__RefData_Field_Mutation_Persists (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::RefData_Field_Mutation_Persists topic: data status: verified // verified behavior: Test.test(...) == 15 namespace Test ref data Bag { var capacity: int init(c: int) { self.capacity = c } } func test() -> int { let b = Bag(0) b.capacity = 10 b.capacity = b.capacity + 5 return b.capacity } ``` ## ILEmitterTests3__Void_Returning_Function_Compiles_And_Runs (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Void_Returning_Function_Compiles_And_Runs topic: core status: verified // verified behavior: Test.test(...) == 0 namespace Test func noop() { let x = 1 } func test() -> int { noop() return 0 } ``` ## ILEmitterTests3__Recursion_Sum_Down_To_Zero (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Recursion_Sum_Down_To_Zero topic: core status: verified // verified behavior: Test.sum_down(...) == 5050 namespace Test func sum_down(n: int) -> int { if n == 0 { return 0 } return n + sum_down(n - 1) } ``` ## ILEmitterTests3__If_Else_Returning_String (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::If_Else_Returning_String topic: core status: verified // verified behavior: Test.test(...) == "negative" namespace Test func test(n: int) -> string { if n == 0 { return "zero" } else if n > 0 { return "positive" } else { return "negative" } } ``` ## ILEmitterTests3__Sum_Even_Numbers_Below_N (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Sum_Even_Numbers_Below_N topic: core status: verified // verified behavior: Test.test(...) == 2450 namespace Test func test(n: int) -> int { var total = 0 for i in 0..n { if i % 2 == 0 { total = total + i } } return total } ``` ## ILEmitterTests3__Product_Of_Range (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Product_Of_Range topic: core status: verified // verified behavior: Test.product(...) == 720 namespace Test func product(lo: int, hi: int) -> int { var p = 1 for i in lo..hi { p = p * i } return p } ``` ## ILEmitterTests3__Count_Digits_Iterative (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Count_Digits_Iterative topic: core status: verified // verified behavior: Test.count_digits(...) == 6 namespace Test func count_digits(n: int) -> int { if n == 0 { return 1 } var x = n var count = 0 while x > 0 { count = count + 1 x = x / 10 } return count } ``` ## ILEmitterTests3__Min_Of_Three_Values (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Min_Of_Three_Values topic: core status: verified // verified behavior: Test.min3(...) == 2 namespace Test func min3(a: int, b: int, c: int) -> int { var m = a if b < m { m = b } if c < m { m = c } return m } ``` ## ILEmitterTests3__Max_Of_Three_Values (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Max_Of_Three_Values topic: core status: verified // verified behavior: Test.max3(...) == 9 namespace Test func max3(a: int, b: int, c: int) -> int { var m = a if b > m { m = b } if c > m { m = c } return m } ``` ## ILEmitterTests3__Linear_Search_Idiom (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Linear_Search_Idiom topic: core status: verified // verified behavior: Test.contains(...) == true namespace Test func contains(target: int, lo: int, hi: int) -> bool { var i = lo while i < hi { if i == target { return true } i = i + 1 } return false } ``` ## ILEmitterTests3__Binary_Search_Returns_Position (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Binary_Search_Returns_Position topic: core status: verified // verified behavior: Test.find_in_sorted(...) == -1 namespace Test func find_in_sorted(target: int, n: int) -> int { var lo = 0 var hi = n while lo < hi { let mid = (lo + hi) / 2 if mid == target { return mid } if mid < target { lo = mid + 1 } if mid > target { hi = mid } } return -1 } ``` ## ILEmitterTests3__Function_Composition_Manual (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_Composition_Manual topic: core status: verified // verified behavior: Test.test(...) == 42 namespace Test func double_it(x: int) -> int = x * 2 func increment(x: int) -> int = x + 1 func test() -> int { return double_it(increment(20)) } ``` ## ILEmitterTests3__Function_Call_Inside_Expression (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_Call_Inside_Expression topic: core status: verified // verified behavior: Test.test(...) == 25 namespace Test func sq(x: int) -> int = x * x func test() -> int { return sq(3) + sq(4) } ``` ## ILEmitterTests3__Nested_Function_Calls_Three_Deep (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Nested_Function_Calls_Three_Deep topic: core status: verified // verified behavior: Test.test(...) == 19 namespace Test func a(x: int) -> int = x + 1 func b(x: int) -> int = a(x) * 2 func c(x: int) -> int = b(x) - 3 func test() -> int = c(10) ``` ## ILEmitterTests3__Data_Equality_Field_By_Field (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_Equality_Field_By_Field topic: data status: verified // verified behavior: Test.test(...) == 1 namespace Test data P { x: int, y: int } func test() -> int { let a = P { x: 1, y: 2 } let b = P { x: 1, y: 2 } if a.x == b.x && a.y == b.y { return 1 } return 0 } ``` ## ILEmitterTests3__Data_Composite_With_String_Field (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_Composite_With_String_Field topic: data status: verified // verified behavior: Test.test(...) == "alice:30" namespace Test data User { name: string, age: int } func test() -> string { let u = User { name: "alice", age: 30 } return u.name + ":" + u.age.ToString() } ``` ## ILEmitterTests3__Data_Multiple_Construction_Sites (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_Multiple_Construction_Sites topic: data status: verified // verified behavior: Test.test(...) == 21 namespace Test data Coord { x: int, y: int } func test() -> int { let a = Coord { x: 1, y: 2 } let b = Coord { x: 3, y: 4 } let c = Coord { x: 5, y: 6 } return a.x + b.x + c.x + a.y + b.y + c.y } ``` ## ILEmitterTests3__StaticFunc_Multiple_Const_Fields (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::StaticFunc_Multiple_Const_Fields topic: static-func status: verified // verified behavior: Test.test(...) == 3032 namespace Test static func Config { let WIDTH: int = 1920 let HEIGHT: int = 1080 let DEPTH: int = 32 } func test() -> int = Config.WIDTH + Config.HEIGHT + Config.DEPTH ``` ## ILEmitterTests3__StaticFunc_Const_String_Field (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::StaticFunc_Const_String_Field topic: static-func status: verified // verified behavior: Test.test(...) == "anonymous" namespace Test static func Names { let DEFAULT: string = "anonymous" } func test() -> string = Names.DEFAULT ``` ## ILEmitterTests3__Inheritance_Three_Level_Chain_Pin (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Inheritance_Three_Level_Chain_Pin topic: inheritance status: verified // verified behavior: Test.test(...) == "dog" namespace Test open ref data Animal { pub kind: string init(k: string) { self.kind = k } } open ref data Mammal : Animal { init(k: string) : base(k) {} } ref data Dog : Mammal { init() : base("dog") {} } func test() -> string { let d = Dog() return d.kind } ``` ## ILEmitterTests3__Interface_Method_Returns_Bool (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Interface_Method_Returns_Bool topic: data status: verified // verified behavior: Test.test(...) == true namespace Test interface ITest { func passes() -> bool } data Suite : ITest { flag: bool } func passes(s: Suite) -> bool = s.flag func test() -> bool { let s = Suite { flag: true } return s.passes() } ``` ## ILEmitterTests3__Long_Loop_Counts_To_1000 (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Long_Loop_Counts_To_1000 topic: core status: verified // verified behavior: Test.test(...) == 1000 namespace Test func test() -> int { var i = 0 var count = 0 while i < 1000 { count = count + 1 i = i + 1 } return count } ``` ## ILEmitterTests3__Nested_While_Sum_Multiplication_Table (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Nested_While_Sum_Multiplication_Table topic: core status: verified // verified behavior: Test.test(...) == 36 namespace Test func test() -> int { var total = 0 var i = 1 while i <= 3 { var j = 1 while j <= 3 { total = total + i * j j = j + 1 } i = i + 1 } return total } ``` ## ILEmitterTests3__Nested_For_In_Range_Sum (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Nested_For_In_Range_Sum topic: core status: verified // verified behavior: Test.test(...) == 36 namespace Test func test() -> int { var total = 0 for i in 1..4 { for j in 1..4 { total = total + i * j } } return total } ``` ## ILEmitterTests3__RefData_Virtual_Method_Overridden_Multiple_Levels_Pin (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::RefData_Virtual_Method_Overridden_Multiple_Levels_Pin topic: inheritance status: verified // verified behavior: Test.test(...) == "ABC" namespace Test open ref data A { init() {} virtual func name() -> string = "A" } open ref data B : A { init() : base() {} : func name() -> string = "B" } ref data C : B { init() : base() {} : func name() -> string = "C" } func test() -> string { let a = A() let b = B() let c = C() return a.name() + b.name() + c.name() } ``` ## ILEmitterTests3__Function_With_Six_Params (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_With_Six_Params topic: core status: verified // verified behavior: Test.test(...) == 21 namespace Test func test(a: int, b: int, c: int, d: int, e: int, f: int) -> int = a + b + c + d + e + f ``` ## ILEmitterTests3__Bool_Returned_From_Function_Used_In_If (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Bool_Returned_From_Function_Used_In_If topic: core status: verified // verified behavior: Test.test(...) == "not pos" namespace Test func is_positive(n: int) -> bool = n > 0 func test(n: int) -> string { if is_positive(n) { return "pos" } return "not pos" } ``` ## ILEmitterTests3__Compound_Conditions_In_While (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Compound_Conditions_In_While topic: core status: verified // verified behavior: Test.test(...) == 10 namespace Test func test() -> int { var i = 0 var count = 0 while i < 10 && count < 5 { i = i + 1 if i % 2 == 0 { count = count + 1 } } return i } ``` ## ILEmitterTests3__For_Range_Single_Iteration (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::For_Range_Single_Iteration topic: core status: verified // verified behavior: Test.test(...) == 5 namespace Test func test() -> int { var sum = 0 for i in 5..6 { sum = sum + i } return sum } ``` ## ILEmitterTests3__Comparison_Result_Of_Arithmetic (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Comparison_Result_Of_Arithmetic topic: core status: verified // verified behavior: Test.test(...) == false namespace Test func test(a: int, b: int) -> bool = a * 2 > b + 5 ``` ## ILEmitterTests3__Tree_Structure_Compiles_Pin (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Tree_Structure_Compiles_Pin topic: pointers status: verified // verified behavior: Test.test(...) == 11 namespace Test data Tree { value: int, left: *Tree, right: *Tree } func test() -> int { let leaf = new Tree { value: 1, left: nil, right: nil } let root = new Tree { value: 10, left: leaf, right: nil } return root.value + root.left.value } ``` ## ILEmitterTests3__LinkedList_Sum_Pin (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::LinkedList_Sum_Pin topic: pointers status: verified // verified behavior: Test.test(...) == 6 namespace Test data Node { value: int, next: *Node } func sum_list(head: *Node) -> int { var total = 0 var cursor = head while cursor != nil { total = total + cursor.value cursor = cursor.next } return total } func test() -> int { let c = new Node { value: 3, next: nil } let b = new Node { value: 2, next: c } let a = new Node { value: 1, next: b } return sum_list(a) } ``` ## ILEmitterTests3__Data_With_All_Default_Fields_Compiles (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_With_All_Default_Fields_Compiles topic: data status: verified // verified behavior: Test.test(...) == 0 namespace Test data Empty { } func test() -> int { let e = Empty { } return 0 } ``` ## ILEmitterTests3__Data_Single_Field_Composite (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_Single_Field_Composite topic: data status: verified // verified behavior: Test.test(...) == 99 namespace Test data Wrap { v: int } func test() -> int { let w = Wrap { v: 99 } return w.v } ``` ## ILEmitterTests3__Swap_Pattern_With_Temp (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Swap_Pattern_With_Temp topic: core status: verified // verified behavior: Test.test(...) == 2010 namespace Test func test() -> int { var a = 10 var b = 20 let tmp = a a = b b = tmp return a * 100 + b } ``` ## ILEmitterTests3__Average_Of_Three (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Average_Of_Three topic: core status: verified // verified behavior: Test.avg(...) == 10 namespace Test func avg(a: int, b: int, c: int) -> int = (a + b + c) / 3 ``` ## ILEmitterTests3__Range_Of_Squares (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Range_Of_Squares topic: core status: verified // verified behavior: Test.test(...) == 285 namespace Test func test(n: int) -> int { var sum = 0 for i in 1..n { sum = sum + i * i } return sum } ``` ## ILEmitterTests3__Triangle_Number (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Triangle_Number topic: core status: verified // verified behavior: Test.tri(...) == 5050 namespace Test func tri(n: int) -> int = n * (n + 1) / 2 ``` ## ILEmitterTests3__Parity_Check (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Parity_Check topic: core status: verified // verified behavior: Test.parity(...) == "even" namespace Test func parity(n: int) -> string { if n % 2 == 0 { return "even" } return "odd" } ``` ## ILEmitterTests3__Data_Field_Function_Pointer_Pin (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Data_Field_Function_Pointer_Pin topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test data Op { apply: &(int -> int) } func add_one(x: int) -> int = x + 1 func double_it(x: int) -> int = x * 2 func test() -> int { let op = Op { apply: &add_one } return op.apply(41) } ``` ## ILEmitterTests3__Embedding_Direct_Field_Access_Pin (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Embedding_Direct_Field_Access_Pin topic: data status: verified // verified behavior: Test.test(...) == 100 namespace Test data Inner { value: int } data Outer { pub Inner } func test() -> int { let o = Outer { Inner: Inner { value: 100 } } return o.Inner.value } ``` ## ILEmitterTests3__Sum_Of_Digits_Recursive (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Sum_Of_Digits_Recursive topic: core status: verified // verified behavior: Test.dsum(...) == 45 namespace Test func dsum(n: int) -> int { if n == 0 { return 0 } return n % 10 + dsum(n / 10) } ``` ## ILEmitterTests3__Reverse_Digits_Recursive_Helper_Pin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Reverse_Digits_Recursive_Helper_Pin topic: core status: verified // verified behavior: Test.rev(...) == 0 namespace Test func rev_helper(n: int, acc: int) -> int { if n == 0 { return acc } return rev_helper(n / 10, acc * 10 + n % 10) } func rev(n: int) -> int = rev_helper(n, 0) ``` ## ILEmitterTests3__Function_Tail_Recursive_Style (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Function_Tail_Recursive_Style topic: core status: verified // verified behavior: Test.test(...) == 5050 namespace Test func sum_to(n: int, acc: int) -> int { if n == 0 { return acc } return sum_to(n - 1, acc + n) } func test() -> int = sum_to(100, 0) ``` ## ILEmitterTests3__Skip_Logic_With_Continue (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Skip_Logic_With_Continue topic: core status: verified // verified behavior: Test.test(...) == 18 namespace Test func test() -> int { var collected = 0 var i = 0 while i < 20 { i = i + 1 if i == 7 { continue } if i == 13 { continue } collected = collected + 1 } return collected } ``` ## ILEmitterTests3__Early_Exit_With_Break (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Early_Exit_With_Break topic: core status: verified // verified behavior: Test.first_above(...) == 101 namespace Test func first_above(threshold: int) -> int { var i = 0 while i < 1000 { if i > threshold { break } i = i + 1 } return i } ``` ## ILEmitterTests3__Result_Map_Chain_Pin (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Result_Map_Chain_Pin topic: result status: verified // verified behavior: Test.test(...) == 42 namespace Test func parse(s: string) -> Result { if s == "" { return error("empty") } return ok(42) } func test() -> int { let r = parse("hello") return r.Value } ``` ## ILEmitterTests3__Result_IsOk_Branch (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests3.cs::Result_IsOk_Branch topic: result status: verified // verified behavior: Test.test(...) == -1 namespace Test func produce(b: bool) -> Result { if b { return ok(7) } return error("bad") } func test(b: bool) -> int { let r = produce(b) if r.IsOk { return r.Value } return -1 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Typed_Parses_And_Emits_JobT_Return (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Typed_Parses_And_Emits_JobT_Return topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test task func produce() -> int { return 42 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Returns_Synonym_Also_Works (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Returns_Synonym_Also_Works topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test task func produce() returns int { return 7 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Void_Returns_Job_That_Completes (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Void_Returns_Job_That_Completes topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test task func ping() { } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Returns_String_Job (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Returns_String_Job topic: async status: verified // verified behavior: Test.null(...) == "ok" namespace Test task func tag() -> string { return "ok" } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Returns_Boolean_Job (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Returns_Boolean_Job topic: async status: verified // verified behavior: Test.null(...) == true namespace Test task func check() -> bool { return true } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Body_Computes_Arithmetic (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Body_Computes_Arithmetic topic: async status: verified // verified behavior: Test.null(...) == 13 namespace Test task func sum() -> int { let a = 3 let b = 4 return a * b + 1 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Call_Site_Returns_Job_Typed_Result_To_Caller (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Call_Site_Returns_Job_Typed_Result_To_Caller topic: async status: verified // verified behavior: Test.caller(...) == 5 namespace Test task func produce() -> int { return 5 } func caller() -> int { let j = produce() return j.Wait() } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Wrapper_Invokes_Inner (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Wrapper_Invokes_Inner topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test task func produce() -> int { return 99 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Wrapper_Calls_Job_Spawn (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Wrapper_Calls_Job_Spawn topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test task func produce() -> int { return 7 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Var_Capture_In_Function_Literal_Reports_ES2130 (async, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Var_Capture_In_Function_Literal_Reports_ES2130 topic: async status: verified // verified behavior: reports diagnostic ES2130 namespace Test task func go() { var counter = 0 let bump = func() { counter = counter + 1 } bump() } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Let_Capture_In_Function_Literal_Is_OK (async, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Let_Capture_In_Function_Literal_Is_OK topic: async status: unverified // verified behavior: reports diagnostic ES2130 namespace Test task func go() { let value = 7 let read = func() -> int { return value } let v = read() } ``` ## ILEmitterTests_TaskFunc__RegularFunc_Var_Capture_Is_Not_ES2130 (core, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::RegularFunc_Var_Capture_Is_Not_ES2130 topic: core status: unverified // verified behavior: reports diagnostic ES2130 namespace Test func go() { var counter = 0 let bump = func() { counter = counter + 1 } bump() } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Captures_Let_Across_Boundary_Compiles (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Captures_Let_Across_Boundary_Compiles topic: async status: verified // verified behavior: Test.caller(...) == 11 namespace Test task func produce() -> int { let x = 11 return x } func caller() -> int { return produce().Wait() } ``` ## ILEmitterTests_TaskFunc__TaskFunc_With_Parameters_Reports_NotYetSupported (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_With_Parameters_Reports_NotYetSupported topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test task func with_arg(n: int) -> int { return n } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Job_Cancel_Available (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Job_Cancel_Available topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test task func produce() -> int { return 1 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Multiple_TaskFuncs_In_Same_File (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Multiple_TaskFuncs_In_Same_File topic: async status: verified // verified behavior: Test.caller(...) == 5 namespace Test task func two() -> int { return 2 } task func three() -> int { return 3 } func caller() -> int { return two().Wait() + three().Wait() } ``` ## ILEmitterTests_TaskFunc__Task_Is_Still_Valid_Identifier_Elsewhere (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::Task_Is_Still_Valid_Identifier_Elsewhere topic: core status: verified // verified behavior: Test.go(...) == 11 namespace Test func go(task: int) -> int { return task + 1 } ``` ## ILEmitterTests_TaskFunc__TaskFunc_Two_Independent_Tasks_Wait_Independently (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Two_Independent_Tasks_Wait_Independently topic: async status: verified // verified behavior: Test.caller(...) == 300 namespace Test task func one() -> int { return 100 } task func two() -> int { return 200 } func caller() -> int = one().Wait() + two().Wait() ``` ## ILEmitterTests_TaskFunc__TaskFunc_Multiple_Awaits_Sum_To_Expected (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_TaskFunc.cs::TaskFunc_Multiple_Awaits_Sum_To_Expected topic: async status: verified // verified behavior: Test.caller(...) == 60 namespace Test task func first() -> int { return 10 } task func second() -> int { return 20 } task func third() -> int { return 30 } func caller() -> int = first().Wait() + second().Wait() + third().Wait() ``` ## ILEmitterTests_Delegates__MethodGroup_ToFunc_Local_Invoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::MethodGroup_ToFunc_Local_Invoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test func dbl(x: int) -> int = x * 2 func test() -> int { let f: Func = dbl return f(21) } ``` ## ILEmitterTests_Delegates__MethodGroup_AsArgument_Invoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::MethodGroup_AsArgument_Invoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 10 namespace Test func dbl(x: int) -> int = x * 2 func apply(x: int, f: Func) -> int = f(x) func test() -> int = apply(5, dbl) ``` ## ILEmitterTests_Delegates__MethodGroup_ToExternalNamedDelegate_Bridges (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::MethodGroup_ToExternalNamedDelegate_Bridges topic: delegates-events status: verified // verified behavior: Test.test(...) == true namespace Test func is_even(x: int) -> bool = x % 2 == 0 func test() -> bool { let p: Predicate = is_even return p(4) } ``` ## ILEmitterTests_Delegates__MethodGroup_BindsRealMethod_NotAForwarder (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::MethodGroup_BindsRealMethod_NotAForwarder topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func dbl(x: int) -> int = x * 2 func get() -> Func = dbl ``` ## ILEmitterTests_Delegates__MethodGroup_Unannotated_Let_IsRejected (delegates-events, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::MethodGroup_Unannotated_Let_IsRejected topic: delegates-events status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func dbl(x: int) -> int = x * 2 func test() -> int { let f = dbl return f(21) } ``` ## ILEmitterTests_Delegates__DelegateFunc_EmitsMulticastDelegateSubclass_WithInvoke (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_EmitsMulticastDelegateSubclass_WithInvoke topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test delegate func BinOp(a: int, b: int) -> int ``` ## ILEmitterTests_Delegates__DelegateFunc_AsParam_MethodGroupArg_Invoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_AsParam_MethodGroupArg_Invoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test delegate func BinOp(a: int, b: int) -> int func apply(f: BinOp, a: int, b: int) -> int = f(a, b) func add(a: int, b: int) -> int = a + b func test() -> int = apply(add, 20, 22) ``` ## ILEmitterTests_Delegates__DelegateFunc_MethodGroup_Let_Invoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_MethodGroup_Let_Invoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test delegate func BinOp(a: int, b: int) -> int func add(a: int, b: int) -> int = a + b func test() -> int { let op: BinOp = add return op(19, 23) } ``` ## ILEmitterTests_Delegates__DelegateFunc_Lambda_Let_Invoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_Lambda_Let_Invoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test delegate func BinOp(a: int, b: int) -> int func test() -> int { let op: BinOp = (a, b) => a + b return op(40, 2) } ``` ## ILEmitterTests_Delegates__DelegateFunc_ReturnedAndInvoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_ReturnedAndInvoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test delegate func BinOp(a: int, b: int) -> int func add(a: int, b: int) -> int = a + b func get_op() -> BinOp = add func test() -> int { let op = get_op() return op(13, 29) } ``` ## ILEmitterTests_Delegates__DelegateFunc_IsNominal_NotAForwarder_NotAFunc (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_IsNominal_NotAForwarder_NotAFunc topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test delegate func BinOp(a: int, b: int) -> int func add(a: int, b: int) -> int = a + b func get_op() -> BinOp = add ``` ## ILEmitterTests_Delegates__DelegateFunc_VoidReturn_CapturingLambda_Invoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_VoidReturn_CapturingLambda_Invoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 3 namespace Test delegate func Tick() func run(t: Tick, n: int) { var i = 0 while i < n { t() i += 1 } } func test() -> int { var count = 0 let t: Tick = func() { count += 1 } run(t, 3) return count } ``` ## ILEmitterTests_Delegates__DelegateFunc_ThreeParams_MethodGroup_Invoked (delegates-events, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Delegates.cs::DelegateFunc_ThreeParams_MethodGroup_Invoked topic: delegates-events status: verified // verified behavior: Test.test(...) == 42 namespace Test delegate func Tri(a: int, b: int, c: int) -> int func add3(a: int, b: int, c: int) -> int = a + b + c func test() -> int { let f: Tri = add3 return f(10, 20, 12) } ``` ## TranspilerTests__Transpiles_Data_Choice_And_Functions (choice, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Data_Choice_And_Functions topic: choice status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Auth pub data LoginRequest { email: string password: string } pub choice AuthError { invalidCredentials accountLocked(untilUtc: DateTimeOffset) } pub func makeRequest(email: string, password: string) -> LoginRequest { let req = LoginRequest { email: email password: password } return req } pub func login(req: LoginRequest) -> Result { if req.password == "secret" { return ok(req) } return error(AuthError.invalidCredentials()) } ``` ## TranspilerTests__Reports_Syntax_Diagnostics (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Reports_Syntax_Diagnostics topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Broken pub func nope( -> void { return } ``` ## TranspilerTests__Transpiles_While_For_And_Spawn (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_While_For_And_Spawn topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Worker pub func sumTo(limit: int) -> int { var i = 0 var total = 0 while i <= limit { total = total + i i = i + 1 } return total } pub func sumAll(values: List) -> int { var total = 0 for value in values { total = total + value } return total } pub func start(values: List) -> Job { return spawn { for value in values { Console.WriteLine(value) } } } ``` ## TranspilerTests__Transpiles_ByRef_Parameters (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_ByRef_Parameters topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Counter pub data Counter { value: int } pub func increment(c: *Counter) { c.value += 1 } ``` ## TranspilerTests__Transpiles_Match_On_Choice_Annotated (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Match_On_Choice_Annotated topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Conn pub choice ConnectionState { disconnected connected failed(reason: string) } pub func describe(state: ConnectionState) -> string { match (state: ConnectionState) { .disconnected { return "off" } .connected { return "on" } .failed(reason) { return reason } default { return "?" } } } ``` ## TranspilerTests__Transpiles_Match_Without_Annotation (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Match_Without_Annotation topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Conn pub choice ConnectionState { disconnected connected } pub func describe(state: ConnectionState) -> string { match state { .disconnected { return "off" } .connected { return "on" } default { return "?" } } } ``` ## TranspilerTests__Transpiles_Match_On_MemberAccess_Inferred (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Match_On_MemberAccess_Inferred topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace SM pub choice Status { on, off } pub data Device { status: Status } pub func check(d: Device) -> string { match d.status { .on { return "on" } .off { return "off" } default { return "?" } } } ``` ## TranspilerTests__Transpiles_Defer (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Defer topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace IO pub func process(path: string) -> string { let file = File.Open(path) defer { file.Close() } return file.ReadAll() } ``` ## TranspilerTests__Transpiles_StringInterpolation (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_StringInterpolation topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Greet pub func hello(name: string) -> string { return "hello {name}" } ``` ## TranspilerTests__Transpiles_PlainString_NoInterpolation (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_PlainString_NoInterpolation topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Plain pub func msg() -> string { return "hello world" } ``` ## TranspilerTests__Transpiles_IndexExpression (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_IndexExpression topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Arr pub func first(items: List) -> int { return items[0] } ``` ## TranspilerTests__Transpiles_RangeExpression (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_RangeExpression topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Slice pub func take(s: string, n: int) -> string { return s[..n] } pub func skip(s: string, n: int) -> string { return s[n..] } pub func sub(s: string, a: int, b: int) -> string { return s[a..b] } ``` ## TranspilerTests__Transpiles_IndexFromEnd (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_IndexFromEnd topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Last pub func last(items: List) -> int { return items[^1] } ``` ## TranspilerTests__Transpiles_TryUnwrap_In_Let (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_TryUnwrap_In_Let topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Prop pub func inner(x: int) -> Result { return ok(x) } pub func outer(x: int) -> Result { let val = inner(x)? return ok(val) } ``` ## TranspilerTests__Transpiles_CompoundAssignment (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_CompoundAssignment topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Math pub func sumTo(n: int) -> int { var total = 0 var i = 0 while i <= n { total += i i += 1 } return total } ``` ## TranspilerTests__Transpiles_Chan_Creation (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Chan_Creation topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Audit pub func makeChan() -> Chan { let ch = chan(256) return ch } ``` ## TranspilerTests__Transpiles_Enum_Declaration (enum, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Enum_Declaration topic: enum status: verified // compiles cleanly (no auto-run claim was extracted) namespace Dir pub enum Direction { north south } ``` ## TranspilerTests__Transpiles_Import_Directive (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Import_Directive topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.IO" using "MyNamespace" pub func run() { Console.WriteLine("hello") } ``` ## TranspilerTests__Transpiles_Generic_Function (generics, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Generic_Function topic: generics status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Util func first(items: List) -> T { return items[0] } func swap(a: A, b: B) -> B { return b } ``` ## TranspilerTests__Transpiles_Function_Literal (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Function_Literal topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace FnTest func run(items: List) { items.Sort(func(a: int, b: int) -> int { return a - b }) } ``` ## TranspilerTests__Transpiles_Function_Literal_Assigned_To_Variable (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Function_Literal_Assigned_To_Variable topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace FnVar func run() { let greet = func(name: string) -> string { return "hello {name}" } Console.WriteLine(greet("world")) } ``` ## TranspilerTests__Transpiles_Protocol_And_Conformance (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Protocol_And_Conformance topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Greet interface IGreeter { func greet(name: string) -> string } data Bot : IGreeter { prefix: string } func greet(b: Bot, name: string) -> string { return "{b.prefix} {name}" } ``` ## TranspilerTests__Transpiles_Data_With_External_Interface (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Data_With_External_Interface topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace IO data FileHandle : IDisposable { path: string } func Dispose(h: FileHandle) { Console.WriteLine("closed") } ``` ## TranspilerTests__Transpiles_Derive_Equality (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Derive_Equality topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Eq derive equality data Point { x: int y: int } ``` ## TranspilerTests__Transpiles_Derive_Debug (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Derive_Debug topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Dbg derive debug data Color { r: int g: int b: int } ``` ## TranspilerTests__Transpiles_Generic_Data (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Generic_Data topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Gen data Pair { first: A second: B } func makePair(a: A, b: B) -> Pair { return Pair { first: a, second: b } } ``` ## TranspilerTests__Transpiles_Generic_Choice (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Generic_Choice topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Opt choice Option { some(value: T) none } func unwrap(opt: Option, fallback: T) -> T { match (opt: Option) { .some(value) { return value } default { return fallback } } } ``` ## TranspilerTests__MultiFile_CrossFile_Type_Reference (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::MultiFile_CrossFile_Type_Reference topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Types data Point { x: int y: int } ``` ## TranspilerTests__MultiFile_CrossFile_Instance_Method_Promotion (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::MultiFile_CrossFile_Instance_Method_Promotion topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Types data Counter { value: int } ``` ## TranspilerTests__Classifies_Small_ValueType_As_Struct (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Classifies_Small_ValueType_As_Struct topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Geo data Point { x: int y: int } ``` ## TranspilerTests__Classifies_RefData_As_Class (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Classifies_RefData_As_Class topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Cfg ref data Config { timeout: int } ``` ## TranspilerTests__Classifies_RefField_As_Struct (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Classifies_RefField_As_Struct topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Wrap data Wrapper { name: string } ``` ## TranspilerTests__Classifies_Oversized_As_Struct (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Classifies_Oversized_As_Struct topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Big data Big { a: decimal b: int } ``` ## TranspilerTests__Classifies_Nested_Struct_Within_Threshold (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Classifies_Nested_Struct_Within_Threshold topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Lines data Vec2 { x: float y: float } data Line { a: Vec2 b: Vec2 } ``` ## TranspilerTests__MultiFile_CrossFile_Protocol_Satisfaction (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::MultiFile_CrossFile_Protocol_Satisfaction topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Proto interface IDescribable { func describe() -> string } data Widget : IDescribable { label: string } func describe(w: Widget) -> string { return w.label } ``` ## TranspilerTests__Transpiles_Closure_Captures_Var (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Closure_Captures_Var topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func counter() -> int { var count = 0 let increment = func() { count += 1 } increment() increment() return count } ``` ## TranspilerTests__Transpiles_Closure_Captures_Let (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Closure_Captures_Let topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func make_adder(base: int) -> int { let offset = 10 let add = func(x: int) -> int { return offset + x } return add(base) } ``` ## TranspilerTests__Transpiles_Attribute_On_RefData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Attribute_On_RefData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [Route("/api/users")] [Authorize] ref data UserController { path: string } ``` ## TranspilerTests__Transpiles_Attribute_On_Function (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Attribute_On_Function topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [HttpGet] func getUsers() -> string { return "users" } ``` ## TranspilerTests__Transpiles_Attribute_With_Arguments (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Attribute_With_Arguments topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [MaxLength(100)] ref data Config { name: string } ``` ## TranspilerTests__Transpiles_RefChoice_SealedHierarchy (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_RefChoice_SealedHierarchy topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Expr { literal(value: int) negate(inner: Expr) unit } ``` ## TranspilerTests__Transpiles_RefChoice_Match (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_RefChoice_Match topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Shape { circle(radius: float) square(side: float) } func describe(s: Shape) -> string { match (s: Shape) { .circle(c) { return "circle" } .square(sq) { return "square" } } return "unknown" } ``` ## TranspilerTests__Transpiles_RefChoice_DotCase (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_RefChoice_DotCase topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Option { some(value: int) none } func make() -> Option { return .some(42) } ``` ## TranspilerTests__Transpiles_MultiPayload_RefChoice (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_MultiPayload_RefChoice topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Action { popout(containerId: uint, slotIndex: int) close } ``` ## TranspilerTests__Transpiles_MultiPayload_ValueChoice (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_MultiPayload_ValueChoice topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Msg { text(from: string, body: string) ping } ``` ## TranspilerTests__ExplicitConformance_Satisfied (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::ExplicitConformance_Satisfied topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IRenderable { func render() -> string } ref data Button : IRenderable { label: string } func render(b: Button) -> string { return b.label } ``` ## TranspilerTests__ExplicitConformance_Missing_Method_Reports_Error (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::ExplicitConformance_Missing_Method_Reports_Error topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IRenderable { func render() -> string } ref data Button : IRenderable { label: string } ``` ## TranspilerTests__VirtualDispatch_ProtocolTypedParameter (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::VirtualDispatch_ProtocolTypedParameter topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IWidget { func render() -> string } ref data Button : IWidget { label: string } func render(b: Button) -> string { return b.label } func display(w: IWidget) -> string { return w.render() } ``` ## TranspilerTests__Transpiles_Nullable_Return_Type (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Nullable_Return_Type topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data User { name: string } func find(id: int) -> User? { return nil } ``` ## TranspilerTests__Transpiles_Nullable_Parameter (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Nullable_Parameter topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func process(name: string?) -> int { return 0 } ``` ## TranspilerTests__Transpiles_Init_Constructor (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_Init_Constructor topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Connection { host: string port: int init(h: string, p: int) { host = h port = p } } ``` ## TranspilerTests__Transpiles_MultiPayload_Destructuring (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_MultiPayload_Destructuring topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Action { popout(containerId: uint, slotIndex: int) close } func handle(a: Action) -> int { match (a: Action) { .popout(cid, slot) { return 1 } .close { return 0 } } return 0 } ``` ## TranspilerTests__Transpiles_SinglePayload_Destructuring_BackwardCompat (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_SinglePayload_Destructuring_BackwardCompat topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice State { running(progress: int) stopped } func check(s: State) -> int { match (s: State) { .running(p) { return p } .stopped { return 0 } } return 0 } ``` ## TranspilerTests__ExhaustiveMatch_Warns_Missing_Cases (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::ExhaustiveMatch_Warns_Missing_Cases topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Light { red yellow green } func check(l: Light) -> int { match (l: Light) { .red { return 1 } .yellow { return 2 } } return 0 } ``` ## TranspilerTests__ExhaustiveMatch_No_Warning_When_Complete (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::ExhaustiveMatch_No_Warning_When_Complete topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Light { red yellow green } func check(l: Light) -> int { match (l: Light) { .red { return 1 } .yellow { return 2 } .green { return 3 } } return 0 } ``` ## TranspilerTests__ExhaustiveMatch_No_Warning_With_Default (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::ExhaustiveMatch_No_Warning_With_Default topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Light { red yellow green } func check(l: Light) -> int { match (l: Light) { .red { return 1 } default { return 0 } } return 0 } ``` ## TranspilerTests__BoxingDiag_Warns_ValueType_As_Protocol (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::BoxingDiag_Warns_ValueType_As_Protocol topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IWidget { func render() -> string } data SmallWidget { label: string } func render(w: SmallWidget) -> string { return w.label } func test() -> string { let w: IWidget = SmallWidget { label: "hi" } return w.render() } ``` ## TranspilerTests__BoxingDiag_NoWarn_RefData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::BoxingDiag_NoWarn_RefData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IWidget { func render() -> string } ref data Button : IWidget { label: string } func render(b: Button) -> string { return b.label } func test() -> string { let w: IWidget = Button { label: "ok" } return w.render() } ``` ## TranspilerTests__Transpiles_ValueEmbedding (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: TranspilerTests.cs::Transpiles_ValueEmbedding topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Base { var x: int var y: int } data Widget { Base label: string } func getX() -> int { var w = Widget { x: 10, y: 20, label: "test" } return w.x } ``` ## ILEmitterTests_Coverage_Numerics__Int_Add (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_Add topic: core status: verified // verified behavior: Test.add(...) == 7 namespace Test func add(a: int, b: int) -> int { return a + b } ``` ## ILEmitterTests_Coverage_Numerics__Int_Sub_Mul (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_Sub_Mul topic: core status: verified // verified behavior: Test.go(...) == 54 namespace Test func go() -> int { let a = 10 - 4 return a * 9 } ``` ## ILEmitterTests_Coverage_Numerics__Int_TruncatingDivision (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_TruncatingDivision topic: core status: verified // verified behavior: Test.go(...) == 3 namespace Test func go() -> int { return 7 / 2 } ``` ## ILEmitterTests_Coverage_Numerics__Int_Modulo (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_Modulo topic: core status: verified // verified behavior: Test.go(...) == 1 namespace Test func go() -> int { return 7 % 3 } ``` ## ILEmitterTests_Coverage_Numerics__Int_NegativeModulo_FollowsClr (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_NegativeModulo_FollowsClr topic: core status: verified // verified behavior: Test.go(...) == -1 namespace Test func go() -> int { return -7 % 3 } ``` ## ILEmitterTests_Coverage_Numerics__Int_UnaryMinus (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_UnaryMinus topic: core status: verified // verified behavior: Test.go(...) == -42 namespace Test func go() -> int { let x = 42 return 0 - x } ``` ## ILEmitterTests_Coverage_Numerics__Int_NegativeLiteral (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_NegativeLiteral topic: core status: verified // verified behavior: Test.go(...) == -5 namespace Test func go() -> int { return -5 } ``` ## ILEmitterTests_Coverage_Numerics__Int_UnderscoreSeparators (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_UnderscoreSeparators topic: core status: verified // verified behavior: Test.go(...) == 1_000_000 namespace Test func go() -> int { return 1_000_000 } ``` ## ILEmitterTests_Coverage_Numerics__Int_PrecedenceMulOverAdd (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_PrecedenceMulOverAdd topic: core status: verified // verified behavior: Test.go(...) == 14 namespace Test func go() -> int { return 2 + 3 * 4 } ``` ## ILEmitterTests_Coverage_Numerics__Int_ParenthesizedPrecedence (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_ParenthesizedPrecedence topic: core status: verified // verified behavior: Test.go(...) == 20 namespace Test func go() -> int { return (2 + 3) * 4 } ``` ## ILEmitterTests_Coverage_Numerics__Int_CompoundAssignAll (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_CompoundAssignAll topic: core status: verified // verified behavior: Test.go(...) == 13 namespace Test func go() -> int { var n = 10 n += 5 n -= 2 n *= 2 n /= 2 return n } ``` ## ILEmitterTests_Coverage_Numerics__Long_Add (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Long_Add topic: core status: verified // verified behavior: Test.add(...) == 7_000_000_000L namespace Test func add(a: long, b: long) -> long { return a + b } ``` ## ILEmitterTests_Coverage_Numerics__Long_Multiply (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Long_Multiply topic: core status: verified // verified behavior: Test.mul(...) == 6_000_000_000L namespace Test func mul(a: long, b: long) -> long { return a * b } ``` ## ILEmitterTests_Coverage_Numerics__Uint_Add (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Uint_Add topic: core status: verified // verified behavior: Test.add(...) == 7u namespace Test func add(a: uint, b: uint) -> uint { return a + b } ``` ## ILEmitterTests_Coverage_Numerics__Ulong_Add (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Ulong_Add topic: core status: verified // verified behavior: Test.add(...) == 7ul namespace Test func add(a: ulong, b: ulong) -> ulong { return a + b } ``` ## ILEmitterTests_Coverage_Numerics__Short_Add (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Short_Add topic: core status: verified // verified behavior: Test.add(...) == (short)7 namespace Test func add(a: short, b: short) -> short { return a + b } ``` ## ILEmitterTests_Coverage_Numerics__Byte_Identity (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Byte_Identity topic: core status: verified // verified behavior: Test.echo(...) == (byte)200 namespace Test func echo(b: byte) -> byte { return b } ``` ## ILEmitterTests_Coverage_Numerics__Sbyte_Negative (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Sbyte_Negative topic: core status: verified // verified behavior: Test.echo(...) == (sbyte)-5 namespace Test func echo(b: sbyte) -> sbyte { return b } ``` ## ILEmitterTests_Coverage_Numerics__Double_Add (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_Add topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return 3.0 + 1.5 } ``` ## ILEmitterTests_Coverage_Numerics__Double_Division (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_Division topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return 5.0 / 2.0 } ``` ## ILEmitterTests_Coverage_Numerics__Double_ScientificNotation (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_ScientificNotation topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return 1.0e10 } ``` ## ILEmitterTests_Coverage_Numerics__Float_Add (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Float_Add topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func add(a: float, b: float) -> float { return a + b } ``` ## ILEmitterTests_Coverage_Numerics__Double_CompoundAssign (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_CompoundAssign topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { var x = 4.0 x *= 2.5 return x } ``` ## ILEmitterTests_Coverage_Numerics__Bool_AndOrNot_Symbolic (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Bool_AndOrNot_Symbolic topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return (true && false) || !false } ``` ## ILEmitterTests_Coverage_Numerics__Bool_AndOrNot_Keyword (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Bool_AndOrNot_Keyword topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return (true and false) or not false } ``` ## ILEmitterTests_Coverage_Numerics__Comparison_Operators (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Comparison_Operators topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return 3 < 4 && 4 <= 4 && 5 > 4 && 5 >= 5 && 3 == 3 && 3 != 4 } ``` ## ILEmitterTests_Coverage_Numerics__ShortCircuit_And_DoesNotEvaluateRight (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::ShortCircuit_And_DoesNotEvaluateRight topic: core status: verified // verified behavior: Test.go(...) == false namespace Test func go() -> bool { let d = 0 return d != 0 && (10 / d) > 0 } ``` ## ILEmitterTests_Coverage_Numerics__ShortCircuit_Or_DoesNotEvaluateRight (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::ShortCircuit_Or_DoesNotEvaluateRight topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { let d = 0 return d == 0 || (10 / d) > 0 } ``` ## ILEmitterTests_Coverage_Numerics__Char_Equality (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_Equality topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { let c = 'x' return c == 'x' } ``` ## ILEmitterTests_Coverage_Numerics__Char_IsDigit_BclInterop (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_IsDigit_BclInterop topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return char.IsDigit('7') } ``` ## ILEmitterTests_Coverage_Numerics__Char_FromStringIndex (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_FromStringIndex topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { let s = "hello" return s[1] == 'e' } ``` ## ILEmitterTests_Coverage_Numerics__Int_LeftAssociativeSubtraction (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_LeftAssociativeSubtraction topic: core status: verified // verified behavior: Test.go(...) == -6 namespace Test func go() -> int { return 1 - 2 - 5 } ``` ## ILEmitterTests_Coverage_Numerics__Int_LeftAssociativeDivision (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_LeftAssociativeDivision topic: core status: verified // verified behavior: Test.go(...) == 4 namespace Test func go() -> int { return 100 / 5 / 5 } ``` ## ILEmitterTests_Coverage_Numerics__Int_TruncationTowardZero_Negative (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_TruncationTowardZero_Negative topic: core status: verified // verified behavior: Test.go(...) == -3 namespace Test func go() -> int { return -7 / 2 } ``` ## ILEmitterTests_Coverage_Numerics__Int_PowerOfTwoChain (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_PowerOfTwoChain topic: core status: verified // verified behavior: Test.go(...) == 1024 namespace Test func go() -> int { var n = 1 for i in 0..10 { n *= 2 } return n } ``` ## ILEmitterTests_Coverage_Numerics__Int_OverflowWrapsUnchecked (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_OverflowWrapsUnchecked topic: core status: verified // verified behavior: Test.go(...) == int.MinValue namespace Test func go() -> int { return int.MaxValue + 1 } ``` ## ILEmitterTests_Coverage_Numerics__Int_MaxValueConstant (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_MaxValueConstant topic: core status: verified // verified behavior: Test.go(...) == int.MaxValue namespace Test func go() -> int { return int.MaxValue } ``` ## ILEmitterTests_Coverage_Numerics__Int_MinValueConstant (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_MinValueConstant topic: core status: verified // verified behavior: Test.go(...) == int.MinValue namespace Test func go() -> int { return int.MinValue } ``` ## ILEmitterTests_Coverage_Numerics__Int_DoubleNegation (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_DoubleNegation topic: core status: verified // verified behavior: Test.go(...) == 5 namespace Test func go() -> int { let x = 5 return 0 - (0 - x) } ``` ## ILEmitterTests_Coverage_Numerics__Int_ModuloZeroRemainder (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_ModuloZeroRemainder topic: core status: verified // verified behavior: Test.go(...) == 0 namespace Test func go() -> int { return 12 % 4 } ``` ## ILEmitterTests_Coverage_Numerics__Int_ChainedCompoundOnParam (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_ChainedCompoundOnParam topic: core status: verified // verified behavior: Test.scale(...) == 45 namespace Test func scale(start: int, factor: int) -> int { var n = start n *= factor n += factor return n } ``` ## ILEmitterTests_Coverage_Numerics__Int_MixedArithmeticExpression (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_MixedArithmeticExpression topic: core status: verified // verified behavior: Test.go(...) == 17 namespace Test func go() -> int { return 2 * 3 + 4 * 2 + 3 } ``` ## ILEmitterTests_Coverage_Numerics__Long_MaxValueConstant (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Long_MaxValueConstant topic: core status: verified // verified behavior: Test.go(...) == long.MaxValue namespace Test func go() -> long { return long.MaxValue } ``` ## ILEmitterTests_Coverage_Numerics__Long_Subtraction (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Long_Subtraction topic: core status: verified // verified behavior: Test.sub(...) == 1_000_000_000L namespace Test func sub(a: long, b: long) -> long { return a - b } ``` ## ILEmitterTests_Coverage_Numerics__Long_Modulo (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Long_Modulo topic: core status: verified // verified behavior: Test.mod(...) == 2L namespace Test func mod(a: long, b: long) -> long { return a % b } ``` ## ILEmitterTests_Coverage_Numerics__Uint_MaxValueConstant (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Uint_MaxValueConstant topic: core status: verified // verified behavior: Test.go(...) == uint.MaxValue namespace Test func go() -> uint { return uint.MaxValue } ``` ## ILEmitterTests_Coverage_Numerics__Uint_Multiply (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Uint_Multiply topic: core status: verified // verified behavior: Test.mul(...) == 12u namespace Test func mul(a: uint, b: uint) -> uint { return a * b } ``` ## ILEmitterTests_Coverage_Numerics__Ulong_LargeValue (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Ulong_LargeValue topic: core status: verified // verified behavior: Test.echo(...) == 18_000_000_000_000_000_000UL namespace Test func echo(n: ulong) -> ulong { return n } ``` ## ILEmitterTests_Coverage_Numerics__Short_Subtraction (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Short_Subtraction topic: core status: verified // verified behavior: Test.sub(...) == (short)100 namespace Test func sub(a: short, b: short) -> short { return a - b } ``` ## ILEmitterTests_Coverage_Numerics__Byte_MaxValueConstant (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Byte_MaxValueConstant topic: core status: verified // verified behavior: Test.go(...) == (byte)255 namespace Test func go() -> byte { return byte.MaxValue } ``` ## ILEmitterTests_Coverage_Numerics__Sbyte_Arithmetic (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Sbyte_Arithmetic topic: core status: verified // verified behavior: Test.add(...) == (sbyte)1 namespace Test func add(a: sbyte, b: sbyte) -> sbyte { return a + b } ``` ## ILEmitterTests_Coverage_Numerics__Double_MathSqrt (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_MathSqrt topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return Math.Sqrt(16.0) } ``` ## ILEmitterTests_Coverage_Numerics__Double_MathAbs (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_MathAbs topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return Math.Abs(0.0 - 3.5) } ``` ## ILEmitterTests_Coverage_Numerics__Double_MathPow (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_MathPow topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return Math.Pow(2.0, 3.0) } ``` ## ILEmitterTests_Coverage_Numerics__Double_MathFloor (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_MathFloor topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return Math.Floor(3.9) } ``` ## ILEmitterTests_Coverage_Numerics__Double_MathCeiling (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_MathCeiling topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return Math.Ceiling(3.1) } ``` ## ILEmitterTests_Coverage_Numerics__Int_MathMax (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_MathMax topic: core status: verified // verified behavior: Test.go(...) == 7 namespace Test func go() -> int { return Math.Max(3, 7) } ``` ## ILEmitterTests_Coverage_Numerics__Int_MathMin (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_MathMin topic: core status: verified // verified behavior: Test.go(...) == 3 namespace Test func go() -> int { return Math.Min(3, 7) } ``` ## ILEmitterTests_Coverage_Numerics__Double_UsingStaticMath (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_UsingStaticMath topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using static "System.Math" func go() -> double { return Sqrt(25.0) } ``` ## ILEmitterTests_Coverage_Numerics__Double_NegativeAndComparison (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_NegativeAndComparison topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { let a = -2.5 let b = 1.5 return a < b && b > a } ``` ## ILEmitterTests_Coverage_Numerics__Double_SubtractionPrecision (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_SubtractionPrecision topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double { return 2.0 - 1.5 } ``` ## ILEmitterTests_Coverage_Numerics__Float_Multiply (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Float_Multiply topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func mul(a: float, b: float) -> float { return a * b } ``` ## ILEmitterTests_Coverage_Numerics__Int_Parse (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_Parse topic: core status: verified // verified behavior: Test.go(...) == 123 namespace Test func go() -> int { return int.Parse("123") } ``` ## ILEmitterTests_Coverage_Numerics__Int_TryParse_Success (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_TryParse_Success topic: core status: verified // verified behavior: Test.go(...) == 42 namespace Test func go() -> int { if int.TryParse("42", out var n) { return n } return -1 } ``` ## ILEmitterTests_Coverage_Numerics__Int_TryParse_Failure (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_TryParse_Failure topic: core status: verified // verified behavior: Test.go(...) == -1 namespace Test func go() -> int { if int.TryParse("notnum", out var n) { return n } return -1 } ``` ## ILEmitterTests_Coverage_Numerics__Long_Parse (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Long_Parse topic: core status: verified // verified behavior: Test.go(...) == 9_000_000_000L namespace Test func go() -> long { return long.Parse("9000000000") } ``` ## ILEmitterTests_Coverage_Numerics__Double_Parse (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_Parse topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Globalization" func go() -> double { return double.Parse("3.14", CultureInfo.InvariantCulture) } ``` ## ILEmitterTests_Coverage_Numerics__Int_ToStringInterpolation (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_ToStringInterpolation topic: interpolation status: verified // verified behavior: Test.go(...) == "n=42" namespace Test func go() -> string { let n = 42 return "n={n}" } ``` ## ILEmitterTests_Coverage_Numerics__Char_IsLetter (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_IsLetter topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return char.IsLetter('q') } ``` ## ILEmitterTests_Coverage_Numerics__Char_IsWhiteSpace (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_IsWhiteSpace topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return char.IsWhiteSpace(' ') } ``` ## ILEmitterTests_Coverage_Numerics__Char_Ordering (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_Ordering topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return 'a' < 'b' && 'z' > 'a' } ``` ## ILEmitterTests_Coverage_Numerics__Char_ToUpper (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_ToUpper topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return char.ToUpper('a') == 'A' } ``` ## ILEmitterTests_Coverage_Numerics__Char_EscapeSequences (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Char_EscapeSequences topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { let tab = '\t' let nl = '\n' return tab != nl } ``` ## ILEmitterTests_Coverage_Numerics__Bool_DeMorgan (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Bool_DeMorgan topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func check(a: bool, b: bool) -> bool { return !(a && b) == (!a || !b) } func go() -> bool { return check(true, false) && check(true, true) && check(false, false) } ``` ## ILEmitterTests_Coverage_Numerics__Bool_XorViaNotEqual (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Bool_XorViaNotEqual topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { return (true != false) && !(true != true) } ``` ## ILEmitterTests_Coverage_Numerics__Bool_NestedParentheses (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Bool_NestedParentheses topic: core status: verified // verified behavior: Test.go(...) == false namespace Test func go() -> bool { return (true && (false || (true && false))) } ``` ## ILEmitterTests_Coverage_Numerics__Bool_FromComparisonChainStored (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Bool_FromComparisonChainStored topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func go() -> bool { let n = 5 let inRange = n >= 1 && n <= 10 return inRange } ``` ## ILEmitterTests_Coverage_Numerics__Int_FieldArithmetic (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_FieldArithmetic topic: data status: verified // verified behavior: Test.go(...) == 30 namespace Test data Vec { x: int, y: int } func go() -> int { let v = Vec { x: 10, y: 20 } return v.x + v.y } ``` ## ILEmitterTests_Coverage_Numerics__Double_FieldMagnitudeSquared (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Double_FieldMagnitudeSquared topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec { x: double, y: double } func go() -> double { let v = Vec { x: 3.0, y: 4.0 } return v.x * v.x + v.y * v.y } ``` ## ILEmitterTests_Coverage_Numerics__Int_MutateThroughPointer (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_MutateThroughPointer topic: core status: verified // verified behavior: Test.go(...) == 15 namespace Test func addTo(target: *int, amount: int) { target += amount } func go() -> int { var n = 10 addTo(&n, 5) return n } ``` ## ILEmitterTests_Coverage_Numerics__Int_AccumulateAcrossCalls (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Int_AccumulateAcrossCalls topic: core status: verified // verified behavior: Test.go(...) == 6 namespace Test func bump(c: *int) { c += 1 } func go() -> int { var count = 3 bump(&count) bump(&count) bump(&count) return count } ``` ## ILEmitterTests_Coverage_Numerics__Long_FieldRoundTrip (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Long_FieldRoundTrip topic: data status: verified // verified behavior: Test.go(...) == 5_000_000_000L namespace Test data Timestamp { epochMs: long } func go() -> long { let t = Timestamp { epochMs: 5000000000 } return t.epochMs } ``` ## ILEmitterTests_Coverage_Numerics__Byte_FieldRoundTrip (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Byte_FieldRoundTrip topic: data status: verified // verified behavior: Test.go(...) == (byte)128 namespace Test data Pixel { r: byte, g: byte, b: byte } func go() -> byte { let p = Pixel { r: 128, g: 64, b: 32 } return p.r } ``` ## ILEmitterTests_Coverage_Numerics__Algo_GcdEuclid (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Algo_GcdEuclid topic: core status: verified // verified behavior: Test.go(...) == 6 namespace Test func gcd(a: int, b: int) -> int { var x = a var y = b while y != 0 { let t = y y = x % y x = t } return x } func go() -> int { return gcd(48, 18) } ``` ## ILEmitterTests_Coverage_Numerics__Algo_FibonacciIterative (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Algo_FibonacciIterative topic: core status: verified // verified behavior: Test.go(...) == 55 namespace Test func fib(n: int) -> int { var a = 0 var b = 1 for i in 0..n { let t = a + b a = b b = t } return a } func go() -> int { return fib(10) } ``` ## ILEmitterTests_Coverage_Numerics__Algo_IsPrime (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Algo_IsPrime topic: core status: verified // verified behavior: Test.go(...) == true namespace Test func isPrime(n: int) -> bool { if n < 2 { return false } var d = 2 while d * d <= n { if n % d == 0 { return false } d += 1 } return true } func go() -> bool { return isPrime(97) } ``` ## ILEmitterTests_Coverage_Numerics__Algo_SumOfDigits (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Algo_SumOfDigits topic: core status: verified // verified behavior: Test.go(...) == 15 namespace Test func digitSum(n: int) -> int { var x = n var sum = 0 while x > 0 { sum += x % 10 x /= 10 } return sum } func go() -> int { return digitSum(12345) } ``` ## ILEmitterTests_Coverage_Numerics__Algo_CountSetViaModulo (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Algo_CountSetViaModulo topic: core status: verified // verified behavior: Test.go(...) == 3 namespace Test func countMultiples(limit: int, of: int) -> int { var count = 0 for i in 1..limit { if i % of == 0 { count += 1 } } return count } func go() -> int { return countMultiples(10, 3) } ``` ## ILEmitterTests_Coverage_Numerics__Algo_PowerByMultiplication (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Numerics.cs::Algo_PowerByMultiplication topic: core status: verified // verified behavior: Test.go(...) == 243 namespace Test func ipow(b: int, exp: int) -> int { var result = 1 for i in 0..exp { result *= b } return result } func go() -> int { return ipow(3, 5) } ``` ## ILEmitterTests_PointerCollections__List_OfInts_Index (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::List_OfInts_Index topic: pointers status: verified // verified behavior: Test.go(...) == 20 namespace Test func go() -> int { let xs = [10, 20, 30] return xs[1] } ``` ## ILEmitterTests_PointerCollections__List_OfValueData_Index (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::List_OfValueData_Index topic: pointers status: verified // verified behavior: Test.go(...) == 20 namespace Test data Box { n: int } func go() -> int { let xs = [Box { n: 10 }, Box { n: 20 }] return xs[1].n } ``` ## ILEmitterTests_PointerCollections__List_OfPointers_IndexZero (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::List_OfPointers_IndexZero topic: pointers status: verified // verified behavior: Test.go(...) == 10 namespace Test data Box { n: int } func go() -> int { let xs = [new Box { n: 10 }, new Box { n: 20 }] return xs[0].n } ``` ## ILEmitterTests_PointerCollections__List_OfPointers_ForIn_Sum (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::List_OfPointers_ForIn_Sum topic: pointers status: verified // verified behavior: Test.go(...) == 60 namespace Test data Box { n: int } func go() -> int { let xs = [new Box { n: 10 }, new Box { n: 20 }, new Box { n: 30 }] var total = 0 for b in xs { total += b.n } return total } ``` ## ILEmitterTests_PointerCollections__List_OfValueData_ForIn_Sum (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::List_OfValueData_ForIn_Sum topic: pointers status: verified // verified behavior: Test.go(...) == 60 namespace Test data Box { n: int } func go() -> int { let xs = [Box { n: 10 }, Box { n: 20 }, Box { n: 30 }] var total = 0 for b in xs { total += b.n } return total } ``` ## ILEmitterTests_PointerCollections__List_OfPointers_Count (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::List_OfPointers_Count topic: pointers status: verified // verified behavior: Test.go(...) == 3 namespace Test data Box { n: int } func go() -> int { let xs = [new Box { n: 1 }, new Box { n: 2 }, new Box { n: 3 }] return xs.Count } ``` ## ILEmitterTests_PointerCollections__ExplicitListOfPointers_AddThenIndex (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::ExplicitListOfPointers_AddThenIndex topic: pointers status: verified // verified behavior: Test.go(...) == 7 namespace Test data Box { n: int } func go() -> int { var xs = List<*Box>() xs.Add(new Box { n: 7 }) return xs[0].n } ``` ## ILEmitterTests_PointerCollections__ExplicitListOfPointers_ForIn (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::ExplicitListOfPointers_ForIn topic: pointers status: verified // verified behavior: Test.go(...) == 12 namespace Test data Box { n: int } func go() -> int { var xs = List<*Box>() xs.Add(new Box { n: 5 }) xs.Add(new Box { n: 7 }) var t = 0 for b in xs { t += b.n } return t } ``` ## ILEmitterTests_PointerCollections__PointerListField_RoundTrip (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerListField_RoundTrip topic: pointers status: verified // verified behavior: Test.go(...) == 9 namespace Test data Box { n: int } data Bag { items: List<*Box> } func go() -> int { var bag = Bag { items: List<*Box>() } bag.items.Add(new Box { n: 9 }) return bag.items[0].n } ``` ## ILEmitterTests_PointerCollections__PointerListReturn (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerListReturn topic: pointers status: verified // verified behavior: Test.go(...) == 2 namespace Test data Box { n: int } func build() -> List<*Box> { var xs = List<*Box>() xs.Add(new Box { n: 1 }) xs.Add(new Box { n: 2 }) return xs } func go() -> int { let xs = build() return xs.Count } ``` ## ILEmitterTests_PointerCollections__PointerListParam_Sum (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerListParam_Sum topic: pointers status: verified // verified behavior: Test.go(...) == 8 namespace Test data Box { n: int } func total(xs: List<*Box>) -> int { var t = 0 for b in xs { t += b.n } return t } func go() -> int { var xs = List<*Box>() xs.Add(new Box { n: 3 }) xs.Add(new Box { n: 5 }) return total(xs) } ``` ## ILEmitterTests_PointerCollections__TupleOfInts_Item (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::TupleOfInts_Item topic: pointers status: verified // verified behavior: Test.go(...) == 5 namespace Test func go() -> int { let t = (2, 5) return t.Item2 } ``` ## ILEmitterTests_PointerCollections__TupleOfPointers_ItemDeref (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::TupleOfPointers_ItemDeref topic: pointers status: verified // verified behavior: Test.go(...) == 5 namespace Test data Box { n: int } func go() -> int { let t = (new Box { n: 2 }, new Box { n: 5 }) return t.Item2.n } ``` ## ILEmitterTests_PointerCollections__TupleOfPointers_Destructure (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::TupleOfPointers_Destructure topic: pointers status: verified // verified behavior: Test.go(...) == 7 namespace Test data Box { n: int } func go() -> int { let (a, b) = (new Box { n: 2 }, new Box { n: 5 }) return a.n + b.n } ``` ## ILEmitterTests_PointerCollections__GenericIdentity_OnPointer (pointers, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::GenericIdentity_OnPointer topic: pointers status: unverified // verified behavior: Test.go(...) == 13 namespace Test data Box { n: int } func identity(v: T) -> T { return v } func go() -> int { let b = identity(new Box { n: 13 }) return b.n } ``` ## ILEmitterTests_PointerCollections__GenericFirst_OverPointerList (pointers, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::GenericFirst_OverPointerList topic: pointers status: unverified // verified behavior: Test.go(...) == 4 namespace Test data Box { n: int } func first(xs: List) -> T { return xs[0] } func go() -> int { var xs = List<*Box>() xs.Add(new Box { n: 4 }) let b = first<*Box>(xs) return b.n } ``` ## ILEmitterTests_PointerCollections__GenericData_HoldingPointer (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::GenericData_HoldingPointer topic: pointers status: verified // verified behavior: Test.go(...) == 6 namespace Test data Box { n: int } data Cell { value: T } func go() -> int { let c = Cell<*Box> { value: new Box { n: 6 } } return c.value.n } ``` ## ILEmitterTests_PointerCollections__DictionaryStringToPointer (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::DictionaryStringToPointer topic: pointers status: verified // verified behavior: Test.go(...) == 99 namespace Test data Box { n: int } func go() -> int { var m = Dictionary() m["a"] = new Box { n: 99 } return m["a"].n } ``` ## ILEmitterTests_PointerCollections__NestedListOfPointerLists (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::NestedListOfPointerLists topic: pointers status: verified // verified behavior: Test.go(...) == 2 namespace Test data Box { n: int } func go() -> int { var outer = List>() var inner = List<*Box>() inner.Add(new Box { n: 1 }) inner.Add(new Box { n: 2 }) outer.Add(inner) return outer[0].Count } ``` ## ILEmitterTests_PointerCollections__NestedListOfPointers_IndexDeref (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::NestedListOfPointers_IndexDeref topic: pointers status: verified // verified behavior: Test.go(...) == 2 namespace Test data Box { n: int } func go() -> int { var outer = List>() var inner = List<*Box>() inner.Add(new Box { n: 1 }) inner.Add(new Box { n: 2 }) outer.Add(inner) return outer[0][1].n } ``` ## ILEmitterTests_PointerCollections__PointerList_IterateAndMutate (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerList_IterateAndMutate topic: pointers status: verified // verified behavior: Test.go(...) == 6 namespace Test data Box { var n: int } func go() -> int { let xs = [new Box { n: 1 }, new Box { n: 2 }, new Box { n: 3 }] for b in xs { b.n += 0 } var t = 0 for b in xs { t += b.n } return t } ``` ## ILEmitterTests_PointerCollections__GenericData_PointerField_Mutate (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::GenericData_PointerField_Mutate topic: pointers status: verified // verified behavior: Test.go(...) == 8 namespace Test data Box { var n: int } data Cell { value: T } func go() -> int { let c = Cell<*Box> { value: new Box { n: 7 } } c.value.n += 1 return c.value.n } ``` ## ILEmitterTests_PointerCollections__Dictionary_PointerValue_Iterate (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::Dictionary_PointerValue_Iterate topic: pointers status: verified // verified behavior: Test.go(...) == 30 namespace Test data Box { n: int } func go() -> int { var m = Dictionary() m["a"] = new Box { n: 10 } m["b"] = new Box { n: 20 } return m["a"].n + m["b"].n } ``` ## ILEmitterTests_PointerCollections__GenericFirst_PointerInferred (pointers, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::GenericFirst_PointerInferred topic: pointers status: unverified // verified behavior: Test.go(...) == 4 namespace Test data Box { n: int } func first(xs: List) -> T = xs[0] func go() -> int { var xs = List<*Box>() xs.Add(new Box { n: 4 }) let b = first(xs) return b.n } ``` ## ILEmitterTests_PointerCollections__TupleOfMixed_PointerAndInt (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::TupleOfMixed_PointerAndInt topic: pointers status: verified // verified behavior: Test.go(...) == 15 namespace Test data Box { n: int } func go() -> int { let t = (new Box { n: 5 }, 10) return t.Item1.n + t.Item2 } ``` ## ILEmitterTests_PointerCollections__PointerList_PassToValueDataMethod (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerList_PassToValueDataMethod topic: pointers status: verified // verified behavior: Test.go(...) == 9 namespace Test data Box { n: int } func sumList(xs: List<*Box>) -> int { var t = 0 for b in xs { t += b.n } return t } func go() -> int { let xs = [new Box { n: 4 }, new Box { n: 5 }] return sumList(xs) } ``` ## ILEmitterTests_PointerCollections__PointerList_NestedFieldAccess (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerList_NestedFieldAccess topic: pointers status: verified // verified behavior: Test.go(...) == 7 namespace Test data Inner { v: int } data Outer { inner: *Inner } func go() -> int { let xs = [new Outer { inner: new Inner { v: 7 } }] return xs[0].inner.v } ``` ## ILEmitterTests_PointerCollections__PointerReturnedFromListBoundMethod (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerReturnedFromListBoundMethod topic: pointers status: verified // verified behavior: Test.go(...) == 2 namespace Test data Box { n: int } func go() -> int { var xs = List<*Box>() xs.Add(new Box { n: 1 }) xs.Add(new Box { n: 2 }) let last = xs[xs.Count - 1] return last.n } ``` ## ILEmitterTests_PointerCollections__GenericData_Nested_PointerInner (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::GenericData_Nested_PointerInner topic: pointers status: verified // verified behavior: Test.go(...) == 3 namespace Test data Box { n: int } data Cell { value: T } func go() -> int { let c = Cell> { value: Cell<*Box> { value: new Box { n: 3 } } } return c.value.value.n } ``` ## ILEmitterTests_PointerCollections__PointerList_CountAfterAdds (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::PointerList_CountAfterAdds topic: pointers status: verified // verified behavior: Test.go(...) == 3 namespace Test data Box { n: int } func go() -> int { var xs = List<*Box>() xs.Add(new Box { n: 1 }) xs.Add(new Box { n: 2 }) xs.Add(new Box { n: 3 }) return xs.Count } ``` ## ILEmitterTests_PointerCollections__TupleOfThreePointers_Destructure (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerCollections.cs::TupleOfThreePointers_Destructure topic: pointers status: verified // verified behavior: Test.go(...) == 6 namespace Test data Box { n: int } func go() -> int { let (a, b, c) = (new Box { n: 1 }, new Box { n: 2 }, new Box { n: 3 }) return a.n + b.n + c.n } ``` ## ILEmitterTests_FieldDefaults__RefData_FieldDefault_String (field-defaults, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FieldDefaults.cs::RefData_FieldDefault_String topic: field-defaults status: verified // verified behavior: Test.test(...) == "default" namespace Test ref data Config { let name: string = "default" } func test() -> string { let c = Config() return c.name } ``` ## ILEmitterTests_FieldDefaults__RefData_FieldDefault_Int (field-defaults, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FieldDefaults.cs::RefData_FieldDefault_Int topic: field-defaults status: verified // verified behavior: Test.test(...) == 42 namespace Test ref data Counter { var count: int = 42 } func test() -> int { let c = Counter() return c.count } ``` ## ILEmitterTests_FieldDefaults__RefData_FieldDefault_WithInit_DefaultsRunFirst (field-defaults, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FieldDefaults.cs::RefData_FieldDefault_WithInit_DefaultsRunFirst topic: field-defaults status: verified // verified behavior: Test.test(...) == "localhost" namespace Test ref data Server { let host: string = "localhost" var port: int = 8080 init(port: int) { self.port = port } } func test() -> string { let s = Server(9090) return s.host } ``` ## ILEmitterTests_FieldDefaults__RefData_FieldDefault_Bool (field-defaults, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FieldDefaults.cs::RefData_FieldDefault_Bool topic: field-defaults status: verified // verified behavior: Test.test(...) == true namespace Test ref data Flags { let enabled: bool = true let verbose: bool = false } func test() -> bool { let f = Flags() return f.enabled and not f.verbose } ``` ## ILEmitterTests_FieldDefaults__PubRefData_MethodsInheritPub (field-defaults, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FieldDefaults.cs::PubRefData_MethodsInheritPub topic: field-defaults status: verified // verified behavior: Test.test(...) == "widget" namespace Test pub ref data Widget { let label: string = "widget" func getLabel() -> string = self.label } func test() -> string { let w = Widget() return w.getLabel() } ``` ## ILEmitterTests_HeapPointer__HeapPointer_FieldDeclaration_Compiles (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_FieldDeclaration_Compiles topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Inner { var x: int } ref data Outer { ptr: *Inner } func check() -> bool { var o = Outer() return o.ptr == nil } ``` ## ILEmitterTests_HeapPointer__HeapPointer_HeapAlloc_StoresValue (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_HeapAlloc_StoresValue topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Point { var x: int var y: int } ref data Holder { pt: *Point } func getX() -> int { var h = Holder() h.pt = new Point { x: 42, y: 7 } return h.pt.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_AutoDeref_Read (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_AutoDeref_Read topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec2 { var x: int var y: int } ref data Entity { pos: *Vec2 } func readY() -> int { var e = Entity() e.pos = new Vec2 { x: 10, y: 20 } return e.pos.y } ``` ## ILEmitterTests_HeapPointer__HeapPointer_AutoDeref_Write (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_AutoDeref_Write topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec2 { var x: int var y: int } ref data Entity { pos: *Vec2 } func writeAndRead() -> int { var e = Entity() e.pos = new Vec2 { x: 0, y: 0 } e.pos.x = 99 return e.pos.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_NilByDefault (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_NilByDefault topic: pointers status: verified // verified behavior: Test.isNil(...) == true namespace Test data Inner { var x: int } ref data Box { inner: *Inner } func isNil() -> bool { var b = Box() return b.inner == nil } ``` ## ILEmitterTests_HeapPointer__HeapPointer_NilCheck (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_NilCheck topic: pointers status: verified // verified behavior: Test.checkAfterSet(...) == 2 namespace Test data Inner { var x: int } ref data Box { inner: *Inner } func checkBoth() -> int { var b = Box() if b.inner == nil { return 1 } return 0 } func checkAfterSet() -> int { var b = Box() b.inner = new Inner { x: 5 } if b.inner != nil { return 2 } return 0 } ``` ## ILEmitterTests_HeapPointer__HeapPointer_AssignNil (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_AssignNil topic: pointers status: verified // verified behavior: Test.setThenNil(...) == true namespace Test data Inner { var x: int } ref data Box { inner: *Inner } func setThenNil() -> bool { var b = Box() b.inner = new Inner { x: 10 } b.inner = nil return b.inner == nil } ``` ## ILEmitterTests_HeapPointer__HeapPointer_AddressOfLocal_CopiesToHeap (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_AddressOfLocal_CopiesToHeap topic: pointers status: verified // verified behavior: Test.copyToHeap(...) == 77 namespace Test data Vec2 { var x: int var y: int } ref data Holder { pt: *Vec2 } func copyToHeap() -> int { var h = Holder() let v = Vec2 { x: 77, y: 88 } h.pt = &v return h.pt.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_CompoundAssignment (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_CompoundAssignment topic: pointers status: verified // verified behavior: Test.increment(...) == 15 namespace Test data Counter { var value: int } ref data Box { c: *Counter } func increment() -> int { var b = Box() b.c = new Counter { value: 10 } b.c.value += 5 return b.c.value } ``` ## ILEmitterTests_HeapPointer__HeapPointer_NamedReceiver_DataType (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_NamedReceiver_DataType topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec2 { var x: int var y: int } func addX(v: *Vec2, amount: int) { v.x += amount } func getSum() -> int { var v: *Vec2 = new Vec2 { x: 10, y: 20 } v.addX(5) return v.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_NamedReceiver_RefData (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_NamedReceiver_RefData topic: pointers status: verified // verified behavior: Test.getValue(...) == 42 namespace Test data Inner { var x: int } ref data Manager { inner: *Inner var count: int } func setup(m: Manager) { m.inner = new Inner { x: 42 } m.count = 1 } func getValue() -> int { var m = Manager() m.setup() return m.inner.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_SelfReferential_StaysStruct (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_SelfReferential_StaysStruct topic: pointers status: verified // verified behavior: Test.sum(...) == 6 namespace Test data Node { value: int next: *Node } func sum() -> int { var n3: *Node = new Node { value: 3, next: nil } var n2: *Node = new Node { value: 2, next: n3 } var n1: *Node = new Node { value: 1, next: n2 } var total = 0 var cur = n1 while cur != nil { total += cur.value cur = cur.next } return total } ``` ## ILEmitterTests_HeapPointer__HeapPointer_ReturnType (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_ReturnType topic: pointers status: verified // verified behavior: Test.sum(...) == 60 namespace Test data Node { value: int next: *Node } func prepend(head: *Node, value: int) -> *Node { return new Node { value: value, next: head } } func sum() -> int { var list: *Node = nil list = prepend(list, 10) list = prepend(list, 20) list = prepend(list, 30) var total = 0 var cur = list while cur != nil { total += cur.value cur = cur.next } return total } ``` ## ILEmitterTests_HeapPointer__HeapPointer_LocalVariable_ExplicitType (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_LocalVariable_ExplicitType topic: pointers status: verified // verified behavior: Test.test(...) == 15 namespace Test data Vec2 { var x: int var y: int } func test() -> int { var p: *Vec2 = new Vec2 { x: 5, y: 10 } return p.x + p.y } ``` ## ILEmitterTests_HeapPointer__HeapPointer_LocalVariable_NilThenAssign (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_LocalVariable_NilThenAssign topic: pointers status: verified // verified behavior: Test.test(...) == 99 namespace Test data Inner { var x: int } func test() -> int { var p: *Inner = nil if p == nil { p = new Inner { x: 99 } } return p.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_MultiplePointerFields (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_MultiplePointerFields topic: pointers status: verified // verified behavior: Test.test(...) == 90 namespace Test data Health { var current: int var max: int } data Position { var x: int var y: int } ref data Entity { hp: *Health pos: *Position } func test() -> int { var e = Entity() e.hp = new Health { current: 80, max: 100 } e.pos = new Position { x: 10, y: 20 } return e.hp.current + e.pos.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_FieldInStruct (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_FieldInStruct topic: pointers status: verified // verified behavior: Test.test(...) == 47 namespace Test data Inner { var x: int } data Outer { tag: int ptr: *Inner } func test() -> int { var o = Outer { tag: 5, ptr: new Inner { x: 42 } } return o.tag + o.ptr.x } ``` ## ILEmitterTests_HeapPointer__HeapPointer_NestedAutoDeref (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_NestedAutoDeref topic: pointers status: verified // verified behavior: Test.test(...) == 77 namespace Test data Vec2 { var x: int var y: int } data Transform { var position: Vec2 var scale: double } ref data Entity { transform: *Transform } func test() -> int { var e = Entity() e.transform = new Transform { position: Vec2 { x: 33, y: 44 }, scale: 1.0 } return e.transform.position.x + e.transform.position.y } ``` ## ILEmitterTests_HeapPointer__HeapPointer_NestedAutoDeref_Write (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_NestedAutoDeref_Write topic: pointers status: verified // verified behavior: Test.test(...) == 300 namespace Test data Vec2 { var x: int var y: int } data Transform { var position: Vec2 var scale: double } ref data Entity { transform: *Transform } func test() -> int { var e = Entity() e.transform = new Transform { position: Vec2 { x: 0, y: 0 }, scale: 1.0 } e.transform.position.x = 100 e.transform.position.y = 200 return e.transform.position.x + e.transform.position.y } ``` ## ILEmitterTests_HeapPointer__HeapPointer_ReceiverMutatesThroughPointer (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_ReceiverMutatesThroughPointer topic: pointers status: verified // verified behavior: Test.test(...) == 0 namespace Test data Health { var current: int var max: int } ref data Entity { hp: *Health } func takeDamage(e: Entity, amount: int) { if e.hp == nil { return } e.hp.current -= amount if e.hp.current < 0 { e.hp.current = 0 } } func test() -> int { var e = Entity() e.hp = new Health { current: 100, max: 100 } e.takeDamage(30) e.takeDamage(80) return e.hp.current } ``` ## ILEmitterTests_HeapPointer__HeapPointer_LinkedList_EndToEnd (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_LinkedList_EndToEnd topic: pointers status: verified // verified behavior: Test.testSum(...) == 60 namespace Test data Node { value: int next: *Node } func prepend(head: *Node, value: int) -> *Node { return new Node { value: value, next: head } } func length(head: *Node) -> int { var count = 0 var cur = head while cur != nil { count += 1 cur = cur.next } return count } func testLength() -> int { var list: *Node = nil list = prepend(list, 10) list = prepend(list, 20) list = prepend(list, 30) return length(list) } func testSum() -> int { var list: *Node = nil list = prepend(list, 10) list = prepend(list, 20) list = prepend(list, 30) var total = 0 var cur = list while cur != nil { total += cur.value cur = cur.next } return total } ``` ## ILEmitterTests_HeapPointer__HeapPointer_StructProtocol_ImplicitSatisfaction (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_StructProtocol_ImplicitSatisfaction topic: pointers status: verified // verified behavior: Test.test(...) == "Alice" namespace Test interface IDescribable { func describe() -> string } data Client : IDescribable { name: string } func describe(c: Client) -> string { return c.name } func printInfo(d: IDescribable) -> string { return d.describe() } func test() -> string { let c = Client { name: "Alice" } return printInfo(c) } ``` ## ILEmitterTests_HeapPointer__HeapPointer_AssignT_ToStarT_WithoutAmpersand_Error (pointers, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_AssignT_ToStarT_WithoutAmpersand_Error topic: pointers status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec2 { var x: int var y: int } ref data Holder { pt: *Vec2 } func test() { var h = Holder() h.pt = Vec2 { x: 1, y: 2 } } ``` ## ILEmitterTests_HeapPointer__HeapPointer_StarRefData_Error (pointers, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_StarRefData_Error topic: pointers status: verified // verified behavior: reports diagnostic ES2003 namespace Test ref data Connection { id: int } ref data Manager { conn: *Connection } ``` ## ILEmitterTests_HeapPointer__HeapPointer_DotSyntax_StaticCall (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_DotSyntax_StaticCall topic: pointers status: verified // verified behavior: Test.test(...) == 70 namespace Test data Vec2 { var x: int var y: int } func scale(v: *Vec2, factor: int) { v.x *= factor v.y *= factor } func test() -> int { var v: *Vec2 = new Vec2 { x: 3, y: 4 } v.scale(10) return v.x + v.y } ``` ## ILEmitterTests_HeapPointer__HeapPointer_BothCallSyntaxes (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_BothCallSyntaxes topic: pointers status: verified // verified behavior: Test.test(...) == 15 namespace Test data Vec2 { var x: int var y: int } func addX(v: *Vec2, amount: int) { v.x += amount } func test() -> int { var v: *Vec2 = new Vec2 { x: 0, y: 0 } addX(v, 10) v.addX(5) return v.x } ``` ## ILEmitterTests_HeapPointer__PointerProtocol_Compiles (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::PointerProtocol_Compiles topic: pointers status: verified // verified behavior: Test.test(...) == 60 namespace Test data Node : ISummable { value: int next: *Node } func sum(head: *Node) -> int { var total = 0 var current = head while current != nil { total += current.value current = current.next } return total } interface ISummable { func sum() -> int } func report(s: ISummable) -> int { return s.sum() } func test() -> int { var list: *Node = nil list = new Node { value: 10, next: nil } list = new Node { value: 20, next: list } list = new Node { value: 30, next: list } return report(list) } ``` ## ILEmitterTests_HeapPointer__PointerProtocol_ValueTypeDoesNotSatisfy (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::PointerProtocol_ValueTypeDoesNotSatisfy topic: pointers status: verified // verified behavior: Test.check(...) == true namespace Test data Widget : IDescribable { var x: int } func describe(w: *Widget) -> string { return "widget" } interface IDescribable { func describe() -> string } func check() -> bool { return true } ``` ## ILEmitterTests_HeapPointer__PointerProtocol_ValueReceiverInBothSets (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::PointerProtocol_ValueReceiverInBothSets topic: pointers status: verified // verified behavior: Test.testValue(...) == 42 namespace Test data Counter : IReadable { var value: int } func current(c: Counter) -> int { return c.value } interface IReadable { func current() -> int } func fetch(r: IReadable) -> int { return r.current() } func testValue() -> int { let c = Counter { value: 42 } return fetch(c) } ``` ## ILEmitterTests_HeapPointer__PointerProtocol_MixedMethodSet (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::PointerProtocol_MixedMethodSet topic: pointers status: verified // verified behavior: Test.test(...) == 30 namespace Test data Acc : IAccumulator { var total: int } func get(a: Acc) -> int { return a.total } func add(a: *Acc, n: int) { a.total += n } interface IAccumulator { func get() -> int func add(n: int) } func useAcc(a: IAccumulator) -> int { a.add(10) a.add(20) return a.get() } func test() -> int { var a: *Acc = new Acc { total: 0 } return useAcc(a) } ``` ## ILEmitterTests_HeapPointer__PointerProtocol_AllMethodsRequired (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::PointerProtocol_AllMethodsRequired topic: pointers status: verified // verified behavior: Test.check(...) == true namespace Test data Pair { var a: int var b: int } func getA(p: *Pair) -> int { return p.a } interface INeedsTwo { func getA() -> int func getB() -> int } func check() -> bool { return true } ``` ## ILEmitterTests_HeapPointer__PointerProtocol_WrapperHasDelegateMethods (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::PointerProtocol_WrapperHasDelegateMethods topic: pointers status: verified // verified behavior: Test.test(...) == 99 namespace Test data Item : IValued { var x: int } func value(i: *Item) -> int { return i.x } interface IValued { func value() -> int } func getValue(v: IValued) -> int { return v.value() } func test() -> int { var item: *Item = new Item { x: 99 } return getValue(item) } ``` ## ILEmitterTests_HeapPointer__HeapPointer_Nil_Default_Construction (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_Nil_Default_Construction topic: pointers status: verified // verified behavior: Test.test(...) == true namespace Test data Node { value: int } func test() -> bool { let n: *Node = nil return n == nil } ``` ## ILEmitterTests_HeapPointer__HeapPointer_NonNil_Compare_Returns_False_To_Nil (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_NonNil_Compare_Returns_False_To_Nil topic: pointers status: verified // verified behavior: Test.test(...) == false namespace Test data Node { value: int } func test() -> bool { let n: *Node = new Node { value: 7 } return n == nil } ``` ## ILEmitterTests_HeapPointer__HeapPointer_Auto_Deref_Field_Access (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::HeapPointer_Auto_Deref_Field_Access topic: pointers status: verified // verified behavior: Test.test(...) == 42 namespace Test data Node { value: int } func test() -> int { let n: *Node = new Node { value: 21 } return n.value * 2 } ``` ## ILEmitterTests_HeapPointer__Added_New_FieldSum (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::Added_New_FieldSum topic: pointers status: verified // verified behavior: Test.test(...) == 30 namespace Test data Point { x: int, y: int } func test() -> int { let p = new Point { x: 10, y: 20 } return p.x + p.y } ``` ## ILEmitterTests_HeapPointer__Added_PointerFieldReassignedThroughChain (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::Added_PointerFieldReassignedThroughChain topic: pointers status: verified // verified behavior: Test.test(...) == 5 namespace Test data Inner { var n: int } data Outer { inner: *Inner } func test() -> int { let o = new Outer { inner: new Inner { n: 1 } } o.inner.n = 5 return o.inner.n } ``` ## ILEmitterTests_HeapPointer__Added_PointerParameterMutatesCaller (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::Added_PointerParameterMutatesCaller topic: pointers status: verified // verified behavior: Test.test(...) == 15 namespace Test data Counter { var value: int } func bump(c: *Counter) { c.value += 10 } func test() -> int { var c = new Counter { value: 5 } bump(c) return c.value } ``` ## ILEmitterTests_HeapPointer__Added_NilPointerDefaultThenAssign (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::Added_NilPointerDefaultThenAssign topic: pointers status: verified // verified behavior: Test.test(...) == 42 namespace Test data Node { value: int, next: *Node } func test() -> int { var head: *Node = nil head = new Node { value: 42, next: nil } return head.value } ``` ## ILEmitterTests_HeapPointer__Added_PointerReturnedAndChained (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::Added_PointerReturnedAndChained topic: pointers status: verified // verified behavior: Test.test(...) == 42 namespace Test data Box { n: int } func make(v: int) -> *Box = new Box { n: v } func test() -> int { let b = make(21) return b.n + b.n } ``` ## ILEmitterTests_HeapPointer__Added_TwoLevelEmbedPointer (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_HeapPointer.cs::Added_TwoLevelEmbedPointer topic: pointers status: verified // verified behavior: Test.test(...) == 42 namespace Test data Vec2 { var x: int, var y: int } data Entity { *Vec2, name: string } func test() -> int { var e = new Entity { Vec2: new Vec2 { x: 30, y: 12 }, name: "p" } return e.x + e.y } ``` ## FeatureMixingTests__Axis1_AsyncEvalRefChoice_TryCatchAroundAwait (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis1_AsyncEvalRefChoice_TryCatchAroundAwait topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Expr { literal(value: int) add(left: Expr, right: Expr) fail(reason: string) } func eval(e: Expr) -> int { match (e: Expr) { .literal(lit) { let v = await Task.FromResult(lit.value) return v } .add(a) { let l = eval(a.left) let r = eval(a.right) return l + r } .fail(f) { throw InvalidOperationException(f.reason) } } return -1 } func run() -> int { let tree = Expr_add { left: Expr_literal { value: 3 }, right: Expr_fail { reason: "no" } } var result = 0 try { result = await eval(tree) } catch (Exception e) { result = -42 } return result } ``` ## FeatureMixingTests__Axis1_AsyncMatch_AwaitInEveryArm (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis1_AsyncMatch_AwaitInEveryArm topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Cmd { one(n: int) two(a: int, b: int) three(s: string) } func handle(c: Cmd) -> int { match (c: Cmd) { .one(o) { let v = await Task.FromResult(o.n) return v + 1 } .two(t) { let a = await Task.FromResult(t.a) let b = await Task.FromResult(t.b) return a + b } .three(t) { let s = await Task.FromResult(t.s) return s.Length } } return -1 } func one() -> int = await handle(Cmd_one { n: 41 }) func two() -> int = await handle(Cmd_two { a: 10, b: 20 }) func three() -> int = await handle(Cmd_three { s: "hello" }) ``` ## FeatureMixingTests__Axis1_AsyncResultMatch_TryCatchInsideArm (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis1_AsyncResultMatch_TryCatchInsideArm topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func parseAsync(s: string) -> int { let v = await Task.FromResult(int.Parse(s)) return v } func safeParse(s: string) -> Result { var n = 0 try { n = await parseAsync(s) } catch (Exception e) { return error("bad: {e.Message}") } return ok(n) } func runOk() -> int { let r = await safeParse("42") match (r: Result) { .ok(v) { return v } .err(_) { return -1 } } return -2 } func runErr() -> int { let r = await safeParse("nope") match (r: Result) { .ok(_) { return -1 } .err(_) { return 99 } } return -2 } ``` ## FeatureMixingTests__Axis1_AsyncResultMatch_BadPattern_DiagnosesUnawaitedAsyncCall (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis1_AsyncResultMatch_BadPattern_DiagnosesUnawaitedAsyncCall topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func parseAsync(s: string) -> int { let v = await Task.FromResult(int.Parse(s)) return v } func safeParse(s: string) -> Result { let n = parseAsync(s) return ok(n) } ``` ## FeatureMixingTests__Axis2_SpawnCapturesPointer_MutatesThroughIt (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis2_SpawnCapturesPointer_MutatesThroughIt topic: pointers status: verified // verified behavior: Test.run(...) == 42 namespace Test data Counter { var value: int } func run() -> int { var box: *Counter = new Counter { value: 0 } let job = spawn { box.value = box.value + 10 box.value = box.value + 32 } job.Join() return box.value } ``` ## FeatureMixingTests__Axis2_DeferLifoOrder_InsideAndAroundSpawn (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis2_DeferLifoOrder_InsideAndAroundSpawn topic: pointers status: verified // verified behavior: Test.line(...) == "inner-1" namespace Test data Log { var lines: List } func run() -> int { var log: *Log = new Log { lines: List() } let job = spawn { defer { log.lines.Add("inner-1") } defer { log.lines.Add("inner-2") } log.lines.Add("body") } defer { log.lines.Add("outer-1") } defer { log.lines.Add("outer-2") } job.Join() log.lines.Add("after-join") return log.lines.Count } func line(i: int) -> string { var log: *Log = new Log { lines: List() } let job = spawn { defer { log.lines.Add("inner-1") } defer { log.lines.Add("inner-2") } log.lines.Add("body") } job.Join() return log.lines[i] } ``` ## FeatureMixingTests__Axis2_SpawnPtrCapture_ChanCloseInDefer (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis2_SpawnPtrCapture_ChanCloseInDefer topic: async status: verified // verified behavior: Test.run(...) == 9 namespace Test data State { var produced: int } func run() -> int { var s: *State = new State { produced: 0 } let ch = chan(4) let producer = spawn { defer { ch.Close() } ch.Send(1) ch.Send(2) ch.Send(3) s.produced = 3 } producer.Join() var total = 0 for v in ch { total += v } return total + s.produced } ``` ## FeatureMixingTests__Axis3_WithOnReadonlyData_OverwritingEmbeddedField (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis3_WithOnReadonlyData_OverwritingEmbeddedField topic: data status: verified // verified behavior: Test.run(...) == 34 namespace Test data Vec2 { var x: int var y: int } readonly data Transform { Vec2 scale: int } func run() -> int { let t = Transform { x: 1, y: 2, scale: 3 } let u = t with { Vec2: Vec2 { x: 10, y: 20 } } return u.x + u.y + u.scale + t.x } ``` ## FeatureMixingTests__Axis3_GenericReadonlyData_WithChain (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis3_GenericReadonlyData_WithChain topic: data status: verified // verified behavior: Test.run(...) == 303 namespace Test readonly data Pair { first: A second: B } func run() -> int { let p = Pair { first: 1, second: 2 } let q = p with { first: 100 } let r = q with { second: 200 } return r.first + r.second + p.first + p.second } ``` ## FeatureMixingTests__Axis3_WithUpdatesEmbeddedField_PromotedAccess (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis3_WithUpdatesEmbeddedField_PromotedAccess topic: data status: verified // verified behavior: Test.run(...) == 33 namespace Test data Vec2 { var x: int var y: int } data Wrap { Vec2 tag: int } func run() -> int { let w = Wrap { x: 1, y: 2, tag: 3 } let q = w with { Vec2: Vec2 { x: 10, y: 20 } } return q.x + q.y + q.tag } ``` ## FeatureMixingTests__Axis4_EmbeddedMethodPromoted_SatisfiesProtocol (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis4_EmbeddedMethodPromoted_SatisfiesProtocol topic: interpolation status: verified // verified behavior: Test.run(...) == "hi kae" namespace Test data Greeter { name: string func describe() -> string { return "hi {self.name}" } } data Wrapped : IDescribable { Greeter tag: int } interface IDescribable { func describe() -> string } func report(d: IDescribable) -> string = d.describe() func run() -> string { let w = Wrapped { name: "kae", tag: 1 } return report(w) } ``` ## FeatureMixingTests__Axis4_PointerEmbedded_PointerReceiverSatisfiesProtocol (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis4_PointerEmbedded_PointerReceiverSatisfiesProtocol topic: pointers status: verified // verified behavior: Test.run(...) == 42 namespace Test data Inner { var n: int } func bump(i: *Inner) { i.n += 1 } func value(i: Inner) -> int = i.n data Outer : IBumper { *Inner label: string } interface IBumper { func bump() func value() -> int } func twice(b: IBumper) -> int { b.bump() b.bump() return b.value() } func run() -> int { var o: *Outer = new Outer { Inner: new Inner { n: 40 }, label: "x" } return twice(o) } ``` ## FeatureMixingTests__Axis5_NestedChoiceInChoiceInResult_FullMatch (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis5_NestedChoiceInChoiceInResult_FullMatch topic: choice status: verified // verified behavior: Test.describe(...) == "err:nope" namespace Test choice Token { word(text: string) number(value: int) } choice Lex { one(t: Token) pair(a: Token, b: Token) } func parse(input: string) -> Result { if input == "fail" { return error("nope") } if input == "num" { return ok(Lex.one(Token.number(7))) } return ok(Lex.pair(Token.word("hi"), Token.number(9))) } func describe(input: string) -> string { let r = parse(input) match (r: Result) { .ok(lex) { match (lex: Lex) { .one(o) { match (o.t: Token) { .word(w) { return "one-word:{w.text}" } .number(n) { return "one-num:{n.value}" } } } .pair(p) { var first = "" match (p.a: Token) { .word(w) { first = "w:{w.text}" } .number(n) { first = "n:{n.value}" } } var second = "" match (p.b: Token) { .word(w) { second = "w:{w.text}" } .number(n) { second = "n:{n.value}" } } return "pair:{first},{second}" } } } .err(e) { return "err:{e}" } } return "?" } ``` ## FeatureMixingTests__Axis5_ResultOfChoice_PropagateThroughQuestion (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis5_ResultOfChoice_PropagateThroughQuestion topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Reply { accepted(id: int) rejected(reason: string) } func fetch() -> Result = ok(Reply.accepted(7)) func process() -> Result { let r = fetch()? match (r: Reply) { .accepted(a) { return ok(a.id * 2) } .rejected(_) { return error("nope") } } return error("unreachable") } ``` ## FeatureMixingTests__Axis6_DeriveEquality_OnTypeWithEmbeddedField (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis6_DeriveEquality_OnTypeWithEmbeddedField topic: data status: verified // verified behavior: Test.differingEmbedded(...) == false namespace Test data Vec2 { x: int y: int } derive equality data Box { Vec2 tag: int } func sameTag() -> bool { let a = Box { x: 1, y: 2, tag: 7 } let b = Box { x: 1, y: 2, tag: 7 } return a.Equals(b) } func differingEmbedded() -> bool { let a = Box { x: 1, y: 2, tag: 7 } let b = Box { x: 99, y: 2, tag: 7 } return a.Equals(b) } ``` ## FeatureMixingTests__Axis6_DeriveEquality_OnGenericData (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis6_DeriveEquality_OnGenericData topic: data status: verified // verified behavior: Test.strPair(...) == false namespace Test derive equality data Pair { first: A second: B } func intPair() -> bool { let a = Pair { first: 3, second: 4 } let b = Pair { first: 3, second: 4 } return a.Equals(b) } func strPair() -> bool { let a = Pair { first: "x", second: 1 } let b = Pair { first: "y", second: 1 } return a.Equals(b) } ``` ## FeatureMixingTests__Axis7_AsyncLet_ResultOk_ImplicitAwaitThenUnwrap (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis7_AsyncLet_ResultOk_ImplicitAwaitThenUnwrap topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func loadAsync(n: int) -> Result { let v = await Task.FromResult(n) if v < 0 { return error("neg:{v}") } return ok(v * 10) } func combine() -> Result { async let a = loadAsync(2) async let b = loadAsync(3) let av = a? let bv = b? return ok(av + bv) } ``` ## FeatureMixingTests__Axis7_AsyncLet_FirstError_ShortCircuitsViaQuestion (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Axis7_AsyncLet_FirstError_ShortCircuitsViaQuestion topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func loadAsync(n: int) -> Result { let v = await Task.FromResult(n) if v < 0 { return error("neg") } return ok(v) } func combine() -> Result { async let a = loadAsync(5) async let b = loadAsync(0 - 1) let av = a? let bv = b? return ok(av + bv) } ``` ## FeatureMixingTests__Char_LiteralEqualityAgainstStringIndex (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Char_LiteralEqualityAgainstStringIndex topic: core status: verified // verified behavior: Test.isNewline(...) == true namespace Test func isSpace(s: string, i: int) -> bool { return s[i] == ' ' } func isQuote(s: string, i: int) -> bool { return s[i] == '"' } func isNewline(s: string, i: int) -> bool { return s[i] == '\n' } ``` ## FeatureMixingTests__Char_LetThenCompare (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Char_LetThenCompare topic: core status: verified // verified behavior: Test.check(...) == false namespace Test func check(s: string, i: int) -> bool { let target = 'X' return s[i] == target } ``` ## FeatureMixingTests__Char_PassedToBclMethod (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::Char_PassedToBclMethod topic: core status: verified // verified behavior: Test.isLetterAt(...) == false namespace Test func isLetterAt(s: string, i: int) -> bool { return char.IsLetter(s[i]) } func isDigitAt(s: string, i: int) -> bool { return char.IsDigit(s[i]) } ``` ## FeatureMixingTests__MiniProgram_ConnectionLifecycleStateMachine (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::MiniProgram_ConnectionLifecycleStateMachine topic: choice status: verified // verified behavior: Test.run(...) == "connected:99|failed:timeout" namespace Test choice ConnState { disconnected connecting connected(sessionId: int) failed(reason: string) } data Client { var state: ConnState name: string } func startConnect(c: *Client) -> Result { match (c.state: ConnState) { .disconnected { c.state = ConnState.connecting() return ok(1) } .connecting { return error("already connecting") } .connected(sid) { return error("already connected") } .failed(reason) { return error("in failed: {reason}") } } return error("unreachable") } func markConnected(c: *Client, sid: int) { c.state = ConnState.connected(sid) } func markFailed(c: *Client, reason: string) { c.state = ConnState.failed(reason) } func describe(c: *Client) -> string { match (c.state: ConnState) { .disconnected { return "disconnected" } .connecting { return "connecting" } .connected(sid) { return "connected:{sid}" } .failed(reason) { return "failed:{reason}" } } return "?" } func run() -> string { var c: *Client = new Client { state: ConnState.disconnected(), name: "node-1" } let r1 = startConnect(c) markConnected(c, 99) let mid = describe(c) markFailed(c, "timeout") let end = describe(c) return "{mid}|{end}" } ``` ## FeatureMixingTests__MiniProgram_TinyJsonParser_NumbersAndStrings (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::MiniProgram_TinyJsonParser_NumbersAndStrings topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Token { integer(value: int) str(text: string) eof } data Lex { var src: string var pos: int } func skipSpace(l: *Lex) { while l.pos < l.src.Length { let c = l.src[l.pos] if c == ' ' || c == '\t' || c == '\n' { l.pos += 1 } else { return } } } func nextToken(l: *Lex) -> Result { skipSpace(l) if l.pos >= l.src.Length { return ok(Token.eof()) } let c = l.src[l.pos] if c == '"' { l.pos += 1 let start = l.pos while l.pos < l.src.Length && l.src[l.pos] != '"' { l.pos += 1 } if l.pos >= l.src.Length { return error("unterminated string") } let text = l.src.Substring(start, l.pos - start) l.pos += 1 return ok(Token.str(text)) } if char.IsDigit(c) { let start = l.pos while l.pos < l.src.Length && char.IsDigit(l.src[l.pos]) { l.pos += 1 } let text = l.src.Substring(start, l.pos - start) return ok(Token.integer(int.Parse(text))) } return error("unexpected char") } func sumIntegersUntilEof(input: string) -> Result { var l: *Lex = new Lex { src: input, pos: 0 } var total = 0 while true { let tok = nextToken(l)? match (tok: Token) { .integer(i) { total += i.value } .str(_) { } .eof { return ok(total) } } } return ok(total) } ``` ## FeatureMixingTests__MiniProgram_CliArgRouter (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FeatureMixingTests.cs::MiniProgram_CliArgRouter topic: choice status: verified // verified behavior: Test.run3(...) == "?nope" namespace Test choice Cmd { help add(a: int, b: int) greet(name: string) unknown(name: string) } func parseCmd(args: List) -> Cmd { if args.Count == 0 { return Cmd.help() } let head = args[0] if head == "help" { return Cmd.help() } if head == "add" { if args.Count < 3 { return Cmd.unknown("add: need 2 args") } return Cmd.add(int.Parse(args[1]), int.Parse(args[2])) } if head == "greet" { let n = args.Count >= 2 ? args[1] : "world" return Cmd.greet(n) } return Cmd.unknown(head) } func dispatch(args: List) -> string { let c = parseCmd(args) match (c: Cmd) { .help { return "usage: help|add|greet" } .add(a, b) { return "sum={a + b}" } .greet(name) { return "hi {name}" } .unknown(n) { return "?{n}" } } return "?" } func run1() -> string { var args = List() args.Add("add") args.Add("3") args.Add("4") return dispatch(args) } func run2() -> string { var args = List() args.Add("greet") return dispatch(args) } func run3() -> string { var args = List() args.Add("nope") return dispatch(args) } ``` ## OptionalArgTests__IntDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::IntDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int = Lib.scale(5) ``` ## OptionalArgTests__IntDefault_Overridden_When_Passed (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::IntDefault_Overridden_When_Passed topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int = Lib.scale(5, 3) ``` ## OptionalArgTests__BoolDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::BoolDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> bool = Lib.flag() ``` ## OptionalArgTests__StringDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::StringDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string = Lib.label("hi") ``` ## OptionalArgTests__MultipleDefaults_AllOmitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::MultipleDefaults_AllOmitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int = Lib.two() ``` ## OptionalArgTests__MultipleDefaults_FirstPassed_SecondDefaulted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::MultipleDefaults_FirstPassed_SecondDefaulted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int = Lib.two(7) ``` ## OptionalArgTests__EnumDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::EnumDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int = Lib.withMode(10) ``` ## OptionalArgTests__CharDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::CharDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string = Lib.repeat("ab") ``` ## OptionalArgTests__DoubleDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::DoubleDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double = Lib.half(8.0) ``` ## OptionalArgTests__NullReferenceDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::NullReferenceDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int = Lib.lenOr() ``` ## OptionalArgTests__LongDefault_Used_When_Omitted (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::LongDefault_Used_When_Omitted topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> long = Lib.big() ``` ## OptionalArgTests__ConstructorDefault_Used_When_Omitted (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::ConstructorDefault_Used_When_Omitted topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let c = Counter() return c.Value } ``` ## OptionalArgTests__InstanceMethodDefault_Used_When_Omitted (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: OptionalArgTests.cs::InstanceMethodDefault_Used_When_Omitted topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let c = Counter(100) return c.bump() } ``` ## ILEmitterTests_Refs__AddressOf_PassedToByRefParam_Works (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::AddressOf_PassedToByRefParam_Works topic: pointers status: verified // verified behavior: Test.test(...) == 2 namespace Test func increment(x: *int) { x += 1 } func test() -> int { var count = 0 increment(&count) increment(&count) return count } ``` ## ILEmitterTests_Refs__RefLocal_ReadThroughPointer_Works (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::RefLocal_ReadThroughPointer_Works topic: pointers status: verified // verified behavior: Test.test(...) == 42 namespace Test func test() -> int { var x = 42 var p = &x return p } ``` ## ILEmitterTests_Refs__RefLocal_WriteThroughPointer_MutatesOriginal (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::RefLocal_WriteThroughPointer_MutatesOriginal topic: pointers status: verified // verified behavior: Test.test(...) == 15 namespace Test func test() -> int { var x = 10 var p = &x p += 5 return x } ``` ## ILEmitterTests_Refs__RefLocal_MultipleWrites_Accumulate (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::RefLocal_MultipleWrites_Accumulate topic: pointers status: verified // verified behavior: Test.test(...) == 3 namespace Test func test() -> int { var count = 0 var p = &count p += 1 p += 1 p += 1 return count } ``` ## ILEmitterTests_Refs__ReadOnlyByRef_CanReadThrough (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::ReadOnlyByRef_CanReadThrough topic: pointers status: verified // verified behavior: Test.test(...) == 42 namespace Test func readVal(x: readonly *int) -> int { return x } func test() -> int { var n = 42 return readVal(&n) } ``` ## ILEmitterTests_Refs__ReadOnlyByRef_StructFieldAccess_Works (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::ReadOnlyByRef_StructFieldAccess_Works topic: pointers status: verified // verified behavior: Test.test(...) == 50.0f namespace Test data Rect { x: float y: float w: float h: float } func area(r: readonly *Rect) -> float { return r.w * r.h } func test() -> float { let r = Rect { x: 0.0, y: 0.0, w: 10.0, h: 5.0 } let result = area(&r) return result } ``` ## ILEmitterTests_Refs__ReadOnlyByRef_HasInAttribute (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::ReadOnlyByRef_HasInAttribute topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func readOnly(x: readonly *int) -> int { return x } ``` ## ILEmitterTests_Refs__OutParam_Int_WritesThrough (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::OutParam_Int_WritesThrough topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func try_inc(input: int, out result: int) -> bool { result = input + 1 return true } ``` ## ILEmitterTests_Refs__OutParam_ReferenceType_WritesThrough (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::OutParam_ReferenceType_WritesThrough topic: pointers status: verified // verified behavior: Test.label(...) == false namespace Test func label(n: int, out text: string) -> bool { if n == 0 { text = "zero" return true } text = "other" return false } ``` ## ILEmitterTests_Refs__OutParam_HasByRefAndOutAttribute (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::OutParam_HasByRefAndOutAttribute topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func emit(out value: int) { value = 7 } ``` ## ILEmitterTests_Refs__OutParam_EsharpCallSite_PassesByRef (pointers, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::OutParam_EsharpCallSite_PassesByRef topic: pointers status: unverified // verified behavior: Test.use_declared(...) == 100 namespace Test func try_inc(input: int, out result: int) -> bool { result = input + 1 return true } func use_existing() -> int { var n = 0 try_inc(41, out n) return n } func use_declared() -> int { if try_inc(99, out var m) { return m } return -1 } ``` ## ILEmitterTests_Refs__OutParam_TryPattern_BothBranchesAssign (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Refs.cs::OutParam_TryPattern_BothBranchesAssign topic: pointers status: verified // verified behavior: Test.divide(...) == false namespace Test func divide(a: int, b: int, out q: int) -> bool { if b == 0 { q = 0 return false } q = a / b return true } ``` ## SourceSpanTests__Parser_CapturesStatementLineNumbers (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: SourceSpanTests.cs::Parser_CapturesStatementLineNumbers topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func add(a: int, b: int) -> int { var total = a total += b return total } ``` ## SourceSpanTests__Binder_PropagatesSpanToStatements (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: SourceSpanTests.cs::Binder_PropagatesSpanToStatements topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func run() -> int { let x = 42 return x } ``` ## SourceSpanTests__IfStatement_HasCorrectSpan (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: SourceSpanTests.cs::IfStatement_HasCorrectSpan topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func check(x: int) -> int { if x > 0 { return x } return 0 } ``` ## ILEmitterTests_Coverage_Errors__Result_OkCarriesValue (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_OkCarriesValue topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func parse(s: string) -> Result { return ok(42) } func go() -> int { let r = parse("x") return r.IsOk ? r.Value : -1 } ``` ## ILEmitterTests_Coverage_Errors__Result_ErrorCarriesError (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_ErrorCarriesError topic: result status: verified // verified behavior: Test.go(...) == "bad" namespace Test func parse(s: string) -> Result { return error("bad") } func go() -> string { let r = parse("x") return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_Coverage_Errors__Result_IsOkTrueOnOk (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_IsOkTrueOnOk topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func f() -> Result { return ok(1) } func go() -> bool { return f().IsOk } ``` ## ILEmitterTests_Coverage_Errors__Result_IsErrorTrueOnError (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_IsErrorTrueOnError topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func f() -> Result { return error("e") } func go() -> bool { return f().IsError } ``` ## ILEmitterTests_Coverage_Errors__Result_BranchOnValidation (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_BranchOnValidation topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func validate(n: int) -> Result { if n < 0 { return error("negative") } return ok(n) } func go() -> int { let r = validate(7) if r.IsOk { return r.Value } return -1 } ``` ## ILEmitterTests_Coverage_Errors__Result_BranchOnInvalid (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_BranchOnInvalid topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func validate(n: int) -> Result { if n < 0 { return error("negative") } return ok(n) } func go() -> int { let r = validate(-5) if r.IsOk { return r.Value } return -1 } ``` ## ILEmitterTests_Coverage_Errors__Propagation_ChainsThroughSuccess (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Propagation_ChainsThroughSuccess topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func parse(s: string) -> Result { if s == "" { return error("empty") } return ok(int.Parse(s)) } func chain(s: string) -> Result { let n = parse(s)? return ok(n + 1) } func go() -> int { let r = chain("42") return r.IsOk ? r.Value : -1 } ``` ## ILEmitterTests_Coverage_Errors__Propagation_ShortCircuitsOnError (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Propagation_ShortCircuitsOnError topic: result status: verified // verified behavior: Test.go(...) == "empty" namespace Test func parse(s: string) -> Result { if s == "" { return error("empty") } return ok(int.Parse(s)) } func chain(s: string) -> Result { let n = parse(s)? return ok(n + 1) } func go() -> string { let r = chain("") return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_Coverage_Errors__Propagation_TwoStageChain (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Propagation_TwoStageChain topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func step1(n: int) -> Result { if n == 0 { return error("zero") } return ok(n * 2) } func step2(n: int) -> Result { return ok(n + 10) } func pipeline(n: int) -> Result { let a = step1(n)? let b = step2(a)? return ok(b) } func go() -> int { let r = pipeline(5) return r.IsOk ? r.Value : -1 } ``` ## ILEmitterTests_Coverage_Errors__Propagation_SecondStageErrorWins (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Propagation_SecondStageErrorWins topic: result status: verified // verified behavior: Test.go(...) == "zero" namespace Test func step1(n: int) -> Result { return ok(n) } func step2(n: int) -> Result { if n == 0 { return error("zero") } return ok(n + 10) } func pipeline(n: int) -> Result { let a = step1(n)? let b = step2(a)? return ok(b) } func go() -> string { let r = pipeline(0) return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_Coverage_Errors__Result_ChoiceErrorVariant (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_ChoiceErrorVariant topic: choice status: verified // verified behavior: Test.go(...) == "notFound" namespace Test choice DbError { notFound timeout connectionFailed(message: string) } func lookup(id: int) -> Result { if id == 0 { return error(DbError.notFound()) } return ok(id) } func go() -> string { let r = lookup(0) if r.IsError { match r.Error { .notFound { return "notFound" } .timeout { return "timeout" } .connectionFailed(c) { return "conn" } } } return "ok" } ``` ## ILEmitterTests_Coverage_Errors__Result_ChoiceErrorWithPayload (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_ChoiceErrorWithPayload topic: choice status: verified // verified behavior: Test.go(...) == "conn:down" namespace Test choice DbError { notFound connectionFailed(message: string) } func lookup(id: int) -> Result { return error(DbError.connectionFailed("down")) } func go() -> string { let r = lookup(1) if r.IsError { match r.Error { .notFound { return "notFound" } .connectionFailed(c) { return "conn:{c.message}" } } } return "ok" } ``` ## ILEmitterTests_Coverage_Errors__Result_DotCaseShorthandError (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_DotCaseShorthandError topic: choice status: verified // verified behavior: Test.go(...) == "notFound" namespace Test choice DbError { notFound timeout } func lookup(id: int) -> Result { if id == 0 { return error(.notFound) } return ok(id) } func go() -> string { let r = lookup(0) if r.IsError { match r.Error { .notFound { return "notFound" } .timeout { return "timeout" } } } return "ok" } ``` ## ILEmitterTests_Coverage_Errors__LetElse_BindsPresentValue (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::LetElse_BindsPresentValue topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func lookup(id: int) -> int? { if id == 0 { return nil } return 50 } func go() -> int { let v = lookup(3) else { return -1 } return v } ``` ## ILEmitterTests_Coverage_Errors__LetElse_DivertsOnNil (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::LetElse_DivertsOnNil topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func lookup(id: int) -> int? { if id == 0 { return nil } return 50 } func go() -> int { let v = lookup(0) else { return -99 } return v } ``` ## ILEmitterTests_Coverage_Errors__LetElse_ChainedGuards (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::LetElse_ChainedGuards topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func first(id: int) -> int? { if id < 0 { return nil } return 10 } func second(n: int) -> int? { if n == 0 { return nil } return n + 5 } func go() -> int { let a = first(2) else { return -1 } let b = second(a) else { return -2 } return b } ``` ## ILEmitterTests_Coverage_Errors__LetElse_SecondGuardDiverts (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::LetElse_SecondGuardDiverts topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func first(id: int) -> int? { return 0 } func second(n: int) -> int? { if n == 0 { return nil } return n + 5 } func go() -> int { let a = first(2) else { return -1 } let b = second(a) else { return -2 } return b } ``` ## ILEmitterTests_Coverage_Errors__Combinator_UnwrapOr_Ok (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Combinator_UnwrapOr_Ok topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func f() -> Result { return ok(42) } func go() -> int { return f().UnwrapOr(-1) } ``` ## ILEmitterTests_Coverage_Errors__Combinator_UnwrapOr_Error (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Combinator_UnwrapOr_Error topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func f() -> Result { return error("bad") } func go() -> int { return f().UnwrapOr(-1) } ``` ## ILEmitterTests_Coverage_Errors__Combinator_Unwrap_Ok (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Combinator_Unwrap_Ok topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func f() -> Result { return ok(7) } func go() -> int { return f().Unwrap() } ``` ## ILEmitterTests_Coverage_Errors__Result_StoredAndReread (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_StoredAndReread topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func produce(n: int) -> Result { return ok(n + 3) } func go() -> int { let r = produce(30) let s = produce(r.Value) return s.IsOk ? r.Value : -1 } ``` ## ILEmitterTests_Coverage_Errors__Result_VoidLikeOkUnit (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_VoidLikeOkUnit topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func validate(n: int) -> Result { if n > 0 { return ok(n) } return error("non-positive") } func go() -> int { let r = validate(5) return r.IsOk ? 1 : 0 } ``` ## ILEmitterTests_Coverage_Errors__TryCatch_RecoversFromParseFailure (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::TryCatch_RecoversFromParseFailure topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var result = 0 try { result = int.Parse("notanumber") } catch (FormatException e) { result = -1 } return result } ``` ## ILEmitterTests_Coverage_Errors__TryCatch_SuccessPathSkipsCatch (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::TryCatch_SuccessPathSkipsCatch topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var result = 0 try { result = int.Parse("123") } catch (FormatException e) { result = -1 } return result } ``` ## ILEmitterTests_Coverage_Errors__TryCatch_BareCatchSwallows (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::TryCatch_BareCatchSwallows topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var result = 0 try { result = int.Parse("xyz") } catch { result = -7 } return result } ``` ## ILEmitterTests_Coverage_Errors__Throw_CaughtByCallerBoundary (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Throw_CaughtByCallerBoundary topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func risky(n: int) -> int { if n < 0 { throw InvalidOperationException("negative") } return n } func go() -> int { var result = 0 try { result = risky(-1) } catch (Exception e) { result = -42 } return result } ``` ## ILEmitterTests_Coverage_Errors__TryCatch_TypedCatchBindsMessage (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::TryCatch_TypedCatchBindsMessage topic: core status: verified // verified behavior: Test.go(...) == "negative" namespace Test func go() -> string { var msg = "none" try { throw InvalidOperationException("negative") } catch (InvalidOperationException e) { msg = e.Message } return msg } ``` ## ILEmitterTests_Coverage_Errors__TryCatch_Nested_InnerHandlesFirst (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::TryCatch_Nested_InnerHandlesFirst topic: core status: verified // verified behavior: Test.go(...) == "inner" namespace Test func go() -> string { var tag = "none" try { try { throw FormatException("x") } catch (FormatException e) { tag = "inner" } } catch (Exception e) { tag = "outer" } return tag } ``` ## ILEmitterTests_Coverage_Errors__Defer_RunsAsCleanupInTry (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Defer_RunsAsCleanupInTry topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { var closed: int } func go() -> int { var b: *Box = new Box { closed: 0 } work(b) return b.closed } func work(b: *Box) { defer { b.closed = 1 } let n = 5 } ``` ## ILEmitterTests_Coverage_Errors__Defer_RunsEvenWhenScopeReturnsEarly (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Defer_RunsEvenWhenScopeReturnsEarly topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { var closed: int } func go() -> int { var b: *Box = new Box { closed: 0 } work(b, true) return b.closed } func work(b: *Box, bail: bool) { defer { b.closed = 1 } if bail { return } b.closed = 99 } ``` ## ILEmitterTests_Coverage_Errors__Pipeline_ThreeStageSuccess (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Pipeline_ThreeStageSuccess topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func parse(s: string) -> Result { if s == "" { return error("empty") } return ok(int.Parse(s)) } func positive(n: int) -> Result { if n <= 0 { return error("non-positive") } return ok(n) } func doubleIt(n: int) -> Result { return ok(n * 2) } func run(s: string) -> Result { let a = parse(s)? let b = positive(a)? let c = doubleIt(b)? return ok(c + 0) } func go() -> int { let r = run("13") return r.IsOk ? r.Value : -1 } ``` ## ILEmitterTests_Coverage_Errors__Pipeline_MiddleStageFails (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Pipeline_MiddleStageFails topic: result status: verified // verified behavior: Test.go(...) == "non-positive" namespace Test func parse(s: string) -> Result { if s == "" { return error("empty") } return ok(int.Parse(s)) } func positive(n: int) -> Result { if n <= 0 { return error("non-positive") } return ok(n) } func run(s: string) -> Result { let a = parse(s)? let b = positive(a)? return ok(b) } func go() -> string { let r = run("0") return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_Coverage_Errors__Result_OkCarriesDataValue (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_OkCarriesDataValue topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data User { id: int, age: int } func load(id: int) -> Result { if id == 0 { return error("missing") } return ok(User { id: id, age: 30 }) } func go() -> int { let r = load(1) if r.IsOk { return r.Value.age } return -1 } ``` ## ILEmitterTests_Coverage_Errors__Result_DataPayloadThroughPropagation (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_DataPayloadThroughPropagation topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data User { id: int, score: int } func load(id: int) -> Result { if id == 0 { return error("missing") } return ok(User { id: id, score: 7 }) } func scoreOf(id: int) -> Result { let u = load(id)? return ok(u.score) } func go() -> int { let r = scoreOf(5) return r.IsOk ? r.Value : -1 } ``` ## ILEmitterTests_Coverage_Errors__OptionInt_SomeUnwraps (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::OptionInt_SomeUnwraps topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice OptionInt { some(value: int) none } func get(present: bool) -> OptionInt { if present { return OptionInt.some(42) } return OptionInt.none() } func go() -> int { let o = get(true) match o { .some(v) { return v } .none { return -1 } } return -1 } ``` ## ILEmitterTests_Coverage_Errors__OptionInt_NoneFallsBack (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::OptionInt_NoneFallsBack topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice OptionInt { some(value: int) none } func get(present: bool) -> OptionInt { if present { return OptionInt.some(42) } return OptionInt.none() } func go() -> int { let o = get(false) match o { .some(v) { return v } .none { return -1 } } return -1 } ``` ## ILEmitterTests_Coverage_Errors__Result_MapErrorMessageManually (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_MapErrorMessageManually topic: result status: verified // verified behavior: Test.go(...) == "wrapped:empty" namespace Test func parse(s: string) -> Result { if s == "" { return error("empty") } return ok(int.Parse(s)) } func wrap(s: string) -> Result { let r = parse(s) if r.IsError { return error("wrapped:{r.Error}") } return ok(r.Value) } func go() -> string { let r = wrap("") return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_Coverage_Errors__Result_AccumulateOverList (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_AccumulateOverList topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func parse(s: string) -> Result { return ok(int.Parse(s)) } func sumAll(items: List) -> Result { var total = 0 for s in items { let n = parse(s)? total += n } return ok(total) } func go() -> int { let xs = ["1", "2", "3"] let r = sumAll(xs) return r.IsOk ? r.Value : -1 } ``` ## ILEmitterTests_Coverage_Errors__Result_EarlyErrorStopsAccumulation (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Errors.cs::Result_EarlyErrorStopsAccumulation topic: result status: verified // verified behavior: Test.go(...) == "bad" namespace Test func parse(s: string) -> Result { if s == "x" { return error("bad") } return ok(int.Parse(s)) } func sumAll(items: List) -> Result { var total = 0 for s in items { let n = parse(s)? total += n } return ok(total) } func go() -> string { let xs = ["1", "x", "3"] let r = sumAll(xs) return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_GenericDerive__IntPair_Equal (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::IntPair_Equal topic: core status: unverified // verified behavior: Test.go(...) == true func go() -> bool { let a = Pair { first: 3, second: 4 } let b = Pair { first: 3, second: 4 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__IntPair_NotEqual (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::IntPair_NotEqual topic: core status: unverified // verified behavior: Test.go(...) == false func go() -> bool { let a = Pair { first: 3, second: 4 } let b = Pair { first: 3, second: 5 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__StrPair_NotEqual (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::StrPair_NotEqual topic: core status: unverified // verified behavior: Test.go(...) == false func go() -> bool { let a = Pair { first: "x", second: 1 } let b = Pair { first: "y", second: 1 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__StrPair_Equal (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::StrPair_Equal topic: core status: unverified // verified behavior: Test.go(...) == true func go() -> bool { let a = Pair { first: "x", second: 1 } let b = Pair { first: "x", second: 1 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__TwoInstantiations_Independent (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::TwoInstantiations_Independent topic: core status: unverified // verified behavior: Test.go(...) == true func ints() -> bool { let a = Pair { first: 1, second: 2 } let b = Pair { first: 1, second: 2 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__MixedTypeArgs_Equal (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::MixedTypeArgs_Equal topic: core status: unverified // verified behavior: Test.go(...) == true func go() -> bool { let a = Pair { first: "y", second: true } let b = Pair { first: "y", second: true } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__GetHashCode_EqualValuesEqualHash (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::GetHashCode_EqualValuesEqualHash topic: core status: unverified // verified behavior: Test.go(...) == true func go() -> bool { let a = Pair { first: 7, second: 8 } let b = Pair { first: 7, second: 8 } return a.GetHashCode() == b.GetHashCode() } ``` ## ILEmitterTests_GenericDerive__ObjectEquals_DelegatesToTyped (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::ObjectEquals_DelegatesToTyped topic: core status: unverified // verified behavior: Test.go(...) == true func go() -> bool { let a = Pair { first: 1, second: 1 } let b = Pair { first: 1, second: 1 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__DeriveDebug_GenericToString (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::DeriveDebug_GenericToString topic: data status: verified // verified behavior: Test.go(...) == "Pair { first = 3, second = 4 }" derive debug data Pair { first: A second: B } func go() -> string { let p = Pair { first: 3, second: 4 } return p.ToString() } ``` ## ILEmitterTests_GenericDerive__DeriveDebug_GenericStringFields (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::DeriveDebug_GenericStringFields topic: data status: verified // verified behavior: Test.go(...) == "Pair { first = a, second = b }" derive debug data Pair { first: A second: B } func go() -> string { let p = Pair { first: "a", second: "b" } return p.ToString() } ``` ## ILEmitterTests_GenericDerive__DeriveBoth_EqualityAndDebug (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::DeriveBoth_EqualityAndDebug topic: generics status: verified // verified behavior: Test.go(...) == "Box { item = 5 }" derive equality, debug data Box { item: T } func go() -> string { let a = Box { item: 5 } return a.ToString() } ``` ## ILEmitterTests_GenericDerive__SingleTypeParam_Equality (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::SingleTypeParam_Equality topic: generics status: verified // verified behavior: Test.go(...) == true derive equality data Box { item: T } func go() -> bool { let a = Box { item: 42 } let b = Box { item: 42 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__GenericEquals_AcrossFunctionBoundary (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::GenericEquals_AcrossFunctionBoundary topic: core status: unverified // verified behavior: Test.go(...) == true func same(a: Pair, b: Pair) -> bool = a.Equals(b) func go() -> bool { let x = Pair { first: 9, second: 9 } let y = Pair { first: 9, second: 9 } return same(x, y) } ``` ## ILEmitterTests_GenericDerive__NonGenericDerive_StillWorks (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::NonGenericDerive_StillWorks topic: data status: verified // verified behavior: Test.go(...) == true derive equality data Point { x: int y: int } func go() -> bool { let a = Point { x: 1, y: 2 } let b = Point { x: 1, y: 2 } return a.Equals(b) } ``` ## ILEmitterTests_GenericDerive__GenericDebug_BoolField (generics, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::GenericDebug_BoolField topic: generics status: verified // verified behavior: Test.go(...) == "Flag { on = True }" derive debug data Flag { on: T } func go() -> string { let f = Flag { on: true } return f.ToString() } ``` ## ILEmitterTests_GenericDerive__GenericEquality_ReturnedFromMatch (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_GenericDerive.cs::GenericEquality_ReturnedFromMatch topic: choice status: unverified // verified behavior: Test.go(...) == true func go() -> bool { let a = Pair { first: 2, second: 3 } let b = Pair { first: 2, second: 3 } let eq = a.Equals(b) return match eq { true { true } false { false } } } ``` ## ILEmitterTests_Coverage_ControlFlow__If_TakesThenBranch (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::If_TakesThenBranch topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { if 3 < 4 { return 1 } return 0 } ``` ## ILEmitterTests_Coverage_ControlFlow__If_Else_TakesElseBranch (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::If_Else_TakesElseBranch topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { if 4 < 3 { return 1 } else { return 0 } } ``` ## ILEmitterTests_Coverage_ControlFlow__IfElseIf_Chain_PicksMiddle (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::IfElseIf_Chain_PicksMiddle topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func classify(n: int) -> int { if n < 0 { return 1 } else if n == 0 { return 2 } else { return 3 } } func go() -> int { return classify(0) } ``` ## ILEmitterTests_Coverage_ControlFlow__If_Nested (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::If_Nested topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let a = 5 let b = 10 if a > 0 { if b > 0 { return 42 } } return 0 } ``` ## ILEmitterTests_Coverage_ControlFlow__If_AsGuard_NoElse_FallsThrough (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::If_AsGuard_NoElse_FallsThrough topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var n = 7 if n < 0 { n = 0 } return n } ``` ## ILEmitterTests_Coverage_ControlFlow__While_AccumulatesSum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::While_AccumulatesSum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var i = 1 var total = 0 while i <= 5 { total += i i += 1 } return total } ``` ## ILEmitterTests_Coverage_ControlFlow__While_Countdown (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::While_Countdown topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var n = 10 while n > 0 { n -= 1 } return n } ``` ## ILEmitterTests_Coverage_ControlFlow__While_FalseCondition_NeverRuns (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::While_FalseCondition_NeverRuns topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var n = 99 while false { n = 0 } return n } ``` ## ILEmitterTests_Coverage_ControlFlow__While_NestedMultiplicationTable (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::While_NestedMultiplicationTable topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var i = 1 var sum = 0 while i <= 5 { var j = 1 while j <= 5 { sum += i * j j += 1 } i += 1 } return sum } ``` ## ILEmitterTests_Coverage_ControlFlow__While_TrueWithEarlyReturn (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::While_TrueWithEarlyReturn topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var n = 0 while true { n += 2 if n >= 8 { return n } } return -1 } ``` ## ILEmitterTests_Coverage_ControlFlow__For_Range_Exclusive (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_Range_Exclusive topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var total = 0 for i in 0..5 { total += i } return total } ``` ## ILEmitterTests_Coverage_ControlFlow__For_Range_WithVariableBounds (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_Range_WithVariableBounds topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func sumRange(lo: int, hi: int) -> int { var total = 0 for i in lo..hi { total += i } return total } func go() -> int { return sumRange(3, 5) } ``` ## ILEmitterTests_Coverage_ControlFlow__For_OverListLiteral (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_OverListLiteral topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var total = 0 for x in [10, 20, 30] { total += x } return total } ``` ## ILEmitterTests_Coverage_ControlFlow__For_Nested_Ranges (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_Nested_Ranges topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var count = 0 for i in 0..3 { for j in 0..3 { count += 1 } } return count } ``` ## ILEmitterTests_Coverage_ControlFlow__For_RangeBuildsProduct (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_RangeBuildsProduct topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var product = 1 for i in 1..6 { product *= i } return product } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_IntLiteral (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_IntLiteral topic: choice status: verified // verified behavior: Test.go(...) == "not found" namespace Test func describe(code: int) -> string { match code { 200 { return "ok" } 404 { return "not found" } 500 { return "server error" } default { return "unknown" } } } func go() -> string { return describe(404) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_IntLiteral_DefaultArm (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_IntLiteral_DefaultArm topic: choice status: verified // verified behavior: Test.go(...) == "unknown" namespace Test func describe(code: int) -> string { match code { 200 { return "ok" } default { return "unknown" } } } func go() -> string { return describe(301) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_StringLiteral (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_StringLiteral topic: choice status: verified // verified behavior: Test.go(...) == "admin-perms" namespace Test func perms(role: string) -> string { match role { "admin" { return "admin-perms" } "guest" { return "guest-perms" } default { return "none" } } } func go() -> string { return perms("admin") } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_BoolLiteral (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_BoolLiteral topic: choice status: verified // verified behavior: Test.go(...) == "on" namespace Test func label(flag: bool) -> string { match flag { true { return "on" } false { return "off" } } } func go() -> string { return label(true) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_NegativeIntLiteral (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_NegativeIntLiteral topic: choice status: verified // verified behavior: Test.go(...) == "neg" namespace Test func sign(n: int) -> string { match n { -1 { return "neg" } 0 { return "zero" } 1 { return "pos" } default { return "?" } } } func go() -> string { return sign(-1) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_AsExpression_InLet (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_AsExpression_InLet topic: choice status: verified // verified behavior: Test.go(...) == "not found" namespace Test func go() -> string { let status = 404 let label = match status { 200 { "ok" } 404 { "not found" } default { "other" } } return label } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_AsExpression_InInterpolation (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_AsExpression_InInterpolation topic: choice status: verified // verified behavior: Test.go(...) == "code=ok" namespace Test func go() -> string { let status = 200 return "code={match status { 200 { "ok" } default { "?" } }}" } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_AsExpression_ExpressionBodiedFunc (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_AsExpression_ExpressionBodiedFunc topic: choice status: verified // verified behavior: Test.go(...) == "two" namespace Test func name(n: int) -> string = match n { 1 { "one" } 2 { "two" } default { "many" } } func go() -> string { return name(2) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Nested (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Nested topic: choice status: verified // verified behavior: Test.go(...) == "a-inner" namespace Test func go() -> string { let outer = "a" let inner = 1 match outer { "a" { match inner { 1 { return "a-inner" } default { return "a-other" } } } default { return "other" } } return "?" } ``` ## ILEmitterTests_Coverage_ControlFlow__Defer_LifoOrder (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Defer_LifoOrder topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { var n: int } func go() -> int { var b: *Box = new Box { n: 2 } apply(b) return b.n } func apply(b: *Box) { defer { b.n += 2 } defer { b.n *= 5 } } ``` ## ILEmitterTests_Coverage_ControlFlow__Defer_RunsOnEarlyReturn (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Defer_RunsOnEarlyReturn topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { var n: int } func go() -> int { var b: *Box = new Box { n: 0 } apply(b, true) return b.n } func apply(b: *Box, early: bool) { defer { b.n += 1 } if early { return } b.n += 100 } ``` ## ILEmitterTests_Coverage_ControlFlow__Defer_ThreeInReverseOrder (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Defer_ThreeInReverseOrder topic: pointers status: verified // verified behavior: Test.go(...) == "321" namespace Test data Buf { var s: string } func go() -> string { var b: *Buf = new Buf { s: "" } apply(b) return b.s } func apply(b: *Buf) { defer { b.s = b.s + "1" } defer { b.s = b.s + "2" } defer { b.s = b.s + "3" } } ``` ## ILEmitterTests_Coverage_ControlFlow__LetElse_BindsOnPresent (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::LetElse_BindsOnPresent topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func find(id: int) -> int? { if id == 0 { return nil } return 5 } func go() -> int { let v = find(1) else { return -1 } return v } ``` ## ILEmitterTests_Coverage_ControlFlow__LetElse_TakesElseOnNil (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::LetElse_TakesElseOnNil topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func find(id: int) -> int? { if id == 0 { return nil } return 5 } func go() -> int { let v = find(0) else { return -1 } return v } ``` ## ILEmitterTests_Coverage_ControlFlow__Ternary_SelectsBranch (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Ternary_SelectsBranch topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let x = -9 return x > 0 ? x : 0 - x } ``` ## ILEmitterTests_Coverage_ControlFlow__Ternary_Nested (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Ternary_Nested topic: core status: verified // verified behavior: Test.go(...) == "zero" namespace Test func sign(n: int) -> string { return n > 0 ? "pos" : (n < 0 ? "neg" : "zero") } func go() -> string { return sign(0) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Enum_BasicDispatch (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Enum_BasicDispatch topic: choice status: verified // verified behavior: Test.go(...) == "S" namespace Test enum Direction { north, south, east, west } func glyph(d: Direction) -> string { match (d: Direction) { .north { return "N" } .south { return "S" } .east { return "E" } .west { return "W" } } return "?" } func go() -> string { return glyph(Direction.south()) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Enum_WithDefaultArm (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Enum_WithDefaultArm topic: choice status: verified // verified behavior: Test.go(...) == "other" namespace Test enum Size { small, medium, large } func label(s: Size) -> string { match (s: Size) { .small { return "S" } default { return "other" } } } func go() -> string { return label(Size.large()) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Enum_ExplicitValues (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Enum_ExplicitValues topic: choice status: verified // verified behavior: Test.go(...) == "warn" namespace Test enum Code { ok = 0, warn = 10, fail = 20 } func name(c: Code) -> string { match (c: Code) { .ok { return "ok" } .warn { return "warn" } .fail { return "fail" } default { return "?" } } } func go() -> string { return name(Code.warn()) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Enum_AsExpression (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Enum_AsExpression topic: choice status: verified // verified behavior: Test.go(...) == "N" namespace Test enum Dir { north, south } func go() -> string { let d = Dir.north() let name = match (d: Dir) { .north { "N" } .south { "S" } default { "?" } } return name } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Choice_ZeroPayload (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Choice_ZeroPayload topic: choice status: verified // verified behavior: Test.go(...) == "a" namespace Test choice Cmd { help quit } func go() -> string { let c = Cmd.help() match c { .help { return "a" } .quit { return "b" } } return "?" } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Choice_SinglePayloadBinding (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Choice_SinglePayloadBinding topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Box { empty full(value: int) } func go() -> int { let b = Box.full(42) match b { .empty { return 0 } .full(v) { return v } } return -1 } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Choice_MultiPayloadDestructure (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Choice_MultiPayloadDestructure topic: choice status: verified // verified behavior: Test.go(...) == "[3] hi" namespace Test choice LogEntry { message(level: int, text: string) blank } func go() -> string { let e = LogEntry.message(3, "hi") match e { .message(lvl, txt) { return "[{lvl}] {txt}" } .blank { return "" } } return "?" } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Choice_CaseViewProjection (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Choice_CaseViewProjection topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Pair { one(a: int) two(a: int, b: int) } func go() -> int { let p = Pair.two(3, 4) match p { .one(o) { return o.a } .two(t) { return t.a + t.b } } return -1 } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Choice_AsExpression (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Choice_AsExpression topic: choice status: verified // verified behavior: Test.go(...) == "sum=7" namespace Test choice Cmd { add(a: int, b: int) nop } func go() -> string { let c = Cmd.add(3, 4) return match c { .add(a, b) { "sum={a + b}" } .nop { "noop" } } } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Choice_GenericOption (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Choice_GenericOption topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Option { some(value: T) none } func unwrapOr(o: Option, fallback: int) -> int { match o { .some(v) { return v } .none { return fallback } } return fallback } func go() -> int { let o = Option.some(99) return unwrapOr(o, -1) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_Choice_GenericOption_NoneFallback (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_Choice_GenericOption_NoneFallback topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Option { some(value: T) none } func unwrapOr(o: Option, fallback: int) -> int { match o { .some(v) { return v } .none { return fallback } } return fallback } func go() -> int { let o = Option.none() return unwrapOr(o, -1) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_RefChoice_RecursiveEval (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_RefChoice_RecursiveEval topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Expr { literal(value: int) add(left: Expr, right: Expr) mul(left: Expr, right: Expr) } func eval(e: Expr) -> int { match e { .literal(lit) { return lit.value } .add(a) { return eval(a.left) + eval(a.right) } .mul(m) { return eval(m.left) * eval(m.right) } } return 0 } func go() -> int { let tree = Expr.add(Expr.literal(2), Expr.mul(Expr.literal(3), Expr.literal(4))) return eval(tree) } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_RefChoice_CompositeLiteralConstruction (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_RefChoice_CompositeLiteralConstruction topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Expr { literal(value: int) add(left: Expr, right: Expr) } func eval(e: Expr) -> int { match e { .literal(lit) { return lit.value } .add(a) { return eval(a.left) + eval(a.right) } } return 0 } func go() -> int { let sum = Expr_add { left: Expr_literal { value: 3 } right: Expr_literal { value: 4 } } return eval(sum) } ``` ## ILEmitterTests_Coverage_ControlFlow__For_AccumulatesIntoData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_AccumulatesIntoData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Acc { var total: int } func go() -> int { var a = Acc { total: 0 } for i in 0..10 { a.total += i } return a.total } ``` ## ILEmitterTests_Coverage_ControlFlow__While_BuildsString (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::While_BuildsString topic: core status: verified // verified behavior: Test.go(...) == "aaa" namespace Test func go() -> string { var s = "" var n = 3 while n > 0 { s = s + "a" n -= 1 } return s } ``` ## ILEmitterTests_Coverage_ControlFlow__For_OverString_CountsVowels (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_OverString_CountsVowels topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let s = "hello" var vowels = 0 for c in s { if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' { vowels += 1 } } return vowels } ``` ## ILEmitterTests_Coverage_ControlFlow__Match_OnLoopIndex_Categorizes (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Match_OnLoopIndex_Categorizes topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var evens = 0 for i in 0..8 { match i % 2 { 0 { evens += 1 } default { } } } return evens } ``` ## ILEmitterTests_Coverage_ControlFlow__Defer_RunsAfterLoopBody (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Defer_RunsAfterLoopBody topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { var n: int } func go() -> int { var b: *Box = new Box { n: 0 } apply(b) return b.n } func apply(b: *Box) { defer { b.n *= 2 } for i in 1..5 { b.n += i } } ``` ## ILEmitterTests_Coverage_ControlFlow__Defer_NestedScopes (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Defer_NestedScopes topic: pointers status: verified // verified behavior: Test.go(...) == "inner-outer" namespace Test data Buf { var s: string } func go() -> string { var b: *Buf = new Buf { s: "" } outer(b) return b.s } func inner(b: *Buf) { defer { b.s = b.s + "inner-" } } func outer(b: *Buf) { defer { b.s = b.s + "outer" } inner(b) } ``` ## ILEmitterTests_Coverage_ControlFlow__NullCoalescing_ChainPicksFirstNonNull (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::NullCoalescing_ChainPicksFirstNonNull topic: core status: verified // verified behavior: Test.go(...) == "b" namespace Test func pick(a: string?, b: string?) -> string { return a ?? b ?? "fallback" } func go() -> string { return pick(nil, "b") } ``` ## ILEmitterTests_Coverage_ControlFlow__NullCoalescing_AllNilUsesFallback (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::NullCoalescing_AllNilUsesFallback topic: core status: verified // verified behavior: Test.go(...) == "fallback" namespace Test func pick(a: string?, b: string?) -> string { return a ?? b ?? "fallback" } func go() -> string { return pick(nil, nil) } ``` ## ILEmitterTests_Coverage_ControlFlow__NullConditional_OnPresentReadsMember (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::NullConditional_OnPresentReadsMember topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let s: string? = "hello" return s?.Length ?? 0 } ``` ## ILEmitterTests_Coverage_ControlFlow__While_FlagBasedExit (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::While_FlagBasedExit topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func firstSquareOver(limit: int) -> int { var i = 0 var done = false var answer = -1 while !done { if i * i > limit { answer = i done = true } i += 1 } return answer } func go() -> int { return firstSquareOver(10) } ``` ## ILEmitterTests_Coverage_ControlFlow__For_EarlyReturnFromLoop (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_EarlyReturnFromLoop topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func indexOf(xs: List, target: int) -> int { var i = 0 for x in xs { if x == target { return i } i += 1 } return -1 } func go() -> int { let xs = [10, 20, 30, 40] return indexOf(xs, 40) } ``` ## ILEmitterTests_Coverage_ControlFlow__For_NotFoundReturnsSentinel (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::For_NotFoundReturnsSentinel topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func indexOf(xs: List, target: int) -> int { var i = 0 for x in xs { if x == target { return i } i += 1 } return -1 } func go() -> int { let xs = [10, 20, 30] return indexOf(xs, 99) } ``` ## ILEmitterTests_Coverage_ControlFlow__Loop_AccumulateMaxValue (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Loop_AccumulateMaxValue topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [10, 40, 25, 5, 30] var best = xs[0] for x in xs { if x > best { best = x } } return best } ``` ## ILEmitterTests_Coverage_ControlFlow__Nested_LoopWithMatchClassifier (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Nested_LoopWithMatchClassifier topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func classify(n: int) -> int { return match n % 3 { 0 { 0 } 1 { 1 } default { 2 } } } func go() -> int { var twos = 0 for i in 0..9 { if classify(i) == 2 { twos += 1 } } return twos } ``` ## ILEmitterTests_Coverage_ControlFlow__If_ReturnsValueFromBothBranches (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::If_ReturnsValueFromBothBranches topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func pickLarger(a: int, b: int) -> int { if a > b { return a } else { return b } } func go() -> int { return pickLarger(100, 50) } ``` ## ILEmitterTests_Coverage_ControlFlow__Ternary_DrivesCompoundAssign (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Ternary_DrivesCompoundAssign topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var n = 4 n += n > 0 ? 4 : -4 return n } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_For_RangeSum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_For_RangeSum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var t = 0 for i in 0..5 { t += i } return t } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_For_RangeWithPointerWork (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_For_RangeWithPointerWork topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Acc { total: int } func go() -> int { var a = new Acc { total: 0 } for i in 1..4 { a.total += i } return a.total } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_NestedWhile_Product (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_NestedWhile_Product topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var t = 0 var i = 0 while i < 3 { var j = 0 while j < 4 { t += 1 j += 1 } i += 1 } return t } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_If_ElseIf_Chain (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_If_ElseIf_Chain topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func classify(n: int) -> int { if n < 0 { return 0 } else if n == 0 { return 1 } else { return 2 } } func go() -> int { return classify(7) } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_Match_OnChoice (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_Match_OnChoice topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Shape { circle(r: int), square(s: int) } func area(sh: Shape) -> int { match sh { .circle(r) { return r } .square(s) { return s } } return 0 } func go() -> int { return area(Shape.square(5)) } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_Match_PointerMutateInArm (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_Match_PointerMutateInArm topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } choice Sel { a, b } func go() -> int { let s = Sel.a() var box = new Box { n: 0 } match s { .a { box.n = 7 } .b { box.n = 9 } } return box.n } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_Defer_RunsInReverse (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_Defer_RunsInReverse topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Acc { var v: int } func work(a: *Acc) { defer { a.v += 2 } defer { a.v *= 6 } a.v = 1 } func go() -> int { // defers run LIFO after the function body: *6 then +2 → (1*6)+2 = 8. var a = new Acc { v: 0 } work(a) return a.v } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_ForIn_OverPointerList_Count (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_ForIn_OverPointerList_Count topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } func go() -> int { let xs = [new Box { n: 1 }, new Box { n: 2 }, new Box { n: 3 }] var c = 0 for b in xs { c += 1 } return c } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_While_EarlyReturnViaPointer (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_While_EarlyReturnViaPointer topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Node { value: int, next: *Node } func go() -> int { var head: *Node = new Node { value: 1, next: new Node { value: 2, next: nil } } var cur = head while cur != nil { if cur.value == 2 { return cur.value } cur = cur.next } return -1 } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_Ternary_NestedPointer (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_Ternary_NestedPointer topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } func go() -> int { let pick = true let b = pick ? new Box { n: 2 } : new Box { n: 9 } return b.n } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_For_AccumulateString (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_For_AccumulateString topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { var s = "" for i in 0..3 { s = s + "a" } return s } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_Match_Default (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_Match_Default topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Sel { a, b, c } func pick(s: Sel) -> int { match s { .a { return 1 } default { return 99 } } return 0 } func go() -> int { return pick(Sel.c()) } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_If_PointerNilGuard (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_If_PointerNilGuard topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Node { value: int, next: *Node } func go() -> int { var head: *Node = nil if head == nil { return 0 } return head.value } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_CompoundAssign_AllOps (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_CompoundAssign_AllOps topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var n = 10 n += 4 n -= 2 n *= 1 n /= 1 return n - 5 } ``` ## ILEmitterTests_Coverage_ControlFlow__Added_While_DecrementToZero (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_ControlFlow.cs::Added_While_DecrementToZero topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var n = 5 while n > 0 { n -= 1 } return n } ``` ## ILEmitterTests_StaticFunc__StaticFunc_BasicDeclaration_Parses (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_BasicDeclaration_Parses topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Foo { func go() -> int { return 1 } } ``` ## ILEmitterTests_StaticFunc__StaticFunc_With_Only_Functions (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_With_Only_Functions topic: static-func status: verified // verified behavior: Test.go(...) == 3 namespace Test static func Util { func one() -> int { return 1 } func two() -> int { return 2 } } func go() -> int { return Util.one() + Util.two() } ``` ## ILEmitterTests_StaticFunc__StaticFunc_With_Only_Constants (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_With_Only_Constants topic: static-func status: verified // verified behavior: Test.span(...) == 105 namespace Test static func Limits { let MAX: int = 100 let MIN: int = -5 } func span() -> int { return Limits.MAX - Limits.MIN } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Mixed_Fields_And_Methods (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Mixed_Fields_And_Methods topic: static-func status: verified // verified behavior: Test.combined(...) == 43 namespace Test static func Math2 { let PI: int = 3 func double(x: int) -> int { return x * 2 } func triple(x: int) -> int { return x * 3 } } func combined() -> int { return Math2.double(5) + Math2.triple(10) + Math2.PI } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Emits_TopLevel_Static_Class_Shape (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Emits_TopLevel_Static_Class_Shape topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Holder { let X: int = 7 func make() -> int { return X } } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Type_Is_TopLevel_Not_Nested_In_Module_Class (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Type_Is_TopLevel_Not_Nested_In_Module_Class topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Sibling { func go() -> int { return 1 } } func host() -> int { return Sibling.go() } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Literal_Field_Emits_Const (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Literal_Field_Emits_Const topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Holder { let X: int = 7 } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Var_Field_Emits_Mutable_Static (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Var_Field_Emits_Mutable_Static topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Counter { var n: int = 0 } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Let_NonLiteral_Field_Emits_Readonly_Static (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Let_NonLiteral_Field_Emits_Readonly_Static topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Holder { let s: string = "hi" } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Methods_Are_Static (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Methods_Are_Static topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func Util { func go() -> int { return 42 } } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Pub_Emits_Public_Class (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Pub_Emits_Public_Class topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub static func PubSf { func go() -> int { return 1 } } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Default_Emits_Internal_Class (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Default_Emits_Internal_Class topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func PrivSf { func go() -> int { return 2 } } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Method_Call_From_TopLevel (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Method_Call_From_TopLevel topic: static-func status: verified // verified behavior: Test.main(...) == true namespace Test static func Password { func is_strong(s: string) -> bool { return s.Length > 8 } } func main() -> bool { return Password.is_strong("hunter2hunter2") } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Method_Call_From_Another_StaticFunc (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Method_Call_From_Another_StaticFunc topic: static-func status: verified // verified behavior: Test.go(...) == 11 namespace Test static func A { func produce() -> int { return 10 } } static func B { func consume() -> int { return A.produce() + 1 } } func go() -> int { return B.consume() } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Const_Field_Loaded_Inline_In_IL (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Const_Field_Loaded_Inline_In_IL topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func K { let V: int = 42 } func read() -> int { return K.V } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Method_With_Multiple_Parameters (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Method_With_Multiple_Parameters topic: static-func status: verified // verified behavior: Test.go(...) == 12 namespace Test static func Calc { func add(a: int, b: int) -> int { return a + b } func sub(a: int, b: int) -> int { return a - b } } func go() -> int { return Calc.add(3, 4) + Calc.sub(10, 5) } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Method_Calls_BCL (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Method_Calls_BCL topic: static-func status: verified // verified behavior: Test.go(...) == "" namespace Test static func Str { func tag(s: string) -> string { return "<" + s + ">" } } func go() -> string { return Str.tag("ok") } ``` ## ILEmitterTests_StaticFunc__StaticFunc_References_User_Data_Type (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_References_User_Data_Type topic: static-func status: verified // verified behavior: Test.sum(...) == 0 namespace Test data Point { x: int y: int } static func Geom { func origin() -> Point { return Point { x: 0, y: 0 } } } func sum() -> int { let p = Geom.origin() return p.x + p.y } ``` ## ILEmitterTests_StaticFunc__StaticFunc_Bool_Const (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_Bool_Const topic: static-func status: verified // verified behavior: Test.check(...) == true namespace Test static func Flags { let DEBUG: bool = true } func check() -> bool { return Flags.DEBUG } ``` ## ILEmitterTests_StaticFunc__StaticFunc_String_Const (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_String_Const topic: static-func status: verified // verified behavior: Test.get_name(...) == "Esharp" namespace Test static func App { let NAME: string = "Esharp" } func get_name() -> string { return App.NAME } ``` ## ILEmitterTests_StaticFunc__StaticFunc_RejectsTopLevelStatements (static-func, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_RejectsTopLevelStatements topic: static-func status: unverified // verified behavior: reports diagnostic ES1010 namespace Test static func Bad { let X: int = 1 if true { let y = 2 } } ``` ## ILEmitterTests_StaticFunc__StaticFunc_RejectsBareReturn (static-func, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::StaticFunc_RejectsBareReturn topic: static-func status: unverified // verified behavior: reports diagnostic ES1010 namespace Test static func Bad { return 1 } ``` ## ILEmitterTests_StaticFunc__Static_Is_Still_Valid_Identifier_Elsewhere (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::Static_Is_Still_Valid_Identifier_Elsewhere topic: static-func status: verified // verified behavior: Test.go(...) == 11 namespace Test func go(static: int) -> int { return static + 1 } ``` ## ILEmitterTests_StaticFunc__Static_Func_Const_Inlined_As_Literal_At_Use_Site (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::Static_Func_Const_Inlined_As_Literal_At_Use_Site topic: static-func status: verified // verified behavior: Test.test(...) == 99 namespace Test static func Config { let MAX: int = 99 } func test() -> int = Config.MAX ``` ## ILEmitterTests_StaticFunc__Static_Func_Method_Called_Across_Two_Static_Funcs (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::Static_Func_Method_Called_Across_Two_Static_Funcs topic: static-func status: verified // verified behavior: Test.test(...) == 21 namespace Test static func A { func twice(n: int) -> int = n * 2 } static func B { func via_a(n: int) -> int = A.twice(n) + 1 } func test() -> int = B.via_a(10) ``` ## ILEmitterTests_StaticFunc__Static_Func_Two_Methods_Independent_State (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::Static_Func_Two_Methods_Independent_State topic: static-func status: verified // verified behavior: Test.test(...) == 6 namespace Test static func Counter { var n: int = 0 func bump() -> int { n = n + 1 return n } } func test() -> int { let a = Counter.bump() let b = Counter.bump() let c = Counter.bump() return a + b + c } ``` ## ILEmitterTests_StaticFunc__DottedNamespace_StaticFunc_EmitsIntoFullNamespace (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::DottedNamespace_StaticFunc_EmitsIntoFullNamespace topic: static-func status: verified // verified behavior: Test.null(...) == 7 namespace Keystone.Routing.Demo static func RoutePattern { func answer() -> int { return 7 } } ``` ## ILEmitterTests_StaticFunc__DottedNamespace_Data_EmitsIntoFullNamespace (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::DottedNamespace_Data_EmitsIntoFullNamespace topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Keystone.Routing.Demo pub data Point { x: int, y: int } ``` ## ILEmitterTests_StaticFunc__DottedNamespace_FreeFunction_HostsOnLastSegmentModuleClass (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_StaticFunc.cs::DottedNamespace_FreeFunction_HostsOnLastSegmentModuleClass topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Keystone.Routing.Demo func add(a: int, b: int) -> int { return a + b } ``` ## ILEmitterTests_Interop__JsonDocument_Parse_RootElement_ValueKind_Stepped (interop, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::JsonDocument_Parse_RootElement_ValueKind_Stepped topic: interop status: unverified // verified behavior: Test.run(...) == "object" namespace Test using "System.Text.Json" func run() -> string { let doc = JsonDocument.Parse("{}") let elem = doc.RootElement let kind = elem.ValueKind let isObj = kind == JsonValueKind.Object return isObj ? "object" : "other" } ``` ## ILEmitterTests_Interop__JsonDocument_ChainedMemberAccess (interop, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::JsonDocument_ChainedMemberAccess topic: interop status: unverified // verified behavior: Test.run(...) == "object" namespace Test using "System.Text.Json" func run() -> string { let doc = JsonDocument.Parse("{}") return doc.RootElement.ValueKind == JsonValueKind.Object ? "object" : "other" } ``` ## ILEmitterTests_Interop__JsonSerializer_Serialize (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::JsonSerializer_Serialize topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Text.Json" func run() -> string { return JsonSerializer.Serialize("hello") } ``` ## ILEmitterTests_Interop__ImportStatic_MathMax (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::ImportStatic_MathMax topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using static "System.Math" func run() -> double { return Max(2.5, 4.5) } ``` ## ILEmitterTests_Interop__ArrowLambda_InfersParameterType (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::ArrowLambda_InfersParameterType topic: interop status: verified // verified behavior: Test.run(...) == 7 namespace Test func apply(x: int, f: Func) -> int { return f(x) } func run() -> int { return apply(5, (x) => x + 2) } ``` ## ILEmitterTests_Interop__ArrowLambda_ZeroArgMultiArgCaptures (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::ArrowLambda_ZeroArgMultiArgCaptures topic: interop status: verified // verified behavior: Test.run(...) == 19 namespace Test func compute(f: Func) -> int { return f() } func combine(f: Func) -> int { return f(3, 4) } func run() -> int { let offset = 5 let left = compute(() => 7) let right = combine((x, y) => x + y + offset) return left + right } ``` ## ILEmitterTests_Interop__ArrowLambda_TypedParameter (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::ArrowLambda_TypedParameter topic: interop status: verified // verified behavior: Test.run(...) == "ok" namespace Test func applyText(f: Func) -> string { return f("ok") } func run() -> string { return applyText((value: string) => value) } ``` ## ILEmitterTests_Interop__EnumLiteral_JsonValueKind_EmitsConstant (interop, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::EnumLiteral_JsonValueKind_EmitsConstant topic: interop status: unverified // verified behavior: Test.run(...) == 1 namespace Test using "System.Text.Json" func run() -> int { let kind = JsonValueKind.Object return kind == JsonValueKind.Object ? 1 : 0 } ``` ## ILEmitterTests_Interop__OptionalStructParam_DefaultInitialized (interop, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::OptionalStructParam_DefaultInitialized topic: interop status: unverified // verified behavior: Test.run(...) == "ok" namespace Test using "System.Text.Json" func run() -> string { let doc = JsonDocument.Parse("{}") return "ok" } ``` ## ILEmitterTests_Interop__ForIn_ListOfInt_SumsElements (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::ForIn_ListOfInt_SumsElements topic: interop status: verified // verified behavior: Test.run(...) == 60 namespace Test func run() -> int { let xs = [10, 20, 30] var total = 0 for x in xs { total += x } return total } ``` ## ILEmitterTests_Interop__ForIn_JsonEnumerateArray_GetProperty (interop, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::ForIn_JsonEnumerateArray_GetProperty topic: interop status: unverified // verified behavior: Test.run(...) == "6" namespace Test using "System.Text.Json" func run() -> string { let doc = JsonDocument.Parse("[1, 2, 3]") let root = doc.RootElement var total = 0 for el in root.EnumerateArray() { total += el.GetInt32() } return total.ToString() } ``` ## ILEmitterTests_Interop__ChainedMember_JsonElement_GetArrayLength (interop, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interop.cs::ChainedMember_JsonElement_GetArrayLength topic: interop status: unverified // verified behavior: Test.run(...) == 3 namespace Test using "System.Text.Json" func run() -> int { let doc = JsonDocument.Parse("[10, 20, 30]") return doc.RootElement.GetArrayLength() } ``` ## ILEmitterTests_Events__Event_Declared_EmitsCanonicalClrShape (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_Declared_EmitsCanonicalClrShape topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test delegate func Notify(value: int) pub ref data Server { pub event OnReady: Notify } ``` ## ILEmitterTests_Events__Event_Raise_InvokesSubscribers (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_Raise_InvokesSubscribers topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub ref data Counter { var total: int pub event OnChanged: Action pub func add(n: int) { self.total = self.total + n raise OnChanged(self.total) } } ``` ## ILEmitterTests_Events__Event_Raise_NoSubscribers_DoesNotThrow (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_Raise_NoSubscribers_DoesNotThrow topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub ref data Bell { pub event OnRing: Action pub func ring() { raise OnRing() } } ``` ## ILEmitterTests_Events__Event_Unsubscribe_StopsDelivery (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_Unsubscribe_StopsDelivery topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub ref data Hub { pub event OnPing: Action pub func ping(v: int) { raise OnPing(v) } } ``` ## ILEmitterTests_Events__Event_Interface_EmitsAbstractAccessorsAndEventDef (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_Interface_EmitsAbstractAccessorsAndEventDef topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub interface IRuntime { event OnReady: Action } ``` ## ILEmitterTests_Events__Event_EsharpSideSubscription_AddAndRemove (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_EsharpSideSubscription_AddAndRemove topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub ref data Counter { var total: int pub event OnChanged: Action pub func wire(h: Action) { self.OnChanged += h } pub func unwire(h: Action) { self.OnChanged -= h } pub func add(n: int) { self.total = self.total + n raise OnChanged(self.total) } } ``` ## ILEmitterTests_Events__Event_OnValueData_IsRejected (delegates-events, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_OnValueData_IsRejected topic: delegates-events status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test data Bad { event OnX: Action } ``` ## ILEmitterTests_Events__Event_NonDelegateType_IsRejected (delegates-events, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_NonDelegateType_IsRejected topic: delegates-events status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Bad { event OnX: int } ``` ## ILEmitterTests_Events__Event_MultipleEvents_AreIndependent (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_MultipleEvents_AreIndependent topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub ref data Bus { pub event OnA: Action pub event OnB: Action pub func fireA(v: int) { raise OnA(v) } pub func fireB(v: int) { raise OnB(v) } } ``` ## ILEmitterTests_Events__Event_TypedByEventHandlerGeneric_EmitsCorrectShape (delegates-events, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Events.cs::Event_TypedByEventHandlerGeneric_EmitsCorrectShape topic: delegates-events status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub ref data Widget { pub event OnResize: EventHandler } ``` ## ILEmitterTests_Returns__Returns_Keyword_Synonym_For_Arrow_TopLevel (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Keyword_Synonym_For_Arrow_TopLevel topic: core status: verified // verified behavior: Test.go(...) == 5 namespace Test func add(a: int, b: int) returns int { return a + b } func go() returns int { return add(2, 3) } ``` ## ILEmitterTests_Returns__Returns_Keyword_Synonym_With_String_Return (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Keyword_Synonym_With_String_Return topic: core status: verified // verified behavior: Test.greet(...) == "hi world" namespace Test func greet(name: string) returns string { return "hi " + name } ``` ## ILEmitterTests_Returns__Returns_Keyword_Synonym_With_Nullable_Return (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Keyword_Synonym_With_Nullable_Return topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func maybe() returns int? { return nil } ``` ## ILEmitterTests_Returns__Returns_Keyword_Synonym_On_Inline_Method (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Keyword_Synonym_On_Inline_Method topic: data status: verified // verified behavior: Test.go(...) == 10 namespace Test ref data Box { n: int init(n: int) { self.n = n } func twice() returns int { return self.n * 2 } } func go() -> int { return Box(5).twice() } ``` ## ILEmitterTests_Returns__Returns_Keyword_Mixed_With_Arrow_In_Same_File (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Keyword_Mixed_With_Arrow_In_Same_File topic: core status: verified // verified behavior: Test.sum(...) == 3 namespace Test func a() -> int { return 1 } func b() returns int { return 2 } func sum() returns int { return a() + b() } ``` ## ILEmitterTests_Returns__Returns_Clause_On_StaticFunc_Sets_Default_Return_Type (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_StaticFunc_Sets_Default_Return_Type topic: static-func status: verified // verified behavior: Test.main(...) == 5 namespace Test static func IntBag { returns int func two() { return 2 } func three() { return 3 } func sum() { return two() + three() } } func main() -> int { return IntBag.sum() } ``` ## ILEmitterTests_Returns__Returns_Clause_On_StaticFunc_All_Methods_Without_Arrow_Get_Type (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_StaticFunc_All_Methods_Without_Arrow_Get_Type topic: static-func status: verified // verified behavior: Test.go(...) == "ab" namespace Test static func Strs { returns string func a() { return "a" } func b() { return "b" } } func go() -> string { return Strs.a() + Strs.b() } ``` ## ILEmitterTests_Returns__Returns_Clause_On_StaticFunc_Explicit_Arrow_Wins (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_StaticFunc_Explicit_Arrow_Wins topic: static-func status: verified // verified behavior: Test.combine(...) == "hello" namespace Test static func S { returns int func num() { return 5 } func tag() -> string { return "hello" } } func combine() -> string { return S.tag() } ``` ## ILEmitterTests_Returns__Returns_Clause_On_StaticFunc_Bound_Method_Has_Correct_ReturnType (static-func, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_StaticFunc_Bound_Method_Has_Correct_ReturnType topic: static-func status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test static func S { returns int func go() { return 99 } } ``` ## ILEmitterTests_Returns__Returns_Clause_On_StaticFunc_Internal_Cross_Method_Call_Sees_Type (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_StaticFunc_Internal_Cross_Method_Call_Sees_Type topic: static-func status: verified // verified behavior: Test.go(...) == 5 namespace Test static func IntBag { returns int func two() { return 2 } func three() { return 3 } func sum() { return two() + three() } } func go() -> int { return IntBag.sum() } ``` ## ILEmitterTests_Returns__Returns_Clause_On_RefData_Sets_Default_For_Methods (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_RefData_Sets_Default_For_Methods topic: data status: verified // verified behavior: Test.go(...) == 1 namespace Test ref data Q { returns Q n: int init(n: int) { self.n = n } func bump() { return Q(self.n + 1) } } func go() -> int { let q = Q(0) let r = q.bump() return r.n } ``` ## ILEmitterTests_Returns__Returns_Clause_On_RefData_Fluent_Chaining (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_RefData_Fluent_Chaining topic: data status: verified // verified behavior: Test.go(...) == 3 namespace Test ref data Q { returns Q n: int init(n: int) { self.n = n } func bump() { return Q(self.n + 1) } } func go() -> int { let q = Q(0) let r = q.bump().bump().bump() return r.n } ``` ## ILEmitterTests_Returns__Returns_Clause_On_RefData_Explicit_Arrow_Wins (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_RefData_Explicit_Arrow_Wins topic: data status: verified // verified behavior: Test.go(...) == 1 namespace Test ref data Q { returns Q n: int init(n: int) { self.n = n } func bump() { return Q(self.n + 1) } func count() -> int { return self.n } } func go() -> int { let q = Q(0) return q.bump().count() } ``` ## ILEmitterTests_Returns__Returns_Clause_On_RefData_Bound_Method_Has_Correct_ReturnType (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_On_RefData_Bound_Method_Has_Correct_ReturnType topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Q { returns Q n: int init(n: int) { self.n = n } func bump() { return Q(self.n + 1) } } ``` ## ILEmitterTests_Returns__NoReturnsClause_NoArrow_DefaultsToVoid (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::NoReturnsClause_NoArrow_DefaultsToVoid topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Q { n: int init(n: int) { self.n = n } func touch() { } // no -> Type, no returns clause: void } func go() { let q = Q(0) q.touch() } ``` ## ILEmitterTests_Returns__NoReturnsClause_OnlyExplicitArrowsTakeEffect (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::NoReturnsClause_OnlyExplicitArrowsTakeEffect topic: static-func status: verified // verified behavior: Test.go(...) == 1 namespace Test static func S { func a() { } // void func b() -> int { return 1 } } func go() -> int { S.a() return S.b() } ``` ## ILEmitterTests_Returns__Returns_Clause_With_Primitive_Type (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_With_Primitive_Type topic: static-func status: verified // verified behavior: Test.go(...) == false namespace Test static func B { returns bool func t() { return true } func f() { return false } func both() { return t() and f() } } func go() -> bool { return B.both() } ``` ## ILEmitterTests_Returns__Returns_Clause_With_String_Type (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_With_String_Type topic: static-func status: verified // verified behavior: Test.go(...) == "hi" namespace Test static func S { returns string func hi() { return "hi" } } func go() -> string { return S.hi() } ``` ## ILEmitterTests_Returns__Returns_Clause_With_User_Data_Type (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_With_User_Data_Type topic: static-func status: verified // verified behavior: Test.sum(...) == 2 namespace Test data Point { x: int y: int } static func PointBag { returns Point func origin() { return Point { x: 0, y: 0 } } func one() { return Point { x: 1, y: 1 } } } func sum() -> int { let p = PointBag.one() return p.x + p.y } ``` ## ILEmitterTests_Returns__Returns_Clause_Sees_Cross_Method_Resolution_With_DataType (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_Sees_Cross_Method_Resolution_With_DataType topic: data status: verified // verified behavior: Test.go(...) == 2 namespace Test ref data Counter { returns Counter n: int init(n: int) { self.n = n } func inc() { return Counter(self.n + 1) } func twice() { return self.inc().inc() } } func go() -> int { return Counter(0).twice().n } ``` ## ILEmitterTests_Returns__Returns_Is_Still_Valid_Identifier_Elsewhere (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Is_Still_Valid_Identifier_Elsewhere topic: core status: verified // verified behavior: Test.go(...) == 11 namespace Test func go(returns: int) -> int { return returns + 1 } ``` ## ILEmitterTests_Returns__Returns_Synonym_Of_Arrow_Type (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Synonym_Of_Arrow_Type topic: core status: verified // verified behavior: Test.test(...) == 42 namespace Test func test() returns int = 42 ``` ## ILEmitterTests_Returns__Returns_Clause_With_Two_Methods_Both_Inherit (static-func, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Returns.cs::Returns_Clause_With_Two_Methods_Both_Inherit topic: static-func status: verified // verified behavior: Test.test(...) == 25 namespace Test static func Calc { returns int func double_it(n: int) = n * 2 func triple_it(n: int) = n * 3 } func test() -> int = Calc.double_it(5) + Calc.triple_it(5) ``` ## ILEmitterTests_New__New_Composite_ReadsFirstField (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_ReadsFirstField topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test data Point { x: int, y: int } func go() -> int { let p = new Point { x: 3, y: 4 } return p.x } ``` ## ILEmitterTests_New__New_Composite_ReadsSecondField (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_ReadsSecondField topic: allocation status: verified // verified behavior: Test.go(...) == 4 namespace Test data Point { x: int, y: int } func go() -> int { let p = new Point { x: 3, y: 4 } return p.y } ``` ## ILEmitterTests_New__New_Composite_SumsFields (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_SumsFields topic: allocation status: verified // verified behavior: Test.go(...) == 7 namespace Test data Point { x: int, y: int } func go() -> int { let p = new Point { x: 3, y: 4 } return p.x + p.y } ``` ## ILEmitterTests_New__New_Composite_MutatesThroughPointer (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_MutatesThroughPointer topic: allocation status: verified // verified behavior: Test.go(...) == 6 namespace Test data Counter { value: int } func go() -> int { var c = new Counter { value: 1 } c.value += 5 return c.value } ``` ## ILEmitterTests_New__New_Composite_NewlineSeparatedFields (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_NewlineSeparatedFields topic: allocation status: verified // verified behavior: Test.go(...) == 30 namespace Test data Point { x: int, y: int } func go() -> int { let p = new Point { x: 10 y: 20 } return p.x + p.y } ``` ## ILEmitterTests_New__New_Composite_StringField (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_StringField topic: allocation status: verified // verified behavior: Test.go(...) == "hi" namespace Test data Label { text: string } func go() -> string { let l = new Label { text: "hi" } return l.text } ``` ## ILEmitterTests_New__New_Composite_BoolField (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_BoolField topic: allocation status: verified // verified behavior: Test.go(...) == true namespace Test data Flag { on: bool } func go() -> bool { let f = new Flag { on: true } return f.on } ``` ## ILEmitterTests_New__New_Composite_DoubleField (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Composite_DoubleField topic: allocation status: verified // verified behavior: Test.go(...) == 2.5 namespace Test data Num { v: double } func go() -> double { let n = new Num { v: 2.5 } return n.v } ``` ## ILEmitterTests_New__New_Var_Reassign (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Var_Reassign topic: allocation status: verified // verified behavior: Test.go(...) == 2 namespace Test data Box { n: int } func go() -> int { var b = new Box { n: 1 } b = new Box { n: 2 } return b.n } ``` ## ILEmitterTests_New__New_ExplicitPointerAnnotation (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_ExplicitPointerAnnotation topic: allocation status: verified // verified behavior: Test.go(...) == 9 namespace Test data Box { n: int } func go() -> int { var b: *Box = new Box { n: 9 } return b.n } ``` ## ILEmitterTests_New__New_TwoInstances_IndependentIdentity (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_TwoInstances_IndependentIdentity topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test data Box { n: int } func go() -> int { var a = new Box { n: 1 } var b = new Box { n: 2 } a.n += 0 return a.n + b.n } ``` ## ILEmitterTests_New__New_NotNil (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_NotNil topic: allocation status: verified // verified behavior: Test.go(...) == true namespace Test data Box { n: int } func go() -> bool { let b = new Box { n: 1 } return b != nil } ``` ## ILEmitterTests_New__New_Positional_TwoArgs (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Positional_TwoArgs topic: allocation status: verified // verified behavior: Test.go(...) == 7 namespace Test data Vec2(x: int, y: int) func go() -> int { let v = new Vec2(3, 4) return v.x + v.y } ``` ## ILEmitterTests_New__New_Positional_OneArg (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Positional_OneArg topic: allocation status: verified // verified behavior: Test.go(...) == 42 namespace Test data Wrap(v: int) func go() -> int { let w = new Wrap(42) return w.v } ``` ## ILEmitterTests_New__New_Positional_ExprArgs (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Positional_ExprArgs topic: allocation status: verified // verified behavior: Test.go(...) == 13 namespace Test data Vec2(x: int, y: int) func go() -> int { let a = 5 let v = new Vec2(a + 1, a + 2) return v.x + v.y } ``` ## ILEmitterTests_New__New_Positional_Mutation (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Positional_Mutation topic: allocation status: verified // verified behavior: Test.go(...) == 15 namespace Test data Vec2(x: int, y: int) func go() -> int { var v = new Vec2(3, 4) v.x = 11 return v.x + v.y } ``` ## ILEmitterTests_New__New_Positional_AndComposite_SameType (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Positional_AndComposite_SameType topic: allocation status: verified // verified behavior: Test.go(...) == 20 namespace Test data Vec2(x: int, y: int) func go() -> int { let a = new Vec2(3, 4) let b = new Vec2 { x: 6, y: 7 } return a.x + a.y + b.x + b.y } ``` ## ILEmitterTests_New__New_Generic_Pair_First (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Generic_Pair_First topic: allocation status: verified // verified behavior: Test.go(...) == 42 namespace Test data Pair { first: A, second: B } func go() -> int { let p = new Pair { first: 42, second: "x" } return p.first } ``` ## ILEmitterTests_New__New_Generic_Pair_Second (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Generic_Pair_Second topic: allocation status: verified // verified behavior: Test.go(...) == "hello" namespace Test data Pair { first: A, second: B } func go() -> string { let p = new Pair { first: 1, second: "hello" } return p.second } ``` ## ILEmitterTests_New__New_Generic_SameTypeArgs (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_Generic_SameTypeArgs topic: allocation status: verified // verified behavior: Test.go(...) == 5 namespace Test data Pair { first: A, second: B } func go() -> int { let p = new Pair { first: 2, second: 3 } return p.first + p.second } ``` ## ILEmitterTests_New__New_LinkedList_SumsThree (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_LinkedList_SumsThree topic: allocation status: verified // verified behavior: Test.go(...) == 6 namespace Test data Node { value: int, next: *Node } func go() -> int { var n3: *Node = new Node { value: 3, next: nil } var n2: *Node = new Node { value: 2, next: n3 } var n1: *Node = new Node { value: 1, next: n2 } var total = 0 var cur = n1 while cur != nil { total += cur.value cur = cur.next } return total } ``` ## ILEmitterTests_New__New_LinkedList_PrependReturnsPointer (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_LinkedList_PrependReturnsPointer topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test data Node { value: int, next: *Node } func prepend(head: *Node, value: int) -> *Node { return new Node { value: value, next: head } } func go() -> int { var head: *Node = nil head = prepend(head, 10) head = prepend(head, 20) head = prepend(head, 30) var count = 0 var cur = head while cur != nil { count += 1 cur = cur.next } return count } ``` ## ILEmitterTests_New__New_LinkedList_NilTailTerminates (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_LinkedList_NilTailTerminates topic: allocation status: verified // verified behavior: Test.go(...) == 10 namespace Test data Node { value: int, next: *Node } func go() -> int { let only = new Node { value: 10, next: nil } return only.value } ``` ## ILEmitterTests_New__New_BuildListInLoop (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_BuildListInLoop topic: allocation status: verified // verified behavior: Test.go(...) == 10 namespace Test data Node { value: int, next: *Node } func go() -> int { var head: *Node = nil var i = 1 while i <= 4 { head = new Node { value: i, next: head } i += 1 } var sum = 0 var cur = head while cur != nil { sum += cur.value cur = cur.next } return sum } ``` ## ILEmitterTests_New__New_AsExpressionBodiedReturn (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_AsExpressionBodiedReturn topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test data Point { x: int, y: int } func make() -> *Point = new Point { x: 1, y: 2 } func go() -> int { let p = make() return p.x + p.y } ``` ## ILEmitterTests_New__New_AsFunctionArgument (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_AsFunctionArgument topic: allocation status: verified // verified behavior: Test.go(...) == 8 namespace Test data Box { n: int } func read(b: *Box) -> int = b.n func go() -> int { return read(new Box { n: 8 }) } ``` ## ILEmitterTests_New__New_NestedInFieldInitializer (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_NestedInFieldInitializer topic: allocation status: verified // verified behavior: Test.go(...) == 30 namespace Test data Inner { n: int } data Outer { inner: *Inner, label: string } func go() -> int { let o = new Outer { inner: new Inner { n: 30 }, label: "x" } return o.inner.n } ``` ## ILEmitterTests_New__New_InListLiteral_ThenIndex (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_InListLiteral_ThenIndex topic: allocation status: verified // verified behavior: Test.go(...) == 20 namespace Test data Box { n: int } func go() -> int { let xs = [new Box { n: 10 }, new Box { n: 20 }] return xs[1].n } ``` ## ILEmitterTests_New__New_InListLiteral_IndexThenMutate (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_InListLiteral_IndexThenMutate topic: allocation status: verified // verified behavior: Test.go(...) == 11 namespace Test data Box { n: int } func go() -> int { let xs = [new Box { n: 10 }, new Box { n: 20 }] xs[0].n += 1 return xs[0].n } ``` ## ILEmitterTests_New__New_InTernaryBranch (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_InTernaryBranch topic: allocation status: verified // verified behavior: Test.go(...) == 2 namespace Test data Box { n: int } func go() -> int { let cond = false let b = cond ? new Box { n: 1 } : new Box { n: 2 } return b.n } ``` ## ILEmitterTests_New__New_InIfBody (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_InIfBody topic: allocation status: verified // verified behavior: Test.go(...) == 5 namespace Test data Box { n: int } func go() -> int { var b = new Box { n: 0 } if true { b = new Box { n: 5 } } return b.n } ``` ## ILEmitterTests_New__New_InMatchArm (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_InMatchArm topic: allocation status: verified // verified behavior: Test.go(...) == 7 namespace Test data Box { n: int } choice Sel { a, b } func go() -> int { let s = Sel.a() var box = new Box { n: 0 } match s { .a { box = new Box { n: 7 } } .b { box = new Box { n: 9 } } } return box.n } ``` ## ILEmitterTests_New__New_AsConditionArgument (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_AsConditionArgument topic: allocation status: verified // verified behavior: Test.go(...) == true namespace Test data Box { n: int } func positive(b: *Box) -> bool = b.n > 0 func go() -> bool { if positive(new Box { n: 3 }) { return true } return false } ``` ## ILEmitterTests_New__New_CallsPointerReceiverMethod (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_CallsPointerReceiverMethod topic: allocation status: verified // verified behavior: Test.go(...) == 43 namespace Test data Counter { value: int } func bump(c: *Counter) { c.value += 1 } func go() -> int { var c = new Counter { value: 42 } bump(c) return c.value } ``` ## ILEmitterTests_New__New_PointerEmbedding_PromotedAccess (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_PointerEmbedding_PromotedAccess topic: allocation status: verified // verified behavior: Test.go(...) == 15 namespace Test data Vec2 { var x: int, var y: int } data Entity { *Vec2, name: string } func go() -> int { var e = new Entity { Vec2: new Vec2 { x: 10, y: 5 }, name: "p" } e.x += 0 return e.x + e.y } ``` ## ILEmitterTests_New__New_PointerSatisfiesInterface (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_PointerSatisfiesInterface topic: allocation status: verified // verified behavior: Test.go(...) == 42 namespace Test data Inner { var n: int } func bump(i: *Inner) { i.n += 1 } func value(i: Inner) -> int = i.n data Outer : IBumper { *Inner, label: string } interface IBumper { func bump(), func value() -> int } func twice(b: IBumper) -> int { b.bump() b.bump() return b.value() } func go() -> int { var o: *Outer = new Outer { Inner: new Inner { n: 40 }, label: "x" } return twice(o) } ``` ## ILEmitterTests_New__Ident_New_AsLocalVariable (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_AsLocalVariable topic: allocation status: verified // verified behavior: Test.go(...) == 5 namespace Test func go() -> int { let new = 5 return new } ``` ## ILEmitterTests_New__Ident_New_AsMutableVariable (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_AsMutableVariable topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test func go() -> int { var new = 1 new += 2 return new } ``` ## ILEmitterTests_New__Ident_New_AsFunctionName (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_AsFunctionName topic: allocation status: verified // verified behavior: Test.go(...) == 7 namespace Test func new() -> int = 7 func go() -> int { return new() } ``` ## ILEmitterTests_New__Ident_New_AsFunctionParameter (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_AsFunctionParameter topic: allocation status: verified // verified behavior: Test.go(...) == 8 namespace Test func inc(new: int) -> int = new + 1 func go() -> int { return inc(7) } ``` ## ILEmitterTests_New__Ident_New_AsFieldName (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_AsFieldName topic: allocation status: verified // verified behavior: Test.go(...) == 11 namespace Test data Holder { new: int } func go() -> int { let h = Holder { new: 11 } return h.new } ``` ## ILEmitterTests_New__Ident_New_FollowedByComparison_NotTriggered (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_FollowedByComparison_NotTriggered topic: allocation status: verified // verified behavior: Test.go(...) == 1 namespace Test func go() -> int { let new = 5 return new < 10 ? 1 : 0 } ``` ## ILEmitterTests_New__Ident_New_LowercaseTypeNotTriggered (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_LowercaseTypeNotTriggered topic: allocation status: verified // verified behavior: Test.go(...) == 4 namespace Test func go() -> int { var new = 1 let other = 3 return new + other } ``` ## ILEmitterTests_New__Neg_NewRefData_IsES2003 (allocation, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Neg_NewRefData_IsES2003 topic: allocation status: verified // verified behavior: reports diagnostic ES2003 namespace Test ref data R { x: int init(x: int) { self.x = x } } func go() -> int { let r = new R { x: 1 } return r.x } ``` ## ILEmitterTests_New__Neg_NewExternalGeneric_IsES2144 (allocation, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Neg_NewExternalGeneric_IsES2144 topic: allocation status: verified // verified behavior: reports diagnostic ES2144 namespace Test func go() -> int { let xs = new List() return 0 } ``` ## ILEmitterTests_New__Neg_NewExternalType_IsES2144 (allocation, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Neg_NewExternalType_IsES2144 topic: allocation status: verified // verified behavior: reports diagnostic ES2144 namespace Test func go() -> int { let s = new StringBuilder { } return 0 } ``` ## ILEmitterTests_New__Deprecated_Amp_IsNotAnError (allocation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Deprecated_Amp_IsNotAnError topic: allocation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Box { n: int } func go() -> int { let b = &Box { n: 7 } return b.n } ``` ## ILEmitterTests_New__New_EmitsNoDeprecationWarning (allocation, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_EmitsNoDeprecationWarning topic: allocation status: unverified // verified behavior: reports diagnostic ES2143 namespace Test data Box { n: int } func go() -> int { let b = new Box { n: 7 } return b.n } ``` ## ILEmitterTests_New__Equivalence_NewAndAmp_SameResult (allocation, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Equivalence_NewAndAmp_SameResult topic: allocation status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test data Node { value: int, next: *Node } func go() -> int { var n2: *Node = SPELL Node { value: 2, next: nil } var n1: *Node = SPELL Node { value: 1, next: n2 } return n1.value + n1.next.value } ``` ## ILEmitterTests_New__IL_NewAndAmp_EmitIdenticalBody (allocation, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::IL_NewAndAmp_EmitIdenticalBody topic: allocation status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test data Node { value: int, next: *Node } func go() -> int { let n = SPELL Node { value: 7, next: nil } return n.value } ``` ## ILEmitterTests_New__IL_New_EmitsHeapAllocation (allocation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::IL_New_EmitsHeapAllocation topic: allocation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Node { value: int, next: *Node } func go() -> int { let n = new Node { value: 7, next: nil } return n.value } ``` ## ILEmitterTests_New__IL_New_LocalIsHeapPointerWrapper (allocation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::IL_New_LocalIsHeapPointerWrapper topic: allocation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Node { value: int, next: *Node } func go() -> int { var n: *Node = new Node { value: 7, next: nil } return n.value } ``` ## ILEmitterTests_New__New_ChainedListBuild_LengthFive (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_ChainedListBuild_LengthFive topic: allocation status: verified // verified behavior: Test.go(...) == 5 namespace Test data Node { value: int, next: *Node } func go() -> int { var head: *Node = nil var i = 0 while i < 5 { head = new Node { value: i, next: head } i += 1 } var c = 0 var cur = head while cur != nil { c += 1 cur = cur.next } return c } ``` ## ILEmitterTests_New__New_ReturnedFromBranch (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_ReturnedFromBranch topic: allocation status: verified // verified behavior: Test.go(...) == 9 namespace Test data Box { n: int } func make(big: bool) -> *Box { if big { return new Box { n: 9 } } return new Box { n: 1 } } func go() -> int { let b = make(true) return b.n } ``` ## ILEmitterTests_New__New_PassedToGenericFunction (allocation, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_PassedToGenericFunction topic: allocation status: unverified // verified behavior: Test.go(...) == 13 namespace Test data Box { n: int } func identity(v: T) -> T = v func go() -> int { let b = identity(new Box { n: 13 }) return b.n } ``` ## ILEmitterTests_New__New_NestedThreeLevels (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_NestedThreeLevels topic: allocation status: verified // verified behavior: Test.go(...) == 7 namespace Test data A { n: int } data B { a: *A } data C { b: *B } func go() -> int { let c = new C { b: new B { a: new A { n: 7 } } } return c.b.a.n } ``` ## ILEmitterTests_New__New_InWhileConditionArgument (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_InWhileConditionArgument topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test data Box { n: int } func alive(b: *Box) -> bool = b.n > 0 func go() -> int { var count = 0 var n = 3 while alive(new Box { n: n }) { count += 1 n -= 1 } return count } ``` ## ILEmitterTests_New__New_AssignedToFieldThenRead (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_AssignedToFieldThenRead topic: allocation status: verified // verified behavior: Test.go(...) == 42 namespace Test data Inner { v: int } data Holder { var p: *Inner } func go() -> int { var h = Holder { p: nil } h.p = new Inner { v: 42 } return h.p.v } ``` ## ILEmitterTests_New__New_PositionalGenericExternal_IsError_List (allocation, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_PositionalGenericExternal_IsError_List topic: allocation status: verified // verified behavior: reports diagnostic ES2144 namespace Test func go() -> int { let d = new Dictionary() return 0 } ``` ## ILEmitterTests_New__New_ReadonlyData (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_ReadonlyData topic: allocation status: verified // verified behavior: Test.go(...) == 5 namespace Test readonly data Point { x: int, y: int } func go() -> int { let p = new Point { x: 2, y: 3 } return p.x + p.y } ``` ## ILEmitterTests_New__New_DataWithDefaultField (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_DataWithDefaultField topic: allocation status: verified // verified behavior: Test.go(...) == 8 namespace Test data Box { n: int } func twice(b: *Box) -> int = b.n + b.n func go() -> int { return twice(new Box { n: 4 }) } ``` ## ILEmitterTests_New__New_GenericNestedTypeArg (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_GenericNestedTypeArg topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test data Pair { first: A, second: B } func go() -> int { let p = new Pair { first: 1, second: 2 } return p.first + p.second } ``` ## ILEmitterTests_New__New_MultipleInOneExpression (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_MultipleInOneExpression topic: allocation status: verified // verified behavior: Test.go(...) == 3 namespace Test data Box { n: int } func add(a: *Box, b: *Box) -> int = a.n + b.n func go() -> int { return add(new Box { n: 1 }, new Box { n: 2 }) } ``` ## ILEmitterTests_New__New_PointerComparedEqual (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_PointerComparedEqual topic: allocation status: verified // verified behavior: Test.go(...) == true namespace Test data Box { n: int } func go() -> bool { let a = new Box { n: 1 } let b = a return a == b } ``` ## ILEmitterTests_New__New_TwoPointersNotEqual (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_TwoPointersNotEqual topic: allocation status: verified // verified behavior: Test.go(...) == false namespace Test data Box { n: int } func go() -> bool { let a = new Box { n: 1 } let b = new Box { n: 1 } return a == b } ``` ## ILEmitterTests_New__New_InStaticFuncBody (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_InStaticFuncBody topic: allocation status: verified // verified behavior: Test.go(...) == 6 namespace Test data Box { n: int } static func Maker { func build(v: int) -> *Box = new Box { n: v } } func go() -> int { let b = Maker.build(6) return b.n } ``` ## ILEmitterTests_New__New_DeepLinkedListSum (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_DeepLinkedListSum topic: allocation status: verified // verified behavior: Test.go(...) == 55 namespace Test data Node { value: int, next: *Node } func go() -> int { var head: *Node = nil var i = 1 while i <= 10 { head = new Node { value: i, next: head } i += 1 } var sum = 0 var cur = head while cur != nil { sum += cur.value cur = cur.next } return sum } ``` ## ILEmitterTests_New__Ident_New_AsLetThenArithmetic (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_AsLetThenArithmetic topic: allocation status: verified // verified behavior: Test.go(...) == 25 namespace Test func go() -> int { let new = 5 return new * new } ``` ## ILEmitterTests_New__Ident_New_AsLoopVariableName (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::Ident_New_AsLoopVariableName topic: allocation status: verified // verified behavior: Test.go(...) == 10 namespace Test func go() -> int { var new = 0 for i in 0..5 { new += i } return new } ``` ## ILEmitterTests_New__New_FollowedByMethodCallViaLocal (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_FollowedByMethodCallViaLocal topic: allocation status: verified // verified behavior: Test.go(...) == 50 namespace Test data Box { n: int } func scaled(b: *Box) -> int = b.n * 10 func go() -> int { let b = new Box { n: 5 } return scaled(b) } ``` ## ILEmitterTests_New__New_StringInterpolationViaLocal (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_StringInterpolationViaLocal topic: allocation status: verified // verified behavior: Test.go(...) == "n=5" namespace Test data Box { n: int } func go() -> string { let b = new Box { n: 5 } return "n={b.n}" } ``` ## ILEmitterTests_New__New_MutateLinkedListNode (allocation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_New.cs::New_MutateLinkedListNode topic: allocation status: verified // verified behavior: Test.go(...) == 99 namespace Test data Node { var value: int, next: *Node } func go() -> int { var head = new Node { value: 1, next: nil } head.value = 99 return head.value } ``` ## ILEmitterTests_ExternalReflection__ListObject_BoxInt_ToArray_Length (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::ListObject_BoxInt_ToArray_Length topic: interop status: verified // verified behavior: Test.go(...) == 2 namespace Test func go() -> int { let xs = List() xs.Add(10) xs.Add(20) let arr = xs.ToArray() return arr.Length } ``` ## ILEmitterTests_ExternalReflection__ListInt_Count_AsInt (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::ListInt_Count_AsInt topic: interop status: verified // verified behavior: Test.go(...) == 3 namespace Test func go() -> int { let xs = List() xs.Add(1) xs.Add(2) xs.Add(3) return xs.Count } ``` ## ILEmitterTests_ExternalReflection__ListInt_Count_Interpolated (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::ListInt_Count_Interpolated topic: interop status: verified // verified behavior: Test.go(...) == "count=2" namespace Test func go() -> string { let xs = List() xs.Add(1) xs.Add(2) return "count={xs.Count}" } ``` ## ILEmitterTests_ExternalReflection__IReadOnlyListInt_Count_AsInt (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::IReadOnlyListInt_Count_AsInt topic: interop status: verified // verified behavior: Test.go(...) == 2 namespace Test func makeList() -> IReadOnlyList { let xs = List() xs.Add(1) xs.Add(2) return xs } func go() -> int { let ro = makeList() return ro.Count } ``` ## ILEmitterTests_ExternalReflection__IReadOnlyListInt_Count_Interpolated (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::IReadOnlyListInt_Count_Interpolated topic: interop status: verified // verified behavior: Test.go(...) == "n=1" namespace Test func makeList() -> IReadOnlyList { let xs = List() xs.Add(7) return xs } func go() -> string { let ro = makeList() return "n={ro.Count}" } ``` ## ILEmitterTests_ExternalReflection__AmbiguousExternalType_AcrossImports_ReportsES2151 (interop, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::AmbiguousExternalType_AcrossImports_ReportsES2151 topic: interop status: verified // verified behavior: reports diagnostic ES2151 namespace Test using "System.Threading" using "System.Timers" func go() -> int { let t = Timer() return 0 } ``` ## ILEmitterTests_ExternalReflection__QualifiedExternalType_SilencesAmbiguity (interop, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::QualifiedExternalType_SilencesAmbiguity topic: interop status: unverified // verified behavior: reports diagnostic ES2151 namespace Test using "System.Threading" using "System.Timers" func go(t: System.Timers.Timer) -> double { return t.Interval } ``` ## ILEmitterTests_ExternalReflection__IReadOnlyListInt_Count_PassedAsCallArg (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::IReadOnlyListInt_Count_PassedAsCallArg topic: interop status: verified // verified behavior: Test.go(...) == "2" namespace Test using "System.Text" func makeList() -> IReadOnlyList { let xs = List() xs.Add(2) xs.Add(5) return xs } func go() -> string { let ro = makeList() let sb = StringBuilder() sb.Append(ro.Count) return sb.ToString() } ``` ## ILEmitterTests_ExternalReflection__QualifiedConstruction_External_Works (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::QualifiedConstruction_External_Works topic: interop status: verified // verified behavior: Test.go(...) == 2 namespace Test func go() -> int { let sb = System.Text.StringBuilder() sb.Append(42) return sb.Length } ``` ## ILEmitterTests_ExternalReflection__MultiSegmentQualifiedStaticCall_Works (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::MultiSegmentQualifiedStaticCall_Works topic: interop status: verified // verified behavior: Test.go(...) == ".txt" namespace Test func go() -> string { return System.IO.Path.GetExtension("file.txt") } ``` ## ILEmitterTests_ExternalReflection__UsingStaticMultiSegment_BareCall_Works (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::UsingStaticMultiSegment_BareCall_Works topic: interop status: verified // verified behavior: Test.go(...) == ".txt" namespace Test using static "System.IO.Path" func go() -> string { return GetExtension("file.txt") } ``` ## ILEmitterTests_ExternalReflection__TypeAlias_Construction_Works (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::TypeAlias_Construction_Works topic: interop status: verified // verified behavior: Test.go(...) == 2 namespace Test using SB = "System.Text.StringBuilder" func go() -> int { let sb = SB() sb.Append(42) return sb.Length } ``` ## ILEmitterTests_ExternalReflection__TypeAlias_ResolvesCollision (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::TypeAlias_ResolvesCollision topic: interop status: verified // verified behavior: Test.go(...) == 3.0 namespace Test using "System.Threading" using TTimer = "System.Timers.Timer" func go() -> double { let t = TTimer() t.Interval = 3.0 return t.Interval } ``` ## ILEmitterTests_ExternalReflection__TypeAlias_ParameterPosition_Works (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::TypeAlias_ParameterPosition_Works topic: interop status: verified // verified behavior: Test.go(...) == 5 namespace Test using SB = "System.Text.StringBuilder" func length(b: SB) -> int = b.Length func go() -> int { let sb = SB() sb.Append("hello") return length(sb) } ``` ## ILEmitterTests_ExternalReflection__ListObject_BoxInt_ReadBackElement (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::ListObject_BoxInt_ReadBackElement topic: interop status: verified // verified behavior: Test.go(...) == 1 namespace Test func go() -> int { let xs = List() xs.Add(42) let arr = xs.ToArray() return arr.Length } ``` ## ILEmitterTests_ExternalReflection__OfType_ExplicitGenericArg_FiltersHeterogeneousList (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::OfType_ExplicitGenericArg_FiltersHeterogeneousList topic: interop status: verified // verified behavior: Test.go(...) == 4 namespace Test func go() -> int { let xs = List() xs.Add(1) xs.Add("two") xs.Add(3) xs.Add("four") var sum = 0 for n in xs.OfType() { sum += n } return sum } ``` ## ILEmitterTests_ExternalReflection__Cast_ExplicitGenericArg_TypesElements (interop, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::Cast_ExplicitGenericArg_TypesElements topic: interop status: unverified // verified behavior: Test.go(...) == 30 namespace Test func go() -> int { let xs = List() xs.Add(10) xs.Add(20) var sum = 0 for n in xs.Cast() { sum += n } return sum } ``` ## ILEmitterTests_ExternalReflection__OfType_ResultElementType_AllowsMemberAccess (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_ExternalReflection.cs::OfType_ResultElementType_AllowsMemberAccess topic: interop status: verified // verified behavior: Test.go(...) == 5 namespace Test func go() -> int { let xs = List() xs.Add("ab") xs.Add(7) xs.Add("cde") var total = 0 for s in xs.OfType() { total += s.Length } return total } ``` ## DataContractTests__RecursiveField_DirectSelfReference_Errors (data, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::RecursiveField_DirectSelfReference_Errors topic: data status: verified // verified behavior: reports diagnostic ES2002 namespace Test data Node { value: int next: Node } ``` ## DataContractTests__RecursiveField_PointerForm_Ok (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::RecursiveField_PointerForm_Ok topic: data status: unverified // verified behavior: reports diagnostic ES2002 namespace Test data Node { value: int next: *Node } ``` ## DataContractTests__RecursiveField_InGenericContainer_Errors (data, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::RecursiveField_InGenericContainer_Errors topic: data status: verified // verified behavior: reports diagnostic ES2002 namespace Test data Tree { value: int children: List } ``` ## DataContractTests__RecursiveField_ListOfPointer_Ok (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::RecursiveField_ListOfPointer_Ok topic: data status: unverified // verified behavior: reports diagnostic ES2002 namespace Test data Tree { value: int children: List<*Tree> } ``` ## DataContractTests__RecursiveField_RefDataAllowsSelfReference (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::RecursiveField_RefDataAllowsSelfReference topic: data status: unverified // verified behavior: reports diagnostic ES2002 namespace Test ref data Node { value: int next: Node } ``` ## DataContractTests__InitBlock_OnData_Errors (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::InitBlock_OnData_Errors topic: data status: unverified // verified behavior: reports diagnostic ES3012 namespace Test data Point { x: int y: int init(px: int, py: int) { self.x = px self.y = py } } ``` ## DataContractTests__InitBlock_OnRefData_Ok (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::InitBlock_OnRefData_Ok topic: data status: unverified // verified behavior: reports diagnostic ES3012 namespace Test ref data Point { x: int y: int init(px: int, py: int) { self.x = px self.y = py } } ``` ## DataContractTests__PositionalForm_OnData_StillWorks (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::PositionalForm_OnData_StillWorks topic: data status: unverified // verified behavior: reports diagnostic ES3012 namespace Test data Vec2(x: int, y: int) func main() { let v = Vec2(3, 4) } ``` ## DataContractTests__SmallData_StaysStruct (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::SmallData_StaysStruct topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Point { x: int y: int } ``` ## DataContractTests__ReadonlyData_StaysStruct_EvenWhenLarge (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::ReadonlyData_StaysStruct_EvenWhenLarge topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test readonly data Big { a: double b: double c: double d: double e: double f: double g: double h: double i: double } ``` ## DataContractTests__StackAllocAttribute_ForcesStruct (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::StackAllocAttribute_ForcesStruct topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [StackAlloc] data Big { a: double b: double c: double d: double e: double f: double g: double h: double i: double } ``` ## DataContractTests__HeapAllocAttribute_ForcesClass (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::HeapAllocAttribute_ForcesClass topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [HeapAlloc] data Point { x: int y: int } ``` ## DataContractTests__StackAllocAttribute_OnRefData_Errors (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::StackAllocAttribute_OnRefData_Errors topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test [StackAlloc] ref data Conn { host: string port: int } ``` ## DataContractTests__HeapAllocAttribute_OnRefData_Errors (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::HeapAllocAttribute_OnRefData_Errors topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test [HeapAlloc] ref data Conn { host: string port: int } ``` ## DataContractTests__StackAllocAndHeapAlloc_Together_Errors (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: DataContractTests.cs::StackAllocAndHeapAlloc_Together_Errors topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test [StackAlloc] [HeapAlloc] data Point { x: int y: int } ``` ## ILEmitterTests_FunctionPointers__FunctionPointer_CallThroughLocal_ReturnsCorrectResult (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FunctionPointers.cs::FunctionPointer_CallThroughLocal_ReturnsCorrectResult topic: pointers status: verified // verified behavior: Test.callViaPointer(...) == 7 namespace Test func add(a: int, b: int) -> int { return a + b } func callViaPointer() -> int { let ptr = &add return ptr(3, 4) } ``` ## ILEmitterTests_FunctionPointers__FunctionPointer_VoidReturn_Works (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FunctionPointers.cs::FunctionPointer_VoidReturn_Works topic: pointers status: verified // verified behavior: Test.test(...) == 25 namespace Test func double(x: int) -> int { return x * 2 } func triple(x: int) -> int { return x * 3 } func test() -> int { let d = &double let t = &triple return d(5) + t(5) } ``` ## ILEmitterTests_FunctionPointers__FunctionPointer_WithByRefParam_Works (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FunctionPointers.cs::FunctionPointer_WithByRefParam_Works topic: pointers status: verified // verified behavior: Test.test(...) == 3 namespace Test func increment(x: *int) { x += 1 } func test() -> int { var count = 0 let fn = &increment fn(*count) fn(*count) fn(*count) return count } ``` ## ILEmitterTests_FunctionPointers__FunctionPointer_TypedParameter_Works (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FunctionPointers.cs::FunctionPointer_TypedParameter_Works topic: pointers status: verified // verified behavior: Test.test(...) == 42 namespace Test func double(x: int) -> int { return x * 2 } func apply(f: &(int -> int), value: int) -> int { return f(value) } func test() -> int { return apply(&double, 21) } ``` ## ILEmitterTests_FunctionPointers__FunctionPointer_InStructField_Works (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_FunctionPointers.cs::FunctionPointer_InStructField_Works topic: pointers status: verified // verified behavior: Test.test(...) == 19 namespace Test func add(a: int, b: int) -> int { return a + b } func mul(a: int, b: int) -> int { return a * b } data BinOp { apply: &(int, int -> int) } func test() -> int { let adder = BinOp { apply: &add } let muler = BinOp { apply: &mul } return adder.apply(3, 4) + muler.apply(3, 4) } ``` ## IndexDiagnosticTests__IndexingData_Errors (data, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: IndexDiagnosticTests.cs::IndexingData_Errors topic: data status: verified // verified behavior: reports diagnostic ES2145 namespace Test data P { x: int } func f(p: P) -> int { return p[0] } ``` ## IndexDiagnosticTests__IndexingChoice_Errors (choice, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: IndexDiagnosticTests.cs::IndexingChoice_Errors topic: choice status: verified // verified behavior: reports diagnostic ES2145 namespace Test choice C { a b(n: int) } func f(c: C) -> int { return c[0] } ``` ## IndexDiagnosticTests__IndexingEnum_Errors (enum, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: IndexDiagnosticTests.cs::IndexingEnum_Errors topic: enum status: verified // verified behavior: reports diagnostic ES2145 namespace Test enum E { a b c } func f(e: E) -> int { return e[0] } ``` ## IndexDiagnosticTests__IndexingList_DoesNotError (core, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: IndexDiagnosticTests.cs::IndexingList_DoesNotError topic: core status: unverified // verified behavior: reports diagnostic ES2145 namespace Test func f(xs: List) -> int { return xs[0] } ``` ## IndexDiagnosticTests__IndexingString_DoesNotError (core, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: IndexDiagnosticTests.cs::IndexingString_DoesNotError topic: core status: unverified // verified behavior: reports diagnostic ES2145 namespace Test func first(s: string) -> char { return s[0] } ``` ## EmitterStressTests__PositionalDataWithListLiterals (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::PositionalDataWithListLiterals topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace T data Config(name: string, url: string, category: string) func defaults() -> List { return [ Config("A", "http://a.com", "cat1"), Config("B", "http://b.com", "cat2"), ] } ``` ## EmitterStressTests__TryCatchWithTypedBinding (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::TryCatchWithTypedBinding topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace T func run() -> string { try { let x = 1 / 0 return "ok" } catch (Exception ex) { return ex.Message } } ``` ## EmitterStressTests__AsyncWithTupleReturnAndForDestructuring (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::AsyncWithTupleReturnAndForDestructuring topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T func work() -> (List, List) { var items = List() var errors = List() return (items, errors) } func run() { var tasks = List, List)>>() tasks.Add(Task.Run(func() -> (List, List) { return work() })) let results = await Task.WhenAll(tasks.ToArray()) for (items, errors) in results { let n = items.Count + errors.Count } } ``` ## EmitterStressTests__RefDataWithAsyncMethodAndTryCatch (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::RefDataWithAsyncMethodAndTryCatch topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T data Item(title: string, source: string) func fetchItems(client: HttpClient, url: string) -> (List, List) { var items = List() var errors = List() try { let stream = await client.GetStreamAsync(url) items.Add(Item("title", "src")) } catch (Exception ex) { errors.Add(ex.Message) } return (items, errors) } ``` ## EmitterStressTests__RefDataWithMultipleMethodsAndExpressionBodies (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::RefDataWithMultipleMethodsAndExpressionBodies topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T data Config(name: string, url: string) data Item(title: string, source: string) data Status(name: string, itemCount: int) ref data Svc { configs: List items: List statuses: List client: HttpClient maxItems: int init() { self.configs = List() self.items = List() self.statuses = List() self.client = HttpClient() self.maxItems = 500 } func poll() { var tasks = List, List)>>() for cfg in self.configs { let c = self.client let f = cfg tasks.Add(Task.Run(func() -> (List, List) { return (List(), List()) })) } let results = await Task.WhenAll(tasks.ToArray()) var all = List() var statuses = List() var i = 0 for (items, errors) in results { let cfg = self.configs[i] i += 1 let err = errors.Count > 0 ? errors[0] : "" statuses.Add(Status(cfg.name, items.Count)) all.AddRange(items) } if all.Count > self.maxItems { all.RemoveRange(self.maxItems, all.Count - self.maxItems) } self.items = all self.statuses = statuses } func count() -> int = self.items.Count func addConfig(name: string, url: string) = self.configs.Add(Config(name, url)) } ``` ## EmitterStressTests__InterfaceImplWithLambdaArgs (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::InterfaceImplWithLambdaArgs topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T ref data Plugin { name: string init() { self.name = "test" } pub func Name() -> string = self.name pub func Run(app: WebApplication) { app.MapGet("/api/test", func(q: string) -> IResult { return Results.Json(q ?? "default") }) app.MapGet("/api/ping", func() -> IResult = Results.Json("pong")) } } ``` ## EmitterStressTests__Parse_KeywordAsVariableName_ReportsError (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::Parse_KeywordAsVariableName_ReportsError topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T func run() -> int { let pub = 42 return pub } ``` ## EmitterStressTests__Parse_ConstructorCallWith6ArgsInForLoop (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::Parse_ConstructorCallWith6ArgsInForLoop topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T data Item(a: string, b: string, c: string, d: DateTimeOffset, e: string, f: string) func run(synd: object, feed: object) { var items = List() for entry in synd.Items { let link = entry.Links.Count > 0 ? entry.Links[0].Uri.ToString() : "" let summary = entry.Summary?.Text ?? "" let pub = entry.PublishDate != DateTimeOffset.MinValue ? entry.PublishDate : entry.LastUpdatedTime items.Add(Item(entry.Title.Text, link, feed.name, pub, summary, feed.category)) } } ``` ## EmitterStressTests__NullConditionalChainWithCoalesce (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: EmitterStressTests.cs::NullConditionalChainWithCoalesce topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace T func safe(s: string) -> int { return s?.Length ?? 0 } func ternaryChain(x: int) -> string { let label = x > 100 ? "high" : x > 50 ? "mid" : "low" return label } ``` ## AsyncIntegrationTests__Async_WhileLoop_IL_Runs (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::Async_WhileLoop_IL_Runs topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func sumTo(n: int) -> int { var i = 1 var total = 0 while i <= n { let step = await Task.FromResult(i) total = total + step i = i + 1 } return total } ``` ## AsyncIntegrationTests__Async_Throw_IL_SurfacesException (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::Async_Throw_IL_SurfacesException topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func failIf(n: int) -> int { let v = await Task.FromResult(n) if v < 0 { throw InvalidOperationException("negative") } return v } ``` ## AsyncIntegrationTests__Async_ObjectCreation_IL_Runs (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::Async_ObjectCreation_IL_Runs topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Point { x: int, y: int } func buildAt(n: int) -> int { let v = await Task.FromResult(n) let p = Point { x: v, y: v * 2 } return p.x + p.y } ``` ## AsyncIntegrationTests__Async_StringInterpolation_IL_Runs (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::Async_StringInterpolation_IL_Runs topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func greet(name: string) -> string { let hello = await Task.FromResult(name) return "hi {hello}!" } ``` ## AsyncIntegrationTests__Async_DotCase_IL_Runs (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::Async_DotCase_IL_Runs topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Reply { ok(v: int) err(msg: string) } func replyOf(n: int) -> int { let v = await Task.FromResult(n) let r = Reply.ok(v + 1) match (r: Reply) { .ok(x) { return x } .err(_) { return -1 } } return -2 } ``` ## AsyncIntegrationTests__AsyncLet_SimpleTwoPending_IL_Runs (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::AsyncLet_SimpleTwoPending_IL_Runs topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func runParallel() -> int { async let a = Task.FromResult(20) async let b = Task.FromResult(22) return a + b } ``` ## AsyncIntegrationTests__Async_VoidAwait_IL_Runs (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::Async_VoidAwait_IL_Runs topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func delayThenReturn() -> int { await Task.Delay(1) return 42 } ``` ## AsyncIntegrationTests__AsyncLet_SyncUserFunc_IL_WrapsInTaskRun (async, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::AsyncLet_SyncUserFunc_IL_WrapsInTaskRun topic: async status: verified // verified behavior: reports diagnostic ES3004 namespace Test func compute(n: int) -> int { return n * 10 } func runBoth() -> int { async let a = compute(4) async let b = compute(3) return a + b } ``` ## AsyncIntegrationTests__Async_TryCatch_NoAwaitInTry_IL_Runs (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: AsyncIntegrationTests.cs::Async_TryCatch_NoAwaitInTry_IL_Runs topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func safe(n: int) -> int { let v = await Task.FromResult(n) var result = 0 try { result = v * 2 } catch (Exception e) { result = -1 } return result } ``` ## ILEmitterTests_Integration__Json_SumsNestedNumbers (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_SumsNestedNumbers topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> int { let r = parse("[1, [2, 3], 4]") if r.IsError { return -1 } return sumNumbers(r.Value) } ``` ## ILEmitterTests_Integration__Json_SumIgnoresNonNumbers (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_SumIgnoresNonNumbers topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> int { let r = parse("[1, true, \"hi\", null, [2, 3]]") if r.IsError { return -1 } return sumNumbers(r.Value) } ``` ## ILEmitterTests_Integration__Json_CountsAllNodes (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_CountsAllNodes topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> int { let r = parse("[1, [2, 3], 4]") if r.IsError { return -1 } return countNodes(r.Value) } ``` ## ILEmitterTests_Integration__Json_ComputesNestingDepth (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_ComputesNestingDepth topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> int { let r = parse("[1, [2, [3, 4]]]") if r.IsError { return -1 } return depth(r.Value) } ``` ## ILEmitterTests_Integration__Json_ParsesScalarString (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_ParsesScalarString topic: choice status: unverified // verified behavior: Test.go(...) == "hello" func go() -> string { let r = parse("\"hello\"") if r.IsError { return "ERR" } match r.Value { .jstr(node) { return node.s } default { return "?" } } return "?" } ``` ## ILEmitterTests_Integration__Json_EmptyArray (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_EmptyArray topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> int { let r = parse("[]") if r.IsError { return -1 } return countNodes(r.Value) } ``` ## ILEmitterTests_Integration__Json_UnterminatedArrayIsError (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_UnterminatedArrayIsError topic: core status: unverified // verified behavior: Test.go(...) == "unterminated array" func go() -> string { let r = parse("[1, 2") return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_Integration__Json_UnterminatedStringIsError (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_UnterminatedStringIsError topic: core status: unverified // verified behavior: Test.go(...) == "unterminated string" func go() -> string { let r = parse("\"abc") return r.IsError ? r.Error : "ok" } ``` ## ILEmitterTests_Integration__Json_NegativeNumbers (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_NegativeNumbers topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> int { let r = parse("[-2, -3]") if r.IsError { return 999 } return sumNumbers(r.Value) } ``` ## ILEmitterTests_Integration__Json_WhitespaceTolerant (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Json_WhitespaceTolerant topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> int { let r = parse(" [ 1 ,\t2 ,\n 3 ] ") if r.IsError { return -1 } return sumNumbers(r.Value) } ``` ## ILEmitterTests_Integration__Reflection_RuntimeTypeName (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Reflection_RuntimeTypeName topic: data status: verified // verified behavior: Test.go(...) == "Widget" namespace Test pub ref data Widget { id: int init(id: int) { self.id = id } } func go() -> string { let w = Widget(7) return w.GetType().Name } ``` ## ILEmitterTests_Integration__Reflection_TypeNamespace (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Reflection_TypeNamespace topic: data status: verified // verified behavior: Test.go(...) == "Test" namespace Test pub ref data Widget { id: int init(id: int) { self.id = id } } func go() -> string { let w = Widget(1) return w.GetType().Namespace } ``` ## ILEmitterTests_Integration__Reflection_ValueDataTypeName (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Reflection_ValueDataTypeName topic: data status: verified // verified behavior: Test.go(...) == "Point" namespace Test data Point { x: int, y: int } func go() -> string { let p = Point { x: 1, y: 2 } return p.GetType().Name } ``` ## ILEmitterTests_Integration__Reflection_FindsDeclaredMethod (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Reflection_FindsDeclaredMethod topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Reflection" pub ref data Widget { id: int init(id: int) { self.id = id } pub func describe() -> string = "w{self.id}" } func go() -> bool { let w = Widget(1) let m = w.GetType().GetMethod("describe") return m != nil } ``` ## ILEmitterTests_Integration__Reflection_AssemblyContainsTypes (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Reflection_AssemblyContainsTypes topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Reflection" data Marker { v: int } func go() -> bool { let t = Marker { v: 1 } let asm = t.GetType().Assembly return asm.GetTypes().Length > 0 } ``` ## ILEmitterTests_Integration__Reflection_InvokeMethodDynamically (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Reflection_InvokeMethodDynamically topic: interpolation status: verified // verified behavior: Test.go(...) == "w42" namespace Test using "System.Reflection" pub ref data Widget { id: int init(id: int) { self.id = id } pub func describe() -> string = "w{self.id}" } func go() -> string { let w = Widget(42) let m = w.GetType().GetMethod("describe") let result = m.Invoke(w, nil) return result.ToString() } ``` ## ILEmitterTests_Integration__Reflection_BaseTypeOfRefData (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Reflection_BaseTypeOfRefData topic: data status: verified // verified behavior: Test.go(...) == "Object" namespace Test pub ref data Widget { id: int init(id: int) { self.id = id } } func go() -> string { let w = Widget(1) return w.GetType().BaseType.Name } ``` ## ILEmitterTests_Integration__Exe_EntryPointIsWiredToMain (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Exe_EntryPointIsWiredToMain topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub ref data Program { var counter: int init() { self.counter = 0 } func run() -> int { for i in 1..5 { self.counter += i } return self.counter } } func main() -> int { let p = Program() return p.run() } ``` ## ILEmitterTests_Integration__Exe_MainProducesConsoleOutput (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Exe_MainProducesConsoleOutput topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func main() -> int { let total = 7 * 6 Console.WriteLine("answer={total}") return total } ``` ## ILEmitterTests_Integration__Library_NoEntryPointEvenWithMain (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::Library_NoEntryPointEvenWithMain topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func main() -> int { return 5 } ``` ## ILEmitterTests_Integration__CrossNamespace_TypeVisibleViaUsing (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::CrossNamespace_TypeVisibleViaUsing topic: data status: verified // verified behavior: Test.go(...) == 7 namespace Geometry data Point { x: int y: int } ``` ## ILEmitterTests_Integration__CrossNamespace_PromotedInstanceMethod (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::CrossNamespace_PromotedInstanceMethod topic: data status: verified // verified behavior: Test.go(...) == 30 namespace Geometry data Point { x: int y: int } func area(p: Point) -> int { return p.x * p.y } ``` ## ILEmitterTests_Integration__CrossNamespace_QualifiedFreeFunctionCall (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::CrossNamespace_QualifiedFreeFunctionCall topic: core status: verified // verified behavior: Test.go(...) == 42 namespace MathNs func add(a: int, b: int) -> int { return a + b } ``` ## ILEmitterTests_Integration__CrossNamespace_ChoiceConstructedAndMatched (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::CrossNamespace_ChoiceConstructedAndMatched topic: choice status: verified // verified behavior: Test.go(...) == "active" namespace Model choice Status { active suspended(reason: string) } ``` ## ILEmitterTests_Integration__CrossNamespace_EnumMatched (enum, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::CrossNamespace_EnumMatched topic: enum status: verified // verified behavior: Test.go(...) == "E" namespace Model enum Role { admin editor viewer } ``` ## ILEmitterTests_Integration__CrossNamespace_ThreeUnitsChained (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::CrossNamespace_ThreeUnitsChained topic: data status: verified // verified behavior: Test.go(...) == 500 namespace Core data Money { cents: int } ``` ## ILEmitterTests_Integration__PerFileImportScoping_BareExternalNameResolvesToOwnFileImport (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Integration.cs::PerFileImportScoping_BareExternalNameResolvesToOwnFileImport topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Timers" func ta(x: Timer) -> int = 1 ``` ## ILEmitterTests_Coverage_Adversarial__Interp_ObjectLiteralInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_ObjectLiteralInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data P { x: int, y: int } func go() -> string = "p={P { x: 3, y: 4 }.x}" ``` ## ILEmitterTests_Coverage_Adversarial__Interp_NestedMatchInHole (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_NestedMatchInHole topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { let n = 2 return "v={match n { 1 { "one" } 2 { "two" } default { "?" } }}" } ``` ## ILEmitterTests_Coverage_Adversarial__Interp_EscapedBracesMixedWithHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_EscapedBracesMixedWithHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { let n = 7 return "{{literal}} = {n}" } ``` ## ILEmitterTests_Coverage_Adversarial__Interp_ChainedMemberAccess (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_ChainedMemberAccess topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Inner { v: int } data Outer { inner: Inner } func go() -> string { let o = Outer { inner: Inner { v: 42 } } return "got {o.inner.v}" } ``` ## ILEmitterTests_Coverage_Adversarial__Interp_MethodCallInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_MethodCallInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func square(n: int) -> int = n * n func go() -> string = "sq={square(5)}" ``` ## ILEmitterTests_Coverage_Adversarial__Interp_TernaryWithNestedStringQuotes (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_TernaryWithNestedStringQuotes topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { let n = 0 - 3 return "sign={n > 0 ? "+" : "-"}" } ``` ## ILEmitterTests_Coverage_Adversarial__Interp_PropertyGetterHole_ValueTypeBoxes (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_PropertyGetterHole_ValueTypeBoxes topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { let s = "hello" return "len={s.Length}" } ``` ## ILEmitterTests_Coverage_Adversarial__Interp_MultipleHolesAndOperators (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Interp_MultipleHolesAndOperators topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> string { let a = 3 let b = 4 return "{a}+{b}={a + b}" } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_ListOfValueData_AddAndIndex (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_ListOfValueData_AddAndIndex topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Pt { x: int, y: int } func go() -> int { let xs = List() xs.Add(Pt { x: 10, y: 20 }) xs.Add(Pt { x: 30, y: 40 }) return xs[0].y + xs[1].x } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_DictionaryStringToValueData (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_DictionaryStringToValueData topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Score { points: int } func go() -> int { let m = Dictionary() m["a"] = Score { points: 5 } m["b"] = Score { points: 9 } return m["a"].points + m["b"].points } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_ListOfNullableInt (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_ListOfNullableInt topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = List() xs.Add(7) xs.Add(nil) return xs[0] ?? 0 } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_NullableDoubleCoalesceAndConditional (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_NullableDoubleCoalesceAndConditional topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func pick(v: double?) -> double = v ?? 1.5 func go() -> double { return pick(nil) + pick(2.5) } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_TupleListForDestructure (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_TupleListForDestructure topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let pairs = List<(int, int)>() pairs.Add((1, 2)) pairs.Add((3, 4)) var total = 0 for (a, b) in pairs { total += a * b } return total } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_OptionPayloadMatch (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_OptionPayloadMatch topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Option { some(value: T) none } func unwrapOr(o: Option, fallback: int) -> int { match o { .some(v) { return v } .none { return fallback } } return fallback } func go() -> int { let a = Option.some(99) let b = Option.none() return unwrapOr(a, -1) + unwrapOr(b, 5) } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_UserPairSwap (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_UserPairSwap topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Pair { first: A second: B } func go() -> int { let p = Pair { first: 3, second: 7 } let q = Pair { first: p.second, second: p.first } return q.first - q.second } ``` ## ILEmitterTests_Coverage_Adversarial__Generics_NestedTuple (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Generics_NestedTuple topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let t = (1, (2, 3)) return t.Item1 + t.Item2.Item1 + t.Item2.Item2 } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_UsingBringsTypeAndFreeFuncBare (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_UsingBringsTypeAndFreeFuncBare topic: data status: verified // verified behavior: Test.go(...) == 11 namespace Lib data Vec { x: int } func incr(n: int) -> int { return n + 1 } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_ValueReceiverFreeCall_IsError (data, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_ValueReceiverFreeCall_IsError topic: data status: verified // verified behavior: reports diagnostic ES2142 namespace Test data Vec { x: int } func bump(v: Vec) -> int { return v.x + 1 } func go() -> int { let v = Vec { x: 10 } return bump(v) } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_PointerReceiverFreeCall_IsAllowed (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_PointerReceiverFreeCall_IsAllowed topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec { x: int } func bump(v: *Vec) { v.x += 1 } func go() -> int { var v: *Vec = new Vec { x: 10 } bump(v) return v.x } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_QualifiedFreeFunctionAndType (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_QualifiedFreeFunctionAndType topic: data status: verified // verified behavior: Test.go(...) == 42 namespace Lib data Vec { x: int } func bump(v: Vec) -> int { return v.x + 1 } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_ThreeNamespacesChainedViaUsings (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_ThreeNamespacesChainedViaUsings topic: data status: verified // verified behavior: Test.go(...) == 500 namespace Core data Money { cents: int } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_BareCrossNamespace_WithoutUsing_IsError (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_BareCrossNamespace_WithoutUsing_IsError topic: data status: unverified // verified behavior: reports diagnostic ES2150 namespace Lib data Vec { x: int } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_AmbiguousResolvedByQualifier (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_AmbiguousResolvedByQualifier topic: data status: verified // verified behavior: Test.go(...) == 9 namespace A data Widget { a: int } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_LowerCaseTypeName_IsError (data, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_LowerCaseTypeName_IsError topic: data status: verified // verified behavior: reports diagnostic ES2160 namespace Test data widget { x: int } ``` ## ILEmitterTests_Coverage_Adversarial__Ns_SnakeCaseTypeName_IsError (choice, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Ns_SnakeCaseTypeName_IsError topic: choice status: verified // verified behavior: reports diagnostic ES2160 namespace Test choice my_choice { a b } ``` ## ILEmitterTests_Coverage_Adversarial__DefiniteReturn_FallThrough_IsError (core, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::DefiniteReturn_FallThrough_IsError topic: core status: verified // verified behavior: reports diagnostic ES2140 namespace Test func go(n: int) -> int { if n > 0 { return 1 } } ``` ## ILEmitterTests_Coverage_Adversarial__DefiniteReturn_ExhaustiveBool_NoTrailingReturn_Clean (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::DefiniteReturn_ExhaustiveBool_NoTrailingReturn_Clean topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func label(b: bool) -> string { match b { true { return "on" } false { return "off" } } } func go() -> string = label(true) ``` ## ILEmitterTests_Coverage_Adversarial__DefiniteReturn_ExhaustiveChoice_NoTrailingReturn_Clean (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::DefiniteReturn_ExhaustiveChoice_NoTrailingReturn_Clean topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Dir { north, south } func name(d: Dir) -> string { match d { .north { return "N" } .south { return "S" } } } func go() -> string = name(Dir.south()) ``` ## ILEmitterTests_Coverage_Adversarial__DefiniteReturn_ExhaustiveEnum_NoTrailingReturn_Clean (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::DefiniteReturn_ExhaustiveEnum_NoTrailingReturn_Clean topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test enum Color { red, green, blue } func code(c: Color) -> int { match (c: Color) { .red { return 1 } .green { return 2 } .blue { return 3 } } } func go() -> int = code(Color.green()) ``` ## ILEmitterTests_Coverage_Adversarial__DefiniteReturn_InfiniteLoopTerminates_Clean (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::DefiniteReturn_InfiniteLoopTerminates_Clean topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var i = 0 while true { i += 1 if i >= 5 { return i } } } ``` ## ILEmitterTests_Coverage_Adversarial__Lexer_ExponentLowercaseE (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Lexer_ExponentLowercaseE topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double = 1.0e10 ``` ## ILEmitterTests_Coverage_Adversarial__Lexer_ExponentNegative (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Lexer_ExponentNegative topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double = 1.5e-3 ``` ## ILEmitterTests_Coverage_Adversarial__Lexer_ExponentUppercaseE (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Lexer_ExponentUppercaseE topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double = 2E8 ``` ## ILEmitterTests_Coverage_Adversarial__Lexer_ExponentLargeMantissa (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Lexer_ExponentLargeMantissa topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> double = 6.022e23 ``` ## ILEmitterTests_Coverage_Adversarial__Lexer_UnderscoreSeparators (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Lexer_UnderscoreSeparators topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int = 1_000_000 ``` ## ILEmitterTests_Coverage_Adversarial__Reflection_GetTypeNameOfData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Reflection_GetTypeNameOfData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Widget { id: int } func go() -> string { let w = Widget { id: 1 } return w.GetType().Name } ``` ## ILEmitterTests_Coverage_Adversarial__Reflection_CountDeclaredMethodsViaInstanceType (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Adversarial.cs::Reflection_CountDeclaredMethodsViaInstanceType topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Reflection" data Widget { id: int } func go() -> bool { let w = Widget { id: 1 } let methods = w.GetType().GetMethods() return methods.Length >= 1 } ``` ## ILEmitterTests_Embedding__ValueEmbed_FieldExists (embedding, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_FieldExists topic: embedding status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Base { var x: int var y: int } data Widget { Base label: string } func getLabel() -> string { var w = Widget { x: 10, y: 20, label: "hello" } return w.label } ``` ## ILEmitterTests_Embedding__ValueEmbed_PromotedFieldRead (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_PromotedFieldRead topic: embedding status: verified // verified behavior: Test.getY(...) == 7 namespace Test data Base { var x: int var y: int } data Widget { Base label: string } func getX() -> int { var w = Widget { x: 42, y: 7, label: "test" } return w.x } func getY() -> int { var w = Widget { x: 42, y: 7, label: "test" } return w.y } ``` ## ILEmitterTests_Embedding__ValueEmbed_PromotedFieldWrite (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_PromotedFieldWrite topic: embedding status: verified // verified behavior: Test.mutateX(...) == 99 namespace Test data Base { var x: int var y: int } data Widget { Base label: string } func mutateX() -> int { var w = Widget { x: 10, y: 20, label: "test" } w.x = 99 return w.x } ``` ## ILEmitterTests_Embedding__ValueEmbed_PromotedMethodCall (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_PromotedMethodCall topic: embedding status: verified // verified behavior: Test.getSum(...) == 30 namespace Test data Vec2 { var x: int var y: int func sum() -> int { return self.x + self.y } } data Entity { Vec2 name: string } func getSum() -> int { var e = Entity { x: 10, y: 20, name: "test" } return e.sum() } ``` ## ILEmitterTests_Embedding__ValueEmbed_MutatingMethodCall (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_MutatingMethodCall topic: embedding status: verified // verified behavior: Test.moveAndGet(...) == 15 namespace Test data Vec2 { var x: int var y: int func addTo(dx: int, dy: int) { self.x += dx self.y += dy } } data Entity { Vec2 name: string } func moveAndGet() -> int { var e = Entity { x: 10, y: 20, name: "test" } e.addTo(5, 3) return e.x } ``` ## ILEmitterTests_Embedding__PointerEmbed_FieldExists (embedding, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::PointerEmbed_FieldExists topic: embedding status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Base { var x: int var y: int } data WidgetRef { *Base label: string } func getLabel() -> string { var w = WidgetRef { Base: new Base { x: 10, y: 20 }, label: "hello" } return w.label } ``` ## ILEmitterTests_Embedding__PointerEmbed_PromotedFieldRead (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::PointerEmbed_PromotedFieldRead topic: embedding status: verified // verified behavior: Test.getX(...) == 42 namespace Test data Base { var x: int var y: int } data WidgetRef { *Base label: string } func getX() -> int { var w = WidgetRef { Base: new Base { x: 42, y: 7 }, label: "test" } return w.x } ``` ## ILEmitterTests_Embedding__PointerEmbed_PromotedFieldWrite (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::PointerEmbed_PromotedFieldWrite topic: embedding status: verified // verified behavior: Test.mutateX(...) == 99 namespace Test data Base { var x: int var y: int } data WidgetRef { *Base label: string } func mutateX() -> int { var w = WidgetRef { Base: new Base { x: 10, y: 20 }, label: "test" } w.x = 99 return w.x } ``` ## ILEmitterTests_Embedding__ValueEmbed_CompoundAssignment (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_CompoundAssignment topic: embedding status: verified // verified behavior: Test.addToX(...) == 15 namespace Test data Base { var x: int } data Wrapper { Base tag: int } func addToX() -> int { var w = Wrapper { x: 10, tag: 1 } w.x += 5 return w.x } ``` ## ILEmitterTests_Embedding__ValueEmbed_DirectFieldAccess (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_DirectFieldAccess topic: embedding status: verified // verified behavior: Test.getBaseY(...) == 20 namespace Test data Base { var x: int var y: int } data Widget { Base label: string } func getBaseY() -> int { var w = Widget { x: 10, y: 20, label: "test" } return w.Base.y } ``` ## ILEmitterTests_Embedding__ValueEmbed_MixedFields (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_MixedFields topic: embedding status: verified // verified behavior: Test.checkPlayer(...) == 88 namespace Test data Position { var x: int var y: int } data Player { Position name: string var health: int } func checkPlayer() -> int { var p = Player { x: 5, y: 10, name: "hero", health: 100 } p.x += 3 p.health -= 20 return p.x + p.health } ``` ## ILEmitterTests_Embedding__PointerEmbed_NilCheck (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::PointerEmbed_NilCheck topic: embedding status: verified // verified behavior: Test.isNotNil(...) == true namespace Test data Inner { var x: int } data Outer { *Inner tag: int } func isNil() -> bool { var o = Outer { tag: 1 } return o.Inner == nil } func isNotNil() -> bool { var o = Outer { Inner: new Inner { x: 42 }, tag: 1 } return o.Inner != nil } ``` ## ILEmitterTests_Embedding__ValueEmbed_InRefData (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_InRefData topic: embedding status: verified // verified behavior: Test.getX(...) == 42 namespace Test data Vec2 { var x: int var y: int } ref data Entity { Vec2 name: string } func getX() -> int { var e = Entity() e.x = 42 return e.x } ``` ## ILEmitterTests_Embedding__ValueEmbed_OuterCallsPromoted (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::ValueEmbed_OuterCallsPromoted topic: embedding status: verified // verified behavior: Test.getQuad(...) == 20 namespace Test data Base { var value: int func doubled() -> int { return self.value * 2 } } data Wrapper { Base func quadrupled() -> int { return self.doubled() * 2 } } func getQuad() -> int { var w = Wrapper { value: 5 } return w.quadrupled() } ``` ## ILEmitterTests_Embedding__Embedded_Field_Read_Returns_Inner_Value (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::Embedded_Field_Read_Returns_Inner_Value topic: embedding status: verified // verified behavior: Test.test(...) == 42 namespace Test data Inner { value: int } data Outer { pub Inner } func test() -> int { let o = Outer { Inner: Inner { value: 42 } } return o.value } ``` ## ILEmitterTests_Embedding__Added_ValueEmbed_PromotedField (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::Added_ValueEmbed_PromotedField topic: embedding status: verified // verified behavior: Test.test(...) == 35 namespace Test data Vec2 { var x: int, var y: int } data Transform { Vec2, var scale: int } func test() -> int { var t = Transform { x: 10, y: 20, scale: 2 } t.x += 5 return t.x + t.y // 15 + 20 } ``` ## ILEmitterTests_Embedding__Added_ValueEmbed_PromotedMethod (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::Added_ValueEmbed_PromotedMethod topic: embedding status: verified // verified behavior: Test.test(...) == 25 namespace Test data Vec2 { var x: int, var y: int } func magnitude(v: Vec2) -> int = v.x * v.x + v.y * v.y data Transform { Vec2, var scale: int } func test() -> int { let t = Transform { x: 3, y: 4, scale: 1 } return t.magnitude() } ``` ## ILEmitterTests_Embedding__Added_PointerEmbed_NewConstruction (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::Added_PointerEmbed_NewConstruction topic: embedding status: verified // verified behavior: Test.test(...) == 42 namespace Test data Vec2 { var x: int, var y: int } data Entity { *Vec2, name: string } func test() -> int { var e = new Entity { Vec2: new Vec2 { x: 10, y: 20 }, name: "p" } e.x += 12 return e.x + e.y } ``` ## ILEmitterTests_Embedding__Added_ValueEmbed_DirectAccessByName (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::Added_ValueEmbed_DirectAccessByName topic: embedding status: verified // verified behavior: Test.test(...) == 7 namespace Test data Vec2 { var x: int, var y: int } data Transform { Vec2, var scale: int } func test() -> int { let t = Transform { x: 7, y: 0, scale: 1 } let v = t.Vec2 return v.x } ``` ## ILEmitterTests_Embedding__Added_OuterFieldShadowsPromoted (embedding, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Embedding.cs::Added_OuterFieldShadowsPromoted topic: embedding status: verified // verified behavior: Test.test(...) == 99 namespace Test data Base { tag: int } data Wrap { Base, tag: int } func test() -> int { let w = Wrap { Base: Base { tag: 1 }, tag: 99 } return w.tag } ``` ## ErrorPropagationTests__Question_InLetPosition_Ok (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_InLetPosition_Ok topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> Result { let x = parse(5)? return ok(x + 1) } ``` ## ErrorPropagationTests__Question_InReturnPosition_Ok (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_InReturnPosition_Ok topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> Result { return ok(parse(5)? + 1) } ``` ## ErrorPropagationTests__Question_InReturnPosition_PropagatesError (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_InReturnPosition_PropagatesError topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> Result { return ok(parse(-3)? + 1) } ``` ## ErrorPropagationTests__Question_AsBareStatement_Ok_Continues (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_AsBareStatement_Ok_Continues topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> Result { parse(5)? return ok(99) } ``` ## ErrorPropagationTests__Question_AsBareStatement_Error_Propagates (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_AsBareStatement_Error_Propagates topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> Result { parse(-1)? return ok(99) } ``` ## ErrorPropagationTests__Question_AsCallArgument (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_AsCallArgument topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func add(a: int, b: int) -> int = a + b func go() -> Result { return ok(add(parse(3)?, 100)) // 6 + 100 } ``` ## ErrorPropagationTests__Question_Nested (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_Nested topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> Result { return ok(parse(parse(3)?)?) } ``` ## ErrorPropagationTests__Question_ChainedStatements_StopAtFirstError (result, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::Question_ChainedStatements_StopAtFirstError topic: result status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> Result { parse(1)? // ok, discarded parse(-9)? // error here — propagates, the rest never runs return ok(0) } ``` ## ErrorPropagationTests__ForKV_SumsValues (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::ForKV_SumsValues topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Collections.Generic" func go() -> int { let d = Dictionary() d["a"] = 10 d["b"] = 20 d["c"] = 30 var sum = 0 for (k, v) in d { sum += v } return sum } ``` ## ErrorPropagationTests__ForKV_UsesKey (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::ForKV_UsesKey topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Collections.Generic" func go() -> int { let d = Dictionary() d["xy"] = 1 d["z"] = 1 var totalKeyLen = 0 for (k, v) in d { totalKeyLen += k.Length } return totalKeyLen } ``` ## ErrorPropagationTests__ForKV_MaxByValue (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ErrorPropagationTests.cs::ForKV_MaxByValue topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Collections.Generic" func go() -> string { let d = Dictionary() d["a"] = 3 d["b"] = 9 d["c"] = 5 var best = "" var bestN = 0 for (k, v) in d { if v > bestN { bestN = v best = k } } return best } ``` ## ILEmitterTests_AsyncParity__TaskOfT_EmitsTaskReturn (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::TaskOfT_EmitsTaskReturn topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func compute() -> Task { let x = await Task.FromResult(40) return x + 2 } ``` ## ILEmitterTests_AsyncParity__Task_Void_EmitsTaskReturn (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Task_Void_EmitsTaskReturn topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func ping() -> Task { let _ = await Task.FromResult(0) } ``` ## ILEmitterTests_AsyncParity__ValueTaskOfT_Explicit_EmitsValueTask (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::ValueTaskOfT_Explicit_EmitsValueTask topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func compute() -> ValueTask { let x = await Task.FromResult(7) return x } ``` ## ILEmitterTests_AsyncParity__ExplicitVoid_Await_EmitsAsyncVoid (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::ExplicitVoid_Await_EmitsAsyncVoid topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func handler() -> void { let _ = await Task.FromResult(0) } ``` ## ILEmitterTests_AsyncParity__OmittedReturn_Await_StaysValueTask (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::OmittedReturn_Await_StaysValueTask topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func handler() { let _ = await Task.FromResult(0) } ``` ## ILEmitterTests_AsyncParity__AsyncStream_YieldAndAwait_Streams (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::AsyncStream_YieldAndAwait_Streams topic: async status: verified // verified behavior: Test.nums(...) == 141 namespace Test func nums() -> IAsyncEnumerable { yield 1 let x = await Task.FromResult(40) yield x yield 100 } ``` ## ILEmitterTests_AsyncParity__AsyncStream_Parameterized_LoopYield_Streams (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::AsyncStream_Parameterized_LoopYield_Streams topic: async status: verified // verified behavior: Test.range(...) == 10 namespace Test func range(n: int) -> IAsyncEnumerable { var i = 0 while i < n { yield i i += 1 } } ``` ## ILEmitterTests_AsyncParity__TaskOfT_RunsAndComposesWithBcl (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::TaskOfT_RunsAndComposesWithBcl topic: async status: verified // verified behavior: Test.two(...) == 10 namespace Test func one() -> Task { let x = await Task.FromResult(4) return x + 1 } func two() -> Task { let y = await one() return y + 5 } ``` ## ILEmitterTests_AsyncParity__Added_Default_AwaitChain_Value (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_Default_AwaitChain_Value topic: async status: verified // verified behavior: Test.b(...) == 12 namespace Test func a() -> int { let x = await Task.FromResult(10) return x } func b() -> int { let y = await a() return y + 2 } ``` ## ILEmitterTests_AsyncParity__Added_TaskOfT_ReturnsTaskType (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_TaskOfT_ReturnsTaskType topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func fetch() -> Task { let x = await Task.FromResult(7) return x } ``` ## ILEmitterTests_AsyncParity__Added_NonGenericTask_Void (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_NonGenericTask_Void topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func run() -> Task { await Task.Delay(1) } ``` ## ILEmitterTests_AsyncParity__Added_ExplicitVoid_AsyncVoid (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_ExplicitVoid_AsyncVoid topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func handler() -> void { await Task.Delay(1) } ``` ## ILEmitterTests_AsyncParity__Added_DefaultAsync_IsValueTask (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_DefaultAsync_IsValueTask topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func compute() -> int { let x = await Task.FromResult(40) return x + 2 } ``` ## ILEmitterTests_AsyncParity__Added_AwaitArithmeticResult (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_AwaitArithmeticResult topic: async status: verified // verified behavior: Test.sum(...) == 15 namespace Test func sum() -> int { let a = await Task.FromResult(5) let b = await Task.FromResult(10) return a + b } ``` ## ILEmitterTests_AsyncParity__Added_TaskOfT_AwaitedToValue (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_TaskOfT_AwaitedToValue topic: async status: verified // verified behavior: Test.use(...) == 8 namespace Test func get() -> Task { let x = await Task.FromResult(8) return x } func use() -> int { let v = await get() return v } ``` ## ILEmitterTests_AsyncParity__Added_AwaitInsideIf (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncParity.cs::Added_AwaitInsideIf topic: async status: verified // verified behavior: Test.pick(...) == 1 namespace Test func pick(b: bool) -> int { if b { let x = await Task.FromResult(1) return x } return 0 } ``` ## ILEmitterTests_Interpolation__PlainVariable (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::PlainVariable topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let x = 5 return "x={x}" } ``` ## ILEmitterTests_Interpolation__TwoHoles (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::TwoHoles topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "{a} and {b}" } ``` ## ILEmitterTests_Interpolation__AdditionOperator (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::AdditionOperator topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "sum={a + b}" } ``` ## ILEmitterTests_Interpolation__SubtractionOperator (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::SubtractionOperator topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "d={a - b}" } ``` ## ILEmitterTests_Interpolation__MultiplicationOperator (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::MultiplicationOperator topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "p={a * b}" } ``` ## ILEmitterTests_Interpolation__DivisionOperator (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::DivisionOperator topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 20 let b = 4 return "q={a / b}" } ``` ## ILEmitterTests_Interpolation__ComparisonOperator (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::ComparisonOperator topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "lt={a < b}" } ``` ## ILEmitterTests_Interpolation__TernaryInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::TernaryInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "max={a > b ? a : b}" } ``` ## ILEmitterTests_Interpolation__NestedArithmetic (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::NestedArithmetic topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "r={a + b + b + b - 1 + 4 - 2 - 1}" } ``` ## ILEmitterTests_Interpolation__CallInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::CallInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func dbl(x: int) -> int = x * 2 func go() -> string { return "dbl={dbl(5)}" } ``` ## ILEmitterTests_Interpolation__MemberChainInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::MemberChainInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) data P { name: string } func go() -> string { let p = P { name: "kae" } return "n={p.name}" } ``` ## ILEmitterTests_Interpolation__IndexInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::IndexInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let xs = [10, 20, 30] return "first={xs[0]}" } ``` ## ILEmitterTests_Interpolation__StringHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::StringHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let who = "bob" return "hi {who}" } ``` ## ILEmitterTests_Interpolation__BoolHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::BoolHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let f = true return "flag={f}" } ``` ## ILEmitterTests_Interpolation__DoubleHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::DoubleHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let d = 1.5 return "v={d}" } ``` ## ILEmitterTests_Interpolation__LeadingAndTrailingText (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::LeadingAndTrailingText topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let x = 5 return "[{x}]" } ``` ## ILEmitterTests_Interpolation__AdjacentHoles (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::AdjacentHoles topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "{a}{b}" } ``` ## ILEmitterTests_Interpolation__NoHolesPlainString (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::NoHolesPlainString topic: core status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string = "plain" ``` ## ILEmitterTests_Interpolation__EmptyTextAroundSingleHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::EmptyTextAroundSingleHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let x = 9 return "{x}" } ``` ## ILEmitterTests_Interpolation__BclFormatPlaceholderStaysLiteral (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::BclFormatPlaceholderStaysLiteral topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let x = 5 return "{0} and {x}" } ``` ## ILEmitterTests_Interpolation__ChainedMemberInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::ChainedMemberInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) data Inner { v: int } data Outer { inner: Inner } func go() -> string { let o = Outer { inner: Inner { v: 7 } } return "inner={o.inner.v}" } ``` ## ILEmitterTests_Interpolation__HoleInLetThenReturn (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::HoleInLetThenReturn topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let n = 42 let s = "got {n}" return s } ``` ## ILEmitterTests_Interpolation__NegativeNumberHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::NegativeNumberHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let n = 0 - 7 return "neg={n}" } ``` ## ILEmitterTests_Interpolation__ModuloInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::ModuloInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 7 let b = 3 return "mod={a % b}" } ``` ## ILEmitterTests_Interpolation__AndOperatorInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::AndOperatorInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = true let b = true return "both={a && b}" } ``` ## ILEmitterTests_Interpolation__OrOperatorInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::OrOperatorInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = false let b = true return "any={a || b}" } ``` ## ILEmitterTests_Interpolation__ParenthesizedHole (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::ParenthesizedHole topic: core status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 3 let b = 4 return "r={(a + b) * 2}" } ``` ## ILEmitterTests_Interpolation__CallWithArgExpression (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::CallWithArgExpression topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func add(a: int, b: int) -> int = a + b func go() -> string { return "s={add(8, 12)}" } ``` ## ILEmitterTests_Interpolation__InterpolationInsideMatchArm (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::InterpolationInsideMatchArm topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let n = 2 return match n { 1 { "one:1" } 2 { "two:{n}" } default { "x" } } } ``` ## ILEmitterTests_Interpolation__MixedValueAndRefHoles (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::MixedValueAndRefHoles topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let name = "kae" let age = 30 return "{name} is {age}" } ``` ## ILEmitterTests_Interpolation__NegationUnaryInHole (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::NegationUnaryInHole topic: core status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let b = true return "not={!b}" } ``` ## ILEmitterTests_Interpolation__ThreeHolesArithmetic (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::ThreeHolesArithmetic topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let a = 1 let b = 2 return "{a}+{b}={a + b}" } ``` ## ILEmitterTests_Interpolation__Added_MemberChainHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::Added_MemberChainHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) data P { x: int } func go() -> string { let p = P { x: 5 } return "x={p.x}" } ``` ## ILEmitterTests_Interpolation__Added_PointerFieldHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::Added_PointerFieldHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) data B { n: int } func go() -> string { let b = new B { n: 7 } return "n={b.n}" } ``` ## ILEmitterTests_Interpolation__Added_CallInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::Added_CallInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func dbl(x: int) -> int = x * 2 func go() -> string { return "d={dbl(4)}" } ``` ## ILEmitterTests_Interpolation__Added_IndexInHole (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::Added_IndexInHole topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let xs = [9, 8] return "first={xs[0]}" } ``` ## ILEmitterTests_Interpolation__Added_LiteralBracesPassThrough (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Interpolation.cs::Added_LiteralBracesPassThrough topic: core status: verified // compiles cleanly (no auto-run claim was extracted) func go() -> string { return "{0}" } ``` ## ILEmitterTests_Inheritance__Sealed_Default_Emits_Sealed_Class (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Sealed_Default_Emits_Sealed_Class topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Dog { init() { } } ``` ## ILEmitterTests_Inheritance__Open_Modifier_Emits_NotSealed_NotAbstract (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Open_Modifier_Emits_NotSealed_NotAbstract topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test open ref data Animal { init() { } } ``` ## ILEmitterTests_Inheritance__Abstract_Modifier_Emits_Abstract_Class (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Abstract_Modifier_Emits_Abstract_Class topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test abstract ref data Shape { init() { } } ``` ## ILEmitterTests_Inheritance__Sealed_Explicit_Emits_Sealed_Class (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Sealed_Explicit_Emits_Sealed_Class topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test sealed ref data Cat { init() { } } ``` ## ILEmitterTests_Inheritance__Subclass_Of_Open_Class_Has_Base_Type_Set (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Subclass_Of_Open_Class_Has_Base_Type_Set topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test open ref data Animal { init() { } } ref data Dog : Animal { init() : base() { } } ``` ## ILEmitterTests_Inheritance__Subclass_Of_Abstract_Class_Has_Base_Type_Set (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Subclass_Of_Abstract_Class_Has_Base_Type_Set topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test abstract ref data Shape { init() { } } ref data Square : Shape { init() : base() { } } ``` ## ILEmitterTests_Inheritance__Subclass_With_Interface_AND_Base_Class_Reports_Both (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Subclass_With_Interface_AND_Base_Class_Reports_Both topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface INamed { func name() -> string } open ref data Animal { init() { } } ref data Dog : Animal, INamed { init() : base() { } func name() -> string = "dog" } ``` ## ILEmitterTests_Inheritance__Virtual_Func_On_Open_Class_Emits_Virtual_NewSlot (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Virtual_Func_On_Open_Class_Emits_Virtual_NewSlot topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test open ref data Animal { init() { } virtual func speak() -> string = "" } ``` ## ILEmitterTests_Inheritance__Virtual_Func_On_Sealed_Class_Reports_ES2126 (inheritance, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Virtual_Func_On_Sealed_Class_Reports_ES2126 topic: inheritance status: verified // verified behavior: reports diagnostic ES2126 namespace Test ref data Cat { init() { } virtual func meow() -> string = "meow" } ``` ## ILEmitterTests_Inheritance__Abstract_Func_On_Abstract_Class_Has_No_Body (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Abstract_Func_On_Abstract_Class_Has_No_Body topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test abstract ref data Shape { init() { } abstract func area() -> int } ``` ## ILEmitterTests_Inheritance__Abstract_Func_Outside_Abstract_Class_Reports_ES2125 (inheritance, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Abstract_Func_Outside_Abstract_Class_Reports_ES2125 topic: inheritance status: unverified // verified behavior: reports diagnostic ES2125 namespace Test open ref data Animal { init() { } abstract func voice() -> string } ``` ## ILEmitterTests_Inheritance__Colon_Func_Fulfills_Abstract_Parent (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Colon_Func_Fulfills_Abstract_Parent topic: inheritance status: verified // verified behavior: Test.go(...) == 16 namespace Test abstract ref data Shape { init() { } abstract func area() -> int } ref data Square : Shape { side: int init(s: int) : base() { self.side = s } : func area() -> int { return self.side * self.side } } func go() -> int { let s = Square(4) return s.area() } ``` ## ILEmitterTests_Inheritance__Colon_Func_Overrides_Virtual_Parent (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Colon_Func_Overrides_Virtual_Parent topic: inheritance status: verified // verified behavior: Test.go(...) == "woof" namespace Test open ref data Animal { init() { } virtual func speak() -> string = "..." } ref data Dog : Animal { init() : base() { } : func speak() -> string = "woof" } func go() -> string { let d = Dog() return d.speak() } ``` ## ILEmitterTests_Inheritance__Colon_Func_Override_Uses_ReuseSlot_VTable (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Colon_Func_Override_Uses_ReuseSlot_VTable topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test open ref data Animal { init() { } virtual func speak() -> string = "..." } ref data Dog : Animal { init() : base() { } : func speak() -> string = "woof" } ``` ## ILEmitterTests_Inheritance__Colon_Func_Without_Body_In_Concrete_Subclass_Is_ES2121 (inheritance, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Colon_Func_Without_Body_In_Concrete_Subclass_Is_ES2121 topic: inheritance status: verified // verified behavior: reports diagnostic ES2121 namespace Test abstract ref data Shape { init() { } abstract func area() -> int } ref data Square : Shape { init() : base() { } : func area() -> int } ``` ## ILEmitterTests_Inheritance__Colon_Func_With_No_Matching_Parent_Is_ES2122 (inheritance, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Colon_Func_With_No_Matching_Parent_Is_ES2122 topic: inheritance status: verified // verified behavior: reports diagnostic ES2122 namespace Test open ref data Animal { init() { } } ref data Dog : Animal { init() : base() { } : func bark() -> string = "woof" } ``` ## ILEmitterTests_Inheritance__Colon_Marker_Without_Inheritance_Header_Is_ES2124 (inheritance, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Colon_Marker_Without_Inheritance_Header_Is_ES2124 topic: inheritance status: unverified // verified behavior: reports diagnostic ES2124 namespace Test ref data Solo { init() { } : func go() -> int = 1 } ``` ## ILEmitterTests_Inheritance__Plain_Func_Shadowing_Virtual_Parent_Is_ES2120 (inheritance, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Plain_Func_Shadowing_Virtual_Parent_Is_ES2120 topic: inheritance status: verified // verified behavior: reports diagnostic ES2120 namespace Test open ref data Animal { init() { } virtual func speak() -> string = "..." } ref data Dog : Animal { init() : base() { } func speak() -> string = "woof" } ``` ## ILEmitterTests_Inheritance__Init_Calls_BaseCtor_With_Args (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Init_Calls_BaseCtor_With_Args topic: inheritance status: verified // verified behavior: Test.go(...) == "dog" namespace Test open ref data Animal { species: string init(s: string) { self.species = s } } ref data Dog : Animal { init() : base("dog") { } } func go() -> string { let d = Dog() return d.species } ``` ## ILEmitterTests_Inheritance__Init_Mismatched_BaseArgs_Is_ES2128 (inheritance, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Init_Mismatched_BaseArgs_Is_ES2128 topic: inheritance status: verified // verified behavior: reports diagnostic ES2128 namespace Test open ref data Animal { name: string init(n: string) { self.name = n } } ref data Dog : Animal { init() : base() { } } ``` ## ILEmitterTests_Inheritance__Polymorphic_Dispatch_Through_Base_Class_Reference (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Polymorphic_Dispatch_Through_Base_Class_Reference topic: inheritance status: verified // verified behavior: Test.goDog(...) == "woof" namespace Test open ref data Animal { init() { } virtual func speak() -> string = "..." } ref data Cat : Animal { init() : base() { } : func speak() -> string = "meow" } ref data Dog : Animal { init() : base() { } : func speak() -> string = "woof" } func goCat() -> string { let c = Cat() return c.speak() } func goDog() -> string { let d = Dog() return d.speak() } ``` ## ILEmitterTests_Inheritance__Two_Level_PassThrough_To_Fulfill (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Two_Level_PassThrough_To_Fulfill topic: inheritance status: verified // verified behavior: Test.run(...) == 42 namespace Test abstract ref data Top { init() { } abstract func go() -> int } abstract ref data Middle : Top { init() : base() { } } ref data Leaf : Middle { init() : base() { } : func go() -> int = 42 } func run() -> int { return Leaf().go() } ``` ## ILEmitterTests_Inheritance__Subclass_Of_Sealed_Implicitly_Fails_Cleanly (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Subclass_Of_Sealed_Implicitly_Fails_Cleanly topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Cat { init() { } } ref data Bob : Cat { init() { } } ``` ## ILEmitterTests_Inheritance__Virtual_Method_Calls_Another_Virtual_On_Same_Type (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Virtual_Method_Calls_Another_Virtual_On_Same_Type topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test open ref data Computer { init() {} virtual func step() -> int = 1 virtual func run() -> int = self.step() + self.step() } ref data Faster : Computer { init() : base() {} : func step() -> int = 10 } func test() -> int { let f = Faster() return f.run() } ``` ## ILEmitterTests_Inheritance__Base_Class_Field_Read_Through_Subclass (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Base_Class_Field_Read_Through_Subclass topic: inheritance status: verified // verified behavior: Test.test(...) == 42 namespace Test open ref data Base { pub n: int init(n: int) { self.n = n } } ref data Sub : Base { init(n: int) : base(n) {} } func test() -> int { let s = Sub(42) return s.n } ``` ## ILEmitterTests_Inheritance__Open_Class_Carries_Open_Flag_In_CLR_Metadata (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Open_Class_Carries_Open_Flag_In_CLR_Metadata topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test open ref data Animal { init() {} } ``` ## ILEmitterTests_Inheritance__Sealed_Default_Carries_Sealed_Flag_In_CLR_Metadata (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Sealed_Default_Carries_Sealed_Flag_In_CLR_Metadata topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Locked { init() {} } ``` ## ILEmitterTests_Inheritance__Added_VirtualOverride_DispatchesDerived (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Added_VirtualOverride_DispatchesDerived topic: inheritance status: verified // verified behavior: Test.go(...) == 2 namespace Test open ref data Animal { init() { } virtual func sound() -> int { return 1 } } ref data Dog : Animal { init() : base() { } : func sound() -> int { return 2 } } func go() -> int { // Base-typed local holding a derived instance — callvirt dispatches to Dog. var a: Animal = Dog() return a.sound() } ``` ## ILEmitterTests_Inheritance__Added_BaseCall_PassesArgs (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Added_BaseCall_PassesArgs topic: inheritance status: verified // verified behavior: Test.go(...) == "dog" namespace Test open ref data Animal { species: string init(s: string) { self.species = s } } ref data Dog : Animal { name: string init(n: string) : base("dog") { self.name = n } } func go() -> string { let d = Dog("rex") return d.species } ``` ## ILEmitterTests_Inheritance__Added_InheritedFieldResolves (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Added_InheritedFieldResolves topic: inheritance status: verified // verified behavior: Test.go(...) == 42 namespace Test open ref data Base { n: int init(n: int) { self.n = n } } ref data Derived : Base { init() : base(42) { } } func go() -> int { let d = Derived() return d.n } ``` ## ILEmitterTests_Inheritance__Added_VirtualNotOverridden_UsesBase (inheritance, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Added_VirtualNotOverridden_UsesBase topic: inheritance status: verified // verified behavior: Test.go(...) == 4 namespace Test open ref data Animal { init() { } virtual func legs() -> int { return 4 } } ref data Snake : Animal { init() : base() { } } func go() -> int { // Snake doesn't override legs(): callvirt resolves to Animal's base body. var a: Animal = Snake() return a.legs() } ``` ## ILEmitterTests_Inheritance__Added_Abstract_NotInstantiable_IsAbstractFlag (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Inheritance.cs::Added_Abstract_NotInstantiable_IsAbstractFlag topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test abstract ref data Shape { init() { } abstract func area() -> int } ``` ## ILEmitterTests_Coverage_Choice__ValueChoice_MatchZeroPayload (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::ValueChoice_MatchZeroPayload topic: choice status: verified // verified behavior: Test.go(...) == 2 namespace Test choice Color { red green blue } func code(c: Color) -> int { match (c: Color) { .red { return 1 } .green { return 2 } .blue { return 3 } } return 0 } func go() -> int { return code(Color.green()) } ``` ## ILEmitterTests_Coverage_Choice__ValueChoice_SinglePayload (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::ValueChoice_SinglePayload topic: choice status: verified // verified behavior: Test.go(...) == 25 namespace Test choice Shape { circle(radius: int) square(side: int) } func area(s: Shape) -> int { match (s: Shape) { .circle(r) { return 3 * r * r } .square(side) { return side * side } } return 0 } func go() -> int { return area(Shape.square(5)) } ``` ## ILEmitterTests_Coverage_Choice__ValueChoice_MultiPayload (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::ValueChoice_MultiPayload topic: choice status: verified // verified behavior: Test.go(...) == 207 namespace Test choice Entry { log(level: int, code: int) blank } func score(e: Entry) -> int { match (e: Entry) { .log(lvl, code) { return lvl * 100 + code } .blank { return 0 } } return -1 } func go() -> int { return score(Entry.log(2, 7)) } ``` ## ILEmitterTests_Coverage_Choice__RefChoice_RecursiveEval (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::RefChoice_RecursiveEval topic: choice status: verified // verified behavior: Test.go(...) == 23 namespace Test ref choice Expr { lit(value: int) add(left: Expr, right: Expr) mul(left: Expr, right: Expr) } func eval(e: Expr) -> int { match (e: Expr) { .lit(v) { return v.value } .add(a) { return eval(a.left) + eval(a.right) } .mul(m) { return eval(m.left) * eval(m.right) } } return 0 } func go() -> int { let tree = Expr.add(Expr.lit(3), Expr.mul(Expr.lit(4), Expr.lit(5))) return eval(tree) } ``` ## ILEmitterTests_Coverage_Choice__RefChoice_PositionalMultiPayloadBinding (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::RefChoice_PositionalMultiPayloadBinding topic: choice status: verified // verified behavior: Test.go(...) == 23 namespace Test ref choice Expr { lit(value: int) add(left: Expr, right: Expr) mul(left: Expr, right: Expr) } func eval(e: Expr) -> int { match (e: Expr) { .lit(v) { return v.value } .add(l, r) { return eval(l) + eval(r) } .mul(l, r) { return eval(l) * eval(r) } } return 0 } func go() -> int { let tree = Expr.add(Expr.lit(3), Expr.mul(Expr.lit(4), Expr.lit(5))) return eval(tree) } ``` ## ILEmitterTests_Coverage_Choice__Enum_ExplicitAndAutoValues (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::Enum_ExplicitAndAutoValues topic: choice status: verified // verified behavior: Test.go(...) == 21 namespace Test enum Level { a b = 10 c } func rank(l: Level) -> int { match (l: Level) { .a { return 0 } .b { return 10 } .c { return 11 } } return -1 } func go() -> int { return rank(Level.a()) + rank(Level.b()) + rank(Level.c()) } ``` ## ILEmitterTests_Coverage_Choice__Match_LiteralInt (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::Match_LiteralInt topic: choice status: verified // verified behavior: Test.go(...) == 2 namespace Test func classify(n: int) -> int { match n { 200 { return 1 } 404 { return 2 } 500 { return 3 } default { return 0 } } } func go() -> int { return classify(404) + classify(999) } ``` ## ILEmitterTests_Coverage_Choice__Match_LiteralString (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::Match_LiteralString topic: choice status: verified // verified behavior: Test.go(...) == 8 namespace Test func perm(name: string) -> int { match name { "admin" { return 7 } "guest" { return 1 } default { return 0 } } } func go() -> int { return perm("admin") + perm("guest") + perm("other") } ``` ## ILEmitterTests_Coverage_Choice__Match_AsExpression (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::Match_AsExpression topic: choice status: verified // verified behavior: Test.go(...) == 40 namespace Test func go() -> int { let status = 404 let label = match status { 200 { 1 } 404 { 4 } default { 0 } } return label * 10 } ``` ## ILEmitterTests_Coverage_Choice__Result_OkPropagation (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::Result_OkPropagation topic: result status: verified // verified behavior: Test.go(...) == 2 namespace Test func half(n: int) -> Result { if n % 2 != 0 { return error("odd") } return ok(n / 2) } func chain(n: int) -> Result { let a = half(n)? let b = half(a)? return ok(b) } func go() -> int { let r = chain(8) return r.UnwrapOr(0 - 1) } ``` ## ILEmitterTests_Coverage_Choice__Result_ErrorShortCircuits (result, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::Result_ErrorShortCircuits topic: result status: verified // verified behavior: Test.go(...) == 99 namespace Test func half(n: int) -> Result { if n % 2 != 0 { return error("odd") } return ok(n / 2) } func chain(n: int) -> Result { let a = half(n)? let b = half(a)? return ok(b) } func go() -> int { let r = chain(6) return r.IsError ? 99 : r.UnwrapOr(0) } ``` ## ILEmitterTests_Coverage_Choice__LetElse_Guard (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::LetElse_Guard topic: core status: verified // verified behavior: Test.go(...) == "ok-miss" namespace Test func find(id: int) -> string? { if id == 0 { return nil } return "ok" } func lookup(id: int) -> string { let v = find(id) else { return "miss" } return v } func go() -> string { return lookup(5) + "-" + lookup(0) } ``` ## ILEmitterTests_Coverage_Choice__Match_OnReceiverInferred (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Choice.cs::Match_OnReceiverInferred topic: choice status: verified // verified behavior: Test.go(...) == 1 namespace Test choice State { on off } data Switch { var s: State } func describe(sw: Switch) -> int { match sw.s { .on { return 1 } .off { return 0 } } return -1 } func go() -> int { let sw = Switch { s: State.on() } return sw.describe() } ``` ## ForwardReferenceTests__Data_Field_Of_LaterData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Data_Field_Of_LaterData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data A { b: B } data B { n: int } func go() -> int { let a = A { b: B { n: 7 } } return a.b.n } ``` ## ForwardReferenceTests__Data_ListField_Of_LaterData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Data_ListField_Of_LaterData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data A { bs: List } data B { n: int } func go() -> int { let xs = List() xs.Add(B { n: 1 }) xs.Add(B { n: 2 }) let a = A { bs: xs } return a.bs.Count } ``` ## ForwardReferenceTests__Data_PointerField_Of_LaterData (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Data_PointerField_Of_LaterData topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Holder { p: *Cell } data Cell { value: int } func go() -> int { let h = Holder { p: new Cell { value: 42 } } return h.p.value } ``` ## ForwardReferenceTests__Data_Field_Of_LaterChoice (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Data_Field_Of_LaterChoice topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Wrap { c: Pick } choice Pick { a(n: int) b(n: int) } func go() -> int { let w = Wrap { c: Pick.a(5) } match w.c { .a(x) { return x } .b(x) { return x } } } ``` ## ForwardReferenceTests__Data_Field_Of_LaterEnum (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Data_Field_Of_LaterEnum topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Row { d: Dir } enum Dir { north south east } func go() -> int { let r = Row { d: Dir.east() } match r.d { .north { return 0 } .south { return 1 } .east { return 2 } } } ``` ## ForwardReferenceTests__Choice_Payload_Of_LaterData (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Choice_Payload_Of_LaterData topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Box { full(p: Item) empty } data Item { weight: int } func go() -> int { let b = Box.full(Item { weight: 9 }) match b { .full(c) { return c.p.weight } .empty { return 0 } } } ``` ## ForwardReferenceTests__RefChoice_Payload_Of_LaterData (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::RefChoice_Payload_Of_LaterData topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Node { leaf branch(items: List) } data Leaf { v: int } func go() -> int { let xs = List() xs.Add(Leaf { v: 1 }) xs.Add(Leaf { v: 2 }) xs.Add(Leaf { v: 3 }) let n = Node.branch(xs) match n { .leaf { return 0 } .branch(c) { return c.items.Count } } } ``` ## ForwardReferenceTests__Data_And_RefChoice_MutualCycle (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Data_And_RefChoice_MutualCycle topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Field { key: string, value: J } ref choice J { jnull jobj(fields: List) } func go() -> int { let fs = List() fs.Add(Field { key: "a", value: J.jnull() }) fs.Add(Field { key: "b", value: J.jnull() }) let j = J.jobj(fs) match j { .jnull { return 0 } .jobj(c) { return c.fields.Count } } } ``` ## ForwardReferenceTests__Choice_Payload_Of_LaterChoice (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Choice_Payload_Of_LaterChoice topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Outer { wraps(inner: Inner) none } choice Inner { has(n: int) nothing } func go() -> int { let o = Outer.wraps(Inner.has(11)) match o { .wraps(c) { match c.inner { .has(x) { return x } .nothing { return 0 } } } .none { return 0 } } } ``` ## ForwardReferenceTests__RefData_Inherits_LaterOpenBase (inheritance, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::RefData_Inherits_LaterOpenBase topic: inheritance status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Dog : Animal { extra: int init(e: int) : base(4) { self.extra = e } } open ref data Animal { legs: int init(l: int) { self.legs = l } } func go() -> int { let d = Dog(3) return d.legs + d.extra } ``` ## ForwardReferenceTests__Data_Embeds_LaterData (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::Data_Embeds_LaterData topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Transform { Vec2 scale: int } data Vec2 { var x: int var y: int } func go() -> int { var t = Transform { x: 10, y: 20, scale: 5 } t.x += 5 return t.x + t.y + t.scale // 15 + 20 + 5 } ``` ## ForwardReferenceTests__EndToEnd_ForwardDeclared_JsonLike (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ForwardReferenceTests.cs::EndToEnd_ForwardDeclared_JsonLike topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test using "System.Text" func render(v: Val) -> string { match v { .num(c) { return "{c.value}" } .arr(c) { let sb = StringBuilder() sb.Append("[") var i = 0 while i < c.items.Count { if i > 0 { sb.Append(",") } sb.Append(render(c.items[i])) i += 1 } sb.Append("]") return sb.ToString() } } } ref choice Val { num(value: int) arr(items: List) } func go() -> string { let xs = List() xs.Add(Val.num(1)) xs.Add(Val.num(2)) xs.Add(Val.num(3)) return render(Val.arr(xs)) } ``` ## ILEmitterTests__ShortFormOpcodes_SumTo_ProducesCorrectResult (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ShortFormOpcodes_SumTo_ProducesCorrectResult topic: core status: verified // verified behavior: Test.sumTo(...) == 5050 namespace Test func sumTo(n: int) -> int { var total = 0 var i = 0 while i <= n { total += i i += 1 } return total } ``` ## ILEmitterTests__ShortFormOpcodes_Abs_BranchesWork (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ShortFormOpcodes_Abs_BranchesWork topic: core status: verified // verified behavior: Test.abs(...) == 0 namespace Test func abs(x: int) -> int { if x < 0 { return 0 - x } return x } ``` ## ILEmitterTests__TailCall_RecursiveFunction_NoStackOverflow (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::TailCall_RecursiveFunction_NoStackOverflow topic: core status: verified // verified behavior: Test.countdown(...) == 0 namespace Test func countdown(n: int) -> int { if n <= 0 { return 0 } return countdown(n - 1) } ``` ## ILEmitterTests__TailCall_AccumulatorPattern (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::TailCall_AccumulatorPattern topic: core status: verified // verified behavior: Test.sumTail(...) == 50005000 namespace Test func sumTail(n: int, acc: int) -> int { if n <= 0 { return acc } return sumTail(n - 1, acc + n) } ``` ## ILEmitterTests__Struct_FieldAccess_And_Creation (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Struct_FieldAccess_And_Creation topic: data status: verified // verified behavior: Test.scale(...) == 35 namespace Test data Vec2 { x: int y: int } func scale(factor: int, v: Vec2) -> int { return v.x * factor + v.y * factor } ``` ## ILEmitterTests__Choice_FactoryMethods_CreateValidStructs (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Choice_FactoryMethods_CreateValidStructs topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Option { some(value: int) none } func makeNone() -> Option { return Option.none() } func makeSome(v: int) -> Option { return Option.some(v) } ``` ## ILEmitterTests__Choice_TagEnum_HasCorrectValues (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Choice_TagEnum_HasCorrectValues topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Color { red green blue } func makeGreen() -> Color { return Color.green() } ``` ## ILEmitterTests__FunctionPointer_Ldftn_EmitsCorrectOpcode (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::FunctionPointer_Ldftn_EmitsCorrectOpcode topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func double(x: int) -> int { return x * 2 } func getDoublePtr() -> int { let ptr = &double return 0 } ``` ## ILEmitterTests__FunctionPointer_TranspilerEmitsDelegateStar (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::FunctionPointer_TranspilerEmitsDelegateStar topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func double(x: int) -> int { return x * 2 } func getPtr() -> int { let ptr = &double return 0 } ``` ## ILEmitterTests__EntryPoint_Transpiler_EmitsMain (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::EntryPoint_Transpiler_EmitsMain topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func main() { var x = 42 } ``` ## ILEmitterTests__ExternalCall_ConsoleWriteLine_IL (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ExternalCall_ConsoleWriteLine_IL topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func main() { Console.WriteLine("hello") } ``` ## ILEmitterTests__Await_Transpiler_EmitsAsyncSignature (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Await_Transpiler_EmitsAsyncSignature topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func fetchData() -> string { let result = await Task.FromResult("hello") return result } ``` ## ILEmitterTests__Await_Parser_ParsesAwaitExpression (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Await_Parser_ParsesAwaitExpression topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func fetch() -> string { let x = await someTask() return x } ``` ## ILEmitterTests__Await_Binder_SetsHasAwait (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Await_Binder_SetsHasAwait topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func fetch() -> string { let x = await someCall() return x } ``` ## ILEmitterTests__NoAwait_Binder_HasAwaitIsFalse (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::NoAwait_Binder_HasAwaitIsFalse topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func add(a: int, b: int) -> int { return a + b } ``` ## ILEmitterTests__AsyncIL_EmitsStateMachineStruct (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::AsyncIL_EmitsStateMachineStruct topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func fetchValue() -> int { let result = await Task.FromResult(42) return result } ``` ## ILEmitterTests__AsyncIL_TaskFromResult_ProducesCorrectValue (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::AsyncIL_TaskFromResult_ProducesCorrectValue topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func getValue() -> int { let result = await Task.FromResult(42) return result } ``` ## ILEmitterTests__AsyncIL_VoidFunction_ReturnsValueTask (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::AsyncIL_VoidFunction_ReturnsValueTask topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func doWork() { await Task.Delay(1) } ``` ## ILEmitterTests__RefChoice_IL_EmitsSealedClassHierarchy (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::RefChoice_IL_EmitsSealedClassHierarchy topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Shape { circle(radius: float) rect(width: float) point } ``` ## ILEmitterTests__Closure_NoCaptureIL_EmitsDelegate (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Closure_NoCaptureIL_EmitsDelegate topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func apply(f: int, g: int) -> int { let double = func(x: int) -> int { return x * 2 } return double(f) } ``` ## ILEmitterTests__MultiPayload_Choice_FieldsAndFactory (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::MultiPayload_Choice_FieldsAndFactory topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Msg { text(from: string, body: string) ping } func makeText(f: string, b: string) -> Msg { return Msg.text(f, b) } func makePing() -> Msg { return Msg.ping() } ``` ## ILEmitterTests__Attributes_OnDataType_EmittedAsCLRAttributes (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Attributes_OnDataType_EmittedAsCLRAttributes topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [Serializable] ref data Config { name: string } ``` ## ILEmitterTests__Attributes_OnFunction_EmittedAsCLRAttributes (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Attributes_OnFunction_EmittedAsCLRAttributes topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [Obsolete] func oldMethod() -> int { return 0 } ``` ## ILEmitterTests__Protocol_EmitsInterfaceType (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Protocol_EmitsInterfaceType topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IDrawable { func draw(x: int) -> string } ``` ## ILEmitterTests__Nullable_ValueType_ResolvesToSystemNullable (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Nullable_ValueType_ResolvesToSystemNullable topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func maybe(x: int?) -> int { return 0 } ``` ## ILEmitterTests__ProtocolType_ResolvesInMethodSignature (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ProtocolType_ResolvesInMethodSignature topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface IWidget { func render() -> string } func display(w: IWidget) -> int { return 0 } ``` ## ILEmitterTests__RefChoice_DotCase_EmitsNewobj (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::RefChoice_DotCase_EmitsNewobj topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Shape { circle(radius: float) point } func makeCircle() -> Shape { return .circle(3.14) } func makePoint() -> Shape { return .point() } ``` ## ILEmitterTests__RefChoice_Match_EmitsIsinst (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::RefChoice_Match_EmitsIsinst topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Shape { circle(radius: float) point } func describe(s: Shape) -> int { match (s: Shape) { .circle(c) { return 1 } .point { return 0 } } return 0 } ``` ## ILEmitterTests__Closure_CapturedVar_MutationPropagates (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Closure_CapturedVar_MutationPropagates topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func evalWith(value: int, offset: int) -> int { var total = 0 let addTo = func(v: int) { total = total + v } addTo(value) addTo(offset) return total } ``` ## ILEmitterTests__Closure_CapturedLet_ReadsCorrectly (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Closure_CapturedLet_ReadsCorrectly topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func makeAdder(base: int) -> int { let offset = 100 let add = func(x: int) -> int { return offset + x } return add(base) } ``` ## ILEmitterTests__Nullable_NilReturn_ValueType_Runtime (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Nullable_NilReturn_ValueType_Runtime topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func tryParse(s: string) -> int? { return nil } ``` ## ILEmitterTests__Nullable_NilReturn_ReferenceType_Runtime (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Nullable_NilReturn_ReferenceType_Runtime topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func tryFind(s: string) -> string? { return nil } ``` ## ILEmitterTests__StringInterpolation_IL_Runtime (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::StringInterpolation_IL_Runtime topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func greet(name: string) -> string { return "hello {name}" } ``` ## ILEmitterTests__StringInterpolation_IntValue_IL_Runtime (interpolation, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::StringInterpolation_IntValue_IL_Runtime topic: interpolation status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func format(x: int) -> string { return "value: {x}" } ``` ## ILEmitterTests__CompoundAssignment_IL_Runtime (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::CompoundAssignment_IL_Runtime topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func accumulate(n: int) -> int { var total = 0 total += n total += n total -= 1 return total } ``` ## ILEmitterTests__ValueChoice_Match_Destructuring_IL_Runtime (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ValueChoice_Match_Destructuring_IL_Runtime topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Result { ok(value: int) err(message: string) } func check() -> int { let r = Result.ok(42) match (r: Result) { .ok(v) { return v } .err(msg) { return 0 } } return -1 } ``` ## ILEmitterTests__RefChoice_Match_Runtime (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::RefChoice_Match_Runtime topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref choice Expr { literal(value: int) neg(inner: Expr) } func eval(e: Expr) -> int { match (e: Expr) { .literal(lit) { return lit.value } .neg(n) { return 0 - eval(n.inner) } default { return 0 } } return 0 } ``` ## ILEmitterTests__Protocol_VirtualDispatch_IL_Runtime (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Protocol_VirtualDispatch_IL_Runtime topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface ISpeaker { func speak() -> string } ref data Dog : ISpeaker { name: string } func speak(d: Dog) -> string { return "woof" } func announce(s: ISpeaker) -> string { return s.speak() } ``` ## ILEmitterTests__Init_Constructor_IL_Runtime (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Init_Constructor_IL_Runtime topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Point { x: int y: int init(px: int, py: int) { x = px y = py } } func getX() -> int { let p = Point { x: 0, y: 0 } return p.x } ``` ## ILEmitterTests__DelegateInvoke_ActionVoid_IL_Runtime (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DelegateInvoke_ActionVoid_IL_Runtime topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func runCallback(x: int) -> int { var result = 0 let cb = func(v: int) { result = v * 2 } cb(x) return result } ``` ## ILEmitterTests__MultiPayload_ValueChoice_Destructuring_IL_Runtime (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::MultiPayload_ValueChoice_Destructuring_IL_Runtime topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice LogEntry { message(level: int, text: string) timestamp(epoch: int) } func getLevel() -> int { let entry = LogEntry.message(3, "hello") match (entry: LogEntry) { .message(lvl, txt) { return lvl } .timestamp(t) { return 0 } } return -1 } ``` ## ILEmitterTests__IL_Diagnostics_UnresolvedType_ReportsError (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::IL_Diagnostics_UnresolvedType_ReportsError topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func broken(x: Nonexistent) -> int { return 0 } ``` ## ILEmitterTests__GenericExternalType_List_ResolvesCorrectly (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericExternalType_List_ResolvesCorrectly topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Container { items: List } ``` ## ILEmitterTests__GenericExternalType_Dictionary_ResolvesCorrectly (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericExternalType_Dictionary_ResolvesCorrectly topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Lookup { entries: Dictionary } ``` ## ILEmitterTests__GenericExternalType_Nested_ResolvesCorrectly (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericExternalType_Nested_ResolvesCorrectly topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Nested { mapping: Dictionary> } ``` ## ILEmitterTests__GenericExternalType_UserDefinedArg_ResolvesCorrectly (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericExternalType_UserDefinedArg_ResolvesCorrectly topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Item { name: string value: int } data Bag { items: List } ``` ## ILEmitterTests__GenericExternalType_Runtime_ListAdd (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericExternalType_Runtime_ListAdd topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func run() -> int { var count = 0 count = 3 return count } ``` ## ILEmitterTests__GenericConstructorCall_Parser_ParsesCorrectly (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericConstructorCall_Parser_ParsesCorrectly topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func make() -> int { let d = Dictionary() return 0 } ``` ## ILEmitterTests__GenericConstructorCall_List_ParsesCorrectly (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericConstructorCall_List_ParsesCorrectly topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func make() -> int { let items = List() return 0 } ``` ## ILEmitterTests__GenericConstructorCall_Nested_ParsesCorrectly (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericConstructorCall_Nested_ParsesCorrectly topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func make() -> int { let m = Dictionary>() return 0 } ``` ## ILEmitterTests__GenericConstructorCall_InInit_ParsesAndBinds (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericConstructorCall_InInit_ParsesAndBinds topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Store { items: List lookup: Dictionary init() { self.items = List() self.lookup = Dictionary() } } ``` ## ILEmitterTests__GenericConstructorCall_InFunction_IL (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericConstructorCall_InFunction_IL topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func make() -> string { let d = Dictionary() return "ok" } ``` ## ILEmitterTests__StructPromotion_LargeStruct_SilentlyPromotesToClass (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::StructPromotion_LargeStruct_SilentlyPromotesToClass topic: data status: unverified // verified behavior: reports diagnostic ES2001 namespace Test data Big { a: double b: double c: double d: double e: double f: double g: double h: double i: double } ``` ## ILEmitterTests__StructPromotion_ManyRefFields_SilentlyPromotesToClass (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::StructPromotion_ManyRefFields_SilentlyPromotesToClass topic: data status: unverified // verified behavior: reports diagnostic ES2001 namespace Test data Refs { a: string b: string c: string d: int } ``` ## ILEmitterTests__StructPromotion_StoredInCollection_SilentlyPromotesToClass (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::StructPromotion_StoredInCollection_SilentlyPromotesToClass topic: data status: unverified // verified behavior: reports diagnostic ES2001 namespace Test data Item { a: double b: double c: double d: double e: double } data Container { items: List } ``` ## ILEmitterTests__StructPromotion_RefData_NoWarning (data, negative) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::StructPromotion_RefData_NoWarning topic: data status: unverified // verified behavior: reports diagnostic ES2001 namespace Test ref data Big { a: double b: double c: double d: double e: double f: double g: double h: double i: double } ``` ## ILEmitterTests__DeriveEquality_Struct_TwoEqualInstances_AreEqual (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveEquality_Struct_TwoEqualInstances_AreEqual topic: data status: verified // verified behavior: Test.go(...) == true namespace Test derive equality data Point { x: int y: int } func go() -> bool { let p1 = Point { x: 3, y: 4 } let p2 = Point { x: 3, y: 4 } return p1.Equals(p2) } ``` ## ILEmitterTests__DeriveEquality_Struct_DifferingField_AreNotEqual (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveEquality_Struct_DifferingField_AreNotEqual topic: data status: verified // verified behavior: Test.go(...) == false namespace Test derive equality data Point { x: int y: int } func go() -> bool { let p1 = Point { x: 3, y: 4 } let p2 = Point { x: 3, y: 5 } return p1.Equals(p2) } ``` ## ILEmitterTests__DeriveEquality_Struct_NoFields_AlwaysEqual (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveEquality_Struct_NoFields_AlwaysEqual topic: data status: verified // verified behavior: Test.go(...) == true namespace Test derive equality data Unit { } func go() -> bool { let a = Unit {} let b = Unit {} return a.Equals(b) } ``` ## ILEmitterTests__DeriveEquality_GetHashCode_EqualInstancesHaveEqualHash (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveEquality_GetHashCode_EqualInstancesHaveEqualHash topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test derive equality data Point { x: int y: int } ``` ## ILEmitterTests__DeriveEquality_RefData_WorksWithDifferentInstances (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveEquality_RefData_WorksWithDifferentInstances topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test derive equality ref data Config { name: string port: int init(name: string, port: int) { self.name = name self.port = port } } ``` ## ILEmitterTests__DeriveDebug_Struct_ToStringContainsFieldValues (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveDebug_Struct_ToStringContainsFieldValues topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test derive debug data Point { x: int y: int } ``` ## ILEmitterTests__DeriveDebug_NoFields_ShowsEmptyBraces (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveDebug_NoFields_ShowsEmptyBraces topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test derive debug data Marker { } ``` ## ILEmitterTests__DeriveEqualityAndDebug_Combined (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::DeriveEqualityAndDebug_Combined topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test derive equality, debug data Pair { a: int b: string } ``` ## ILEmitterTests__GenericData_Declaration_EmitsOpenGenericTypeDefinition (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericData_Declaration_EmitsOpenGenericTypeDefinition topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Pair { first: A second: B } ``` ## ILEmitterTests__GenericData_Construction_StructLiteralWithTypeArgs (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericData_Construction_StructLiteralWithTypeArgs topic: data status: verified // verified behavior: Test.makePair(...) == 7 namespace Test data Pair { first: A second: B } func makePair() -> int { let p = Pair { first: 3, second: 4 } return p.first + p.second } ``` ## ILEmitterTests__GenericData_Construction_MixedTypes (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericData_Construction_MixedTypes topic: data status: verified // verified behavior: Test.go(...) == "hello" namespace Test data Pair { first: A second: B } func go() -> string { let p = Pair { first: 42, second: "hello" } return p.second } ``` ## ILEmitterTests__GenericData_TwoInstantiations_AreDistinctAtRuntime (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericData_TwoInstantiations_AreDistinctAtRuntime topic: data status: verified // verified behavior: Test.strPair(...) == "b" namespace Test data Pair { first: A second: B } func intPair() -> int { let p = Pair { first: 10, second: 20 } return p.first } func strPair() -> string { let p = Pair { first: "a", second: "b" } return p.second } ``` ## ILEmitterTests__MultiFile_ChoiceInFileA_MatchedInFileB_Works (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::MultiFile_ChoiceInFileA_MatchedInFileB_Works topic: choice status: verified // verified behavior: Test.goSquare(...) == 36 namespace Test choice Shape { circle(r: int) square(side: int) } ``` ## ILEmitterTests__MultiFile_DuplicateDataName_ReportsDiagnostic (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::MultiFile_DuplicateDataName_ReportsDiagnostic topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Thing { a: int } ``` ## ILEmitterTests__Protocol_RefDataImpl_CalledViaProtocolParameter_DispatchesVirtually (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Protocol_RefDataImpl_CalledViaProtocolParameter_DispatchesVirtually topic: interpolation status: verified // verified behavior: Test.goCat(...) == "cat:black" namespace Test interface INamed { func getName() -> string } ref data Dog : INamed { breed: string init(breed: string) { self.breed = breed } } func getName(self: Dog) -> string { return "dog:{self.breed}" } ref data Cat : INamed { color: string init(color: string) { self.color = color } } func getName(self: Cat) -> string { return "cat:{self.color}" } func describe(n: INamed) -> string { return n.getName() } func goDog() -> string { let d = Dog("lab") return describe(d) } func goCat() -> string { let c = Cat("black") return describe(c) } ``` ## ILEmitterTests__Protocol_AcrossFiles_DeclaredInA_ImplInB_UsedInC (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Protocol_AcrossFiles_DeclaredInA_ImplInB_UsedInC topic: core status: verified // verified behavior: Test.go(...) == 25 namespace Test interface IShape { func area() -> int } ``` ## ILEmitterTests__MultiFile_DistinctNamespaces_CoexistInOneAssembly (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::MultiFile_DistinctNamespaces_CoexistInOneAssembly topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Alpha func a() -> int { return 1 } ``` ## ILEmitterTests__Chan_Buffered_Creation_ReturnsRuntimeChan (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Chan_Buffered_Creation_ReturnsRuntimeChan topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func make() -> Chan { let ch = chan(4) return ch } ``` ## ILEmitterTests__Chan_Unbuffered_Creation_DefaultsToZeroCapacity (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Chan_Unbuffered_Creation_DefaultsToZeroCapacity topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func make() -> Chan { let ch = chan(0) return ch } ``` ## ILEmitterTests__Chan_SendAndTryReceive_SynchronousRoundTrip (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Chan_SendAndTryReceive_SynchronousRoundTrip topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func echo(x: int) -> bool { let ch = chan(1) ch.Send(x) return true } ``` ## ILEmitterTests__Spawn_SimpleJob_RunsAndJoinsCleanly (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Spawn_SimpleJob_RunsAndJoinsCleanly topic: core status: verified // verified behavior: Test.run(...) == 7 namespace Test func run() -> int { let j = spawn { let x = 1 } j.Join() return 7 } ``` ## ILEmitterTests__Spawn_WithChanCapture_ProducerConsumer (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Spawn_WithChanCapture_ProducerConsumer topic: async status: verified // verified behavior: Test.run(...) == 6 namespace Test func run() -> int { let ch = chan(4) let producer = spawn { ch.Send(1) ch.Send(2) ch.Send(3) ch.Close() } producer.Join() var total = 0 for v in ch { total += v } return total } ``` ## ILEmitterTests__Chan_OfUserChoice_ParameterSendFromArg (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Chan_OfUserChoice_ParameterSendFromArg topic: async status: verified // verified behavior: Test.run(...) == 7 namespace Test choice Evt { ping(n: int) done } func run() -> int { let feed = chan(8) feed.Send(Evt.ping(5)) feed.Close() return 7 } ``` ## ILEmitterTests__Spawn_CapturesChanOfUserChoice_CallsHelper (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Spawn_CapturesChanOfUserChoice_CallsHelper topic: async status: verified // verified behavior: Test.run(...) == 7 namespace Test choice Evt { ping(n: int) done } func produce(ch: chan) { ch.Send(Evt.ping(1)) ch.Send(Evt.ping(2)) ch.Close() } func run() -> int { let feed = chan(8) let job = spawn { produce(feed) } job.Join() return 7 } ``` ## ILEmitterTests__Spawn_CallsHelperWithCapturedChan (async, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Spawn_CallsHelperWithCapturedChan topic: async status: verified // verified behavior: Test.run(...) == 6 namespace Test func send3(ch: chan) { ch.Send(1) ch.Send(2) ch.Send(3) ch.Close() } func run() -> int { let ch = chan(4) let producer = spawn { send3(ch) } producer.Join() var total = 0 for v in ch { total += v } return total } ``` ## ILEmitterTests__Select_WithDefault_NoneReady_TakesDefault (async, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Select_WithDefault_NoneReady_TakesDefault topic: async status: unverified // verified behavior: Test.run(...) == 99 namespace Test func run() -> int { let ch = chan(1) var fired = 0 select { .recv(v, ch) { fired = 1 } default { fired = 99 } } return fired } ``` ## ILEmitterTests__Select_WithDefault_OneReady_TakesThatArm (async, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Select_WithDefault_OneReady_TakesThatArm topic: async status: unverified // verified behavior: Test.run(...) == 42 namespace Test func run() -> int { let ch = chan(1) ch.Send(42) var got = 0 select { .recv(v, ch) { got = v } default { got = 99 } } return got } ``` ## ILEmitterTests__Property_GetFromBclObject_ListCount (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Property_GetFromBclObject_ListCount topic: core status: verified // verified behavior: Test.run(...) == 3 namespace Test func run() -> int { let list = List() list.Add(1) list.Add(2) list.Add(3) return list.Count } ``` ## ILEmitterTests__Property_GetFromBclObject_StringLength (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Property_GetFromBclObject_StringLength topic: core status: verified // verified behavior: Test.run(...) == 5 namespace Test func run() -> int { let s = "hello" return s.Length } ``` ## ILEmitterTests__Property_SetOnBclObject_StringBuilderCapacity (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Property_SetOnBclObject_StringBuilderCapacity topic: interop status: verified // verified behavior: Test.run(...) == 128 namespace Test func run() -> int { let sb = StringBuilder() sb.Capacity = 128 return sb.Capacity } ``` ## ILEmitterTests__Indexer_ListGetSet_RoundTrip (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Indexer_ListGetSet_RoundTrip topic: core status: verified // verified behavior: Test.run(...) == 99 namespace Test func run() -> int { let list = List() list.Add(10) list.Add(20) list.Add(30) list[1] = 99 return list[1] } ``` ## ILEmitterTests__Indexer_DictionaryGetSet_StringIntRoundTrip (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Indexer_DictionaryGetSet_StringIntRoundTrip topic: interop status: verified // verified behavior: Test.run(...) == 185 namespace Test func run() -> int { let scores = Dictionary() scores["alice"] = 100 scores["bob"] = 85 return scores["alice"] + scores["bob"] } ``` ## ILEmitterTests__Extension_LinqCount_OnList (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Extension_LinqCount_OnList topic: core status: verified // verified behavior: Test.run(...) == 3 namespace Test func run() -> int { let nums = List() nums.Add(1) nums.Add(2) nums.Add(3) return nums.Count() } ``` ## ILEmitterTests__Default_IntIsZero (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Default_IntIsZero topic: core status: verified // verified behavior: Test.run(...) == 0 namespace Test func run() -> int { let x = default(int) return x } ``` ## ILEmitterTests__Default_StructZeroed (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Default_StructZeroed topic: data status: verified // verified behavior: Test.run(...) == 0 namespace Test data P { x: int y: int } func run() -> int { let p = default(P) return p.x + p.y } ``` ## ILEmitterTests__Default_BoolIsFalse (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Default_BoolIsFalse topic: core status: verified // verified behavior: Test.run(...) == false namespace Test func run() -> bool { let b = default(bool) return b } ``` ## ILEmitterTests__Out_IntTryParse_Success (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Out_IntTryParse_Success topic: core status: verified // verified behavior: Test.run(...) == 42 namespace Test func run() -> int { if int.TryParse("42", out var n) { return n } return -1 } ``` ## ILEmitterTests__Out_IntTryParse_Failure (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Out_IntTryParse_Failure topic: core status: verified // verified behavior: Test.run(...) == -1 namespace Test func run() -> int { if int.TryParse("not a number", out var n) { return n } return -1 } ``` ## ILEmitterTests__Out_DictionaryTryGetValue (interop, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Out_DictionaryTryGetValue topic: interop status: verified // verified behavior: Test.run(...) == 100 namespace Test func run() -> int { let scores = Dictionary() scores["alice"] = 100 if scores.TryGetValue("alice", out var score) { return score } return -1 } ``` ## ILEmitterTests__GenericCall_EnumerableCountOnList (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericCall_EnumerableCountOnList topic: core status: verified // verified behavior: Test.run(...) == 2 namespace Test func run() -> int { let nums = List() nums.Add(10) nums.Add(20) return Enumerable.Count(nums) } ``` ## ILEmitterTests__GenericCall_InferenceStillWorks (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericCall_InferenceStillWorks topic: core status: verified // verified behavior: Test.run(...) == 6 namespace Test func run() -> int { let nums = List() nums.Add(1) nums.Add(2) nums.Add(3) return nums.Sum() } ``` ## ILEmitterTests__Params_StringFormat_TwoArgs (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Params_StringFormat_TwoArgs topic: core status: verified // verified behavior: Test.run(...) == "1 + 2 = 3" namespace Test func run() -> string { return string.Format("{0} + {1} = {2}", 1, 2, 3) } ``` ## ILEmitterTests__Params_StringFormat_NoExtraArgs (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Params_StringFormat_NoExtraArgs topic: core status: verified // verified behavior: Test.run(...) == "hello world" namespace Test func run() -> string { return string.Format("hello {0}", "world") } ``` ## ILEmitterTests__Attribute_ObsoleteWithMessage_EmittedOntoType (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Attribute_ObsoleteWithMessage_EmittedOntoType topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test [Obsolete("do not use")] data Legacy { value: int } func run() -> int { return 0 } ``` ## ILEmitterTests__Event_Subscribe_ObservableCollectionCollectionChanged (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Event_Subscribe_ObservableCollectionCollectionChanged topic: core status: verified // verified behavior: Test.run(...) == 2 namespace Test func run() -> int { var fired = 0 let coll = ObservableCollection() coll.CollectionChanged += func(sender: object, args: NotifyCollectionChangedEventArgs) -> void { fired = fired + 1 } coll.Add(10) coll.Add(20) return fired } ``` ## ILEmitterTests__Try_CatchSpecificException_FormatException (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Try_CatchSpecificException_FormatException topic: core status: verified // verified behavior: Test.run(...) == -1 namespace Test func run() -> int { var result = 0 try { result = int.Parse("not a number") } catch (FormatException e) { result = -1 } return result } ``` ## ILEmitterTests__Try_CatchAll_BareCatch (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Try_CatchAll_BareCatch topic: core status: verified // verified behavior: Test.run(...) == 42 namespace Test func run() -> int { var result = 0 try { result = int.Parse("nope") } catch { result = 42 } return result } ``` ## ILEmitterTests__Try_BodyRunsWithoutException (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Try_BodyRunsWithoutException topic: core status: verified // verified behavior: Test.run(...) == 100 namespace Test func run() -> int { var result = 0 try { result = int.Parse("100") } catch (Exception e) { result = -1 } return result } ``` ## ILEmitterTests__Throw_Simple_InvalidOperation (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Throw_Simple_InvalidOperation topic: core status: verified // verified behavior: Test.run(...) == 99 namespace Test func run() -> int { var result = 0 try { throw InvalidOperationException("bad") } catch (Exception e) { result = 99 } return result } ``` ## ILEmitterTests__LetField_IsEmittedAsInitOnly (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::LetField_IsEmittedAsInitOnly topic: data status: verified // verified behavior: Test.make(...) == 3 namespace Test data Point { let x: int var y: int } func make() -> int { let p = Point { x: 1, y: 2 } return p.x + p.y } ``` ## ILEmitterTests__ReadonlyData_AllFieldsInitOnly (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ReadonlyData_AllFieldsInitOnly topic: data status: verified // verified behavior: Test.make(...) == 7.0f namespace Test readonly data Vec2 { x: float y: float } func make() -> float { let v = Vec2 { x: 3.0, y: 4.0 } return v.x + v.y } ``` ## ILEmitterTests__ReadonlyData_HasIsReadOnlyAttribute (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ReadonlyData_HasIsReadOnlyAttribute topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test readonly data Pt { x: int y: int } func make() -> int { return 0 } ``` ## ILEmitterTests__LetField_AssignmentOutsideInit_ReportsError (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::LetField_AssignmentOutsideInit_ReportsError topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test data Point { let x: int y: int } func bad() -> int { var p = Point { x: 1, y: 2 } p.x = 99 return p.x } ``` ## ILEmitterTests__LocalLet_Reassignment_ReportsError (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::LocalLet_Reassignment_ReportsError topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func bad() -> int { let x = 1 x = 2 return x } ``` ## ILEmitterTests__With_CopyAndOverwrite_ProducesNewValue (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::With_CopyAndOverwrite_ProducesNewValue topic: data status: verified // verified behavior: Test.run(...) == 14 namespace Test data Point { x: int y: int } func run() -> int { let p = Point { x: 3, y: 4 } let q = p with { x: 10 } return q.x + q.y } ``` ## ILEmitterTests__With_DoesNotMutateOriginal (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::With_DoesNotMutateOriginal topic: data status: verified // verified behavior: Test.run(...) == 3 namespace Test data Point { x: int y: int } func run() -> int { let p = Point { x: 3, y: 4 } let q = p with { x: 10 } return p.x } ``` ## ILEmitterTests__With_OnReadonlyData_Works (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::With_OnReadonlyData_Works topic: data status: verified // verified behavior: Test.run(...) == 100 namespace Test readonly data Vec { x: int y: int } func run() -> int { let v = Vec { x: 1, y: 2 } let w = v with { y: 99 } return w.x + w.y } ``` ## ILEmitterTests__With_OnRefData_ReportsError (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::With_OnRefData_ReportsError topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Node { value: int } func run() -> int { let n = Node { value: 1 } let m = n with { value: 2 } return m.value } ``` ## ILEmitterTests__Result_OkAndError_RoundTrips (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Result_OkAndError_RoundTrips topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func getOk() -> Result { return ok(42) } func getErr() -> Result { return error("bad") } ``` ## ILEmitterTests__TryUnwrap_PropagatesError (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::TryUnwrap_PropagatesError topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func inner() -> Result { return error("fail") } func outer() -> Result { let x = inner()? return ok(x + 1) } ``` ## ILEmitterTests__TryUnwrap_UnwrapsOk (result, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::TryUnwrap_UnwrapsOk topic: result status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func inner() -> Result { return ok(10) } func outer() -> Result { let x = inner()? return ok(x + 1) } ``` ## ILEmitterTests__ByRef_MutatesThroughPointer (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ByRef_MutatesThroughPointer topic: core status: verified // verified behavior: Test.run(...) == 15 namespace Test func addTen(x: *int) { x += 10 } func run() -> int { var n = 5 addTen(*n) return n } ``` ## ILEmitterTests__LetElse_ReturnsOnNull (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::LetElse_ReturnsOnNull topic: core status: verified // verified behavior: Test.runFound(...) == "found" namespace Test func tryFind(key: string) -> string? { if key == "a" { return "found" } return nil } func run() -> string { let value = tryFind("b") else { return "default" } return value } func runFound() -> string { let value = tryFind("a") else { return "default" } return value } ``` ## ILEmitterTests__Ternary_BasicConditional (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Ternary_BasicConditional topic: core status: verified // verified behavior: Test.pick(...) == 99 namespace Test func abs(x: int) -> int { return x >= 0 ? x : 0 - x } func pick(flag: bool) -> int { return flag ? 42 : 99 } ``` ## ILEmitterTests__Parse_TupleTypeInGeneric (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_TupleTypeInGeneric topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func test() -> int { var tasks = List>() return tasks.Count } ``` ## ILEmitterTests__Parse_ExprBodiedWithLock (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_ExprBodiedWithLock topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Foo { x: int lock: object init() { self.x = 0 self.lock = object() } func getX() -> int = self.x } ``` ## ILEmitterTests__PositionalData_FieldAccess (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::PositionalData_FieldAccess topic: data status: verified // verified behavior: Test.make(...) == 42 namespace Test data Item(name: string, value: int) func make() -> int { let a = Item("hello", 42) return a.value } ``` ## ILEmitterTests__TupleReturn_WithListElements (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::TupleReturn_WithListElements topic: core status: verified // verified behavior: Test.test(...) == 2 namespace Test func split() -> (List, List) { var nums = List() var strs = List() nums.Add(1) strs.Add("a") return (nums, strs) } func test() -> int { let (nums, strs) = split() return nums.Count + strs.Count } ``` ## ILEmitterTests__RefData_ExprBodiedMethod (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::RefData_ExprBodiedMethod topic: data status: verified // verified behavior: Test.test(...) == 2 namespace Test ref data Bag { items: List init() { self.items = List() } func count() -> int = self.items.Count func add(x: int) { self.items.Add(x) } } func test() -> int { let b = Bag() b.add(10) b.add(20) return b.count() } ``` ## ILEmitterTests__Ternary_WithNullCoalescing (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Ternary_WithNullCoalescing topic: core status: verified // verified behavior: Test.test(...) == 5 namespace Test func test() -> int { let a = 5 > 0 ? 5 : 0 let s = nil ?? "fallback" return a } ``` ## ILEmitterTests__Tuple_ReturnAndDestructure (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Tuple_ReturnAndDestructure topic: core status: verified // verified behavior: Test.test(...) == 21 namespace Test func swap(a: int, b: int) -> (int, int) { return (b, a) } func test() -> int { let (x, y) = swap(1, 2) return x * 10 + y } ``` ## ILEmitterTests__Tuple_TwoElements (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Tuple_TwoElements topic: core status: verified // verified behavior: Test.getFirst(...) == 42 namespace Test func pair(a: int, b: string) -> (int, string) { return (a, b) } func getFirst() -> int { let (x, y) = pair(42, "hello") return x } ``` ## ILEmitterTests__RefDataMethods_BasicInstanceMethod (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::RefDataMethods_BasicInstanceMethod topic: data status: verified // verified behavior: Test.run(...) == 3 namespace Test ref data Counter { value: int init() { self.value = 0 } func inc() { self.value += 1 } func get() -> int = self.value } func run() -> int { let c = Counter() c.inc() c.inc() c.inc() return c.get() } ``` ## ILEmitterTests__RefDataMethods_PubMethod (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::RefDataMethods_PubMethod topic: data status: verified // verified behavior: Test.run(...) == "world" namespace Test ref data Greeter { name: string init(n: string) { self.name = n } pub func greet() -> string = self.name } func run() -> string { let g = Greeter("world") return g.greet() } ``` ## ILEmitterTests__ListLiteral_IntElements (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ListLiteral_IntElements topic: core status: verified // verified behavior: Test.first(...) == 42 namespace Test func count() -> int { let xs = [10, 20, 30] return xs.Count } func first() -> int { let xs = [42, 99] return xs[0] } ``` ## ILEmitterTests__ListLiteral_StringElements (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ListLiteral_StringElements topic: core status: verified // verified behavior: Test.joined(...) == "hello" namespace Test func joined() -> string { let xs = ["hello", "world"] return xs[0] } ``` ## ILEmitterTests__PositionalData_BasicConstruction (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::PositionalData_BasicConstruction topic: data status: verified // verified behavior: Test.makeAndSum(...) == 7 namespace Test data Vec2(x: int, y: int) func sum(v: Vec2) -> int { return v.x + v.y } func makeAndSum() -> int { let v = Vec2(3, 4) return v.sum() } ``` ## ILEmitterTests__PositionalData_RefData (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::PositionalData_RefData topic: data status: verified // verified behavior: Test.make(...) == "hello" namespace Test ref data Label(text: string, size: int) func getText(l: Label) -> string { return l.text } func make() -> string { let l = Label("hello", 12) return l.getText() } ``` ## ILEmitterTests__NullConditional_PropertyAccess (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::NullConditional_PropertyAccess topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func safeLen(s: string) -> string { return s?.Length ?? "0" } ``` ## ILEmitterTests__NullConditional_ChainedWithCoalescing (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::NullConditional_ChainedWithCoalescing topic: core status: verified // verified behavior: Test.safeLen(...) == 5 namespace Test func safeLen(s: string) -> int { let result = s ?? "" return result.Length } func withCoalesce(s: string) -> string { return s ?? "none" } ``` ## ILEmitterTests__NullCoalescing_StringFallback (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::NullCoalescing_StringFallback topic: core status: verified // verified behavior: Test.fallback(...) == "hello" namespace Test func fallback(s: string) -> string { return s ?? "default" } ``` ## ILEmitterTests__ExpressionBodied_SimpleReturn (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ExpressionBodied_SimpleReturn topic: core status: verified // verified behavior: Test.always42(...) == 42 namespace Test func double(x: int) -> int = x * 2 func negate(x: int) -> int = 0 - x func always42() -> int = 42 ``` ## ILEmitterTests__Ternary_InExpression (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Ternary_InExpression topic: core status: verified // verified behavior: Test.clamp(...) == 10 namespace Test func clamp(x: int, lo: int, hi: int) -> int { let v = x < lo ? lo : x return v > hi ? hi : v } ``` ## ILEmitterTests__Parse_LambdaWithComplexGenericReturnType (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_LambdaWithComplexGenericReturnType topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T func run() { var xs = List, List)>>() xs.Add(Task.Run(func() -> (List, List) { return (List(), List()) })) } ``` ## ILEmitterTests__Parse_ForTupleDestructuring (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_ForTupleDestructuring topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace T func run() { let results = List<(int, int)>() for (a, b) in results { let x = a + b } } ``` ## ILEmitterTests__Parse_RefDataWithMultipleMethods (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_RefDataWithMultipleMethods topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T ref data Svc { items: List obj: object init() { self.items = List() self.obj = object() } func start() { self.items.Add("a") } func stop() { self.items.Clear() } func query(filter: string) -> List { return self.items } func count() -> int = self.items.Count func addItem(s: string) = self.items.Add(s) } ``` ## ILEmitterTests__Parse_LambdaInsideMethodCallChain (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_LambdaInsideMethodCallChain topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T func run() { let items = List() for item in items.Where(func(s: string) -> bool { return s != "" }).ToList() { let x = item } } ``` ## ILEmitterTests__Parse_NullConditionalAndCoalesceInTernary (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_NullConditionalAndCoalesceInTernary topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace T func run() { let s: string = nil let x = s?.Length ?? 0 let y = x > 0 ? s : "default" } ``` ## ILEmitterTests__Parse_TryCatchWithTypedBinding (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_TryCatchWithTypedBinding topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace T func run() { try { let x = 1 } catch (Exception ex) { let msg = ex.Message } } ``` ## ILEmitterTests__Emit_RefDataWithMethodsAndLambdas (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Emit_RefDataWithMethodsAndLambdas topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace T data Config(name: string, url: string) ref data Aggregator { configs: List count: int init() { self.configs = List() self.count = 0 } func getCount() -> int = self.count func addConfig(name: string, url: string) = self.configs.Add(Config(name, url)) } ``` ## ILEmitterTests__Emit_LambdaWithTupleReturnType (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Emit_LambdaWithTupleReturnType topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T func run() { var tasks = List, List)>>() tasks.Add(Task.Run(func() -> (List, List) { return (List(), List()) })) } ``` ## ILEmitterTests__Emit_AsyncFunctionWithAwait (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Emit_AsyncFunctionWithAwait topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T func fetch() -> Task { let client = HttpClient() let result = await client.GetStringAsync("http://example.com") return result } ``` ## ILEmitterTests__Emit_ComplexRefDataWithAsyncAndLambdas (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Emit_ComplexRefDataWithAsyncAndLambdas topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T func work() -> (List, List) { var items = List() var errors = List() return (items, errors) } func run() { var tasks = List, List)>>() tasks.Add(Task.Run(func() -> (List, List) { return work() })) let results = await Task.WhenAll(tasks.ToArray()) } ``` ## ILEmitterTests__Bind_RefDataWithMethodsAndLambdas (interop, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Bind_RefDataWithMethodsAndLambdas topic: interop status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T using "System.Net.Http" data Config(name: string, url: string) data Item(title: string, source: string) ref data Aggregator { configs: List items: List client: HttpClient init() { self.configs = List() self.items = List() self.client = HttpClient() } func start() { self.poll() } func poll() { var tasks = List, List)>>() for cfg in self.configs { let c = self.client let f = cfg tasks.Add(Task.Run(func() -> (List, List) { return (List(), List()) })) } } func query(filter: string, limit: int) -> List { var result = self.items if filter != "" { result = result.Where(func(n: Item) -> bool { return n.source == filter }).ToList() } return result.Take(limit > 0 ? limit : 50).ToList() } func count() -> int = self.items.Count func addConfig(name: string, url: string) = self.configs.Add(Config(name, url)) } ``` ## ILEmitterTests__Parse_InterfaceImplementation (data, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_InterfaceImplementation topic: data status: unverified // compiles cleanly (no auto-run claim was extracted) namespace T ref data MyPlugin : IPlugin { init() { } pub func Name() -> string = "test" pub func Run(app: WebApplication) { app.MapGet("/api/test", func(q: string) -> IResult { return Results.Json(q ?? "") }) app.MapGet("/api/ping", func() -> IResult = Results.Json("pong")) } } ``` ## ILEmitterTests__Parse_ImportStaticAndArrowLambda (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::Parse_ImportStaticAndArrowLambda topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace T using static "System.Math" func run() -> double { return Max(1.0, ((x) => x + 2.0)(3.0)) } ``` ## ILEmitterTests__GenericTypeWithTupleArg_NoStackOverflow (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::GenericTypeWithTupleArg_NoStackOverflow topic: core status: verified // verified behavior: Test.run(...) == 0 namespace Test func run() -> int { var xs = List<(int, int)>() return xs.Count } ``` ## ILEmitterTests__NestedGenericWithTupleArg_NoStackOverflow (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::NestedGenericWithTupleArg_NoStackOverflow topic: core status: verified // verified behavior: Test.run(...) == 0 namespace Test func run() -> int { var xs = List<(List, List)>() return xs.Count } ``` ## ILEmitterTests__ExpressionBodiedMethodInRefData (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::ExpressionBodiedMethodInRefData topic: data status: verified // verified behavior: Test.run(...) == 21 namespace Test ref data Box { value: int init(v: int) { self.value = v } func get() -> int = self.value func doubled() -> int = self.value * 2 } func run() -> int { let b = Box(7) return b.get() + b.doubled() } ``` ## ILEmitterTests__VoidExpressionBodiedMethodInRefData (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests.cs::VoidExpressionBodiedMethodInRefData topic: data status: verified // verified behavior: Test.run(...) == 2 namespace Test ref data Bag { items: List init() { self.items = List() } func add(x: int) = self.items.Add(x) func count() -> int = self.items.Count } func run() -> int { let b = Bag() b.add(10) b.add(20) return b.count() } ``` ## MixedLanguageTests__CSharp_Class_Field_Read_From_Esharp_Function (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Class_Field_Read_From_Esharp_Function topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func sum(v: Vec) -> int = v.X + v.Y ``` ## MixedLanguageTests__CSharp_Instance_Method_Called_From_Esharp (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Instance_Method_Called_From_Esharp topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func describe(g: Greeter) -> string = g.Hello("world") ``` ## MixedLanguageTests__CSharp_Static_Method_Called_From_Esharp (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Static_Method_Called_From_Esharp topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func double_it(x: int) -> int = MathHelper.Twice(x) ``` ## MixedLanguageTests__CSharp_Property_Read_From_Esharp (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Property_Read_From_Esharp topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func name_of(p: Person) -> string = p.Name ``` ## MixedLanguageTests__CSharp_Class_Constructed_In_Esharp (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Class_Constructed_In_Esharp topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func make(n: int) -> Box = Box(n) func valueOf(b: Box) -> int = b.N ``` ## MixedLanguageTests__CSharp_Enum_Switch_In_Esharp (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Enum_Switch_In_Esharp topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func label(c: Color) -> string { if c == Color.Red { return "red" } if c == Color.Green { return "green" } return "other" } ``` ## MixedLanguageTests__Esharp_Func_Called_From_Csharp (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::Esharp_Func_Called_From_Csharp topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func triple(n: int) -> int = n * 3 ``` ## MixedLanguageTests__CSharp_Interface_Implemented_By_Esharp_Data (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Interface_Implemented_By_Esharp_Data topic: data status: verified // verified behavior: Test.null(...) == "greeter" namespace Test data Greeter : IDescribable {} func describe(g: Greeter) -> string = "greeter" ``` ## MixedLanguageTests__CSharp_Ctor_With_Multiple_Args_Constructed_In_Esharp (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::CSharp_Ctor_With_Multiple_Args_Constructed_In_Esharp topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func make(x: int, y: int, label: string) -> Rect = Rect(x, y, label) func area(r: Rect) -> int = r.X * r.Y ``` ## MixedLanguageTests__Esharp_Data_Type_Used_From_Csharp (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::Esharp_Data_Type_Used_From_Csharp topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test pub data Point { x: int, y: int } ``` ## MixedLanguageTests__Esharp_OutParam_BoundByCsharp_OutVar (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: MixedLanguageTests.cs::Esharp_OutParam_BoundByCsharp_OutVar topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func try_parse(input: int, out doubled: int) -> bool { doubled = input * 2 return true } ``` ## FluentChainTests__RefData_SelfReturn_ChainsOnOneLine (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FluentChainTests.cs::RefData_SelfReturn_ChainsOnOneLine topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Acc { var n: int init() { self.n = 0 } } func add(a: Acc, x: int) -> Acc { a.n += x return a } func go() -> int { let a = Acc().add(5).add(3).add(2) return a.n } ``` ## FluentChainTests__RefData_SelfReturn_MultiLineLeadingDot (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FluentChainTests.cs::RefData_SelfReturn_MultiLineLeadingDot topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Acc { var n: int init() { self.n = 0 } } func add(a: Acc, x: int) -> Acc { a.n += x return a } func go() -> int { let a = Acc() .add(5) .add(3) .add(2) return a.n } ``` ## FluentChainTests__Chain_PreservesIdentity_SameObject (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FluentChainTests.cs::Chain_PreservesIdentity_SameObject topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ref data Acc { var n: int init() { self.n = 0 } } func add(a: Acc, x: int) -> Acc { a.n += x return a } func go() -> int { let a = Acc() let b = a.add(40).add(4) return a.n + b.n // 44 + 44 — a and b are the same object } ``` ## FluentChainTests__ChainedCall_WithIfGuardedMutation (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FluentChainTests.cs::ChainedCall_WithIfGuardedMutation topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test choice Command { forward(steps: int) } ref data Turtle { var y: int var facing: int init() { self.y = 0 self.facing = 0 } } func apply(t: Turtle, cmd: Command) -> Turtle { match cmd { .forward(steps) { if t.facing == 0 { t.y += steps } } } return t } func go() -> int { let t = Turtle().apply(Command.forward(5)).apply(Command.forward(3)) return t.y } ``` ## FluentChainTests__ChainedCall_WithNestedEnumMatch_UpdatesField (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FluentChainTests.cs::ChainedCall_WithNestedEnumMatch_UpdatesField topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test enum Turn { left right } choice Command { turn(direction: Turn) } ref data Turtle { var facing: int init() { self.facing = 0 } } func apply(t: Turtle, cmd: Command) -> Turtle { match cmd { .turn(direction) { match (direction: Turn) { .left { t.facing = (t.facing + 3) % 4 } .right { t.facing = (t.facing + 1) % 4 } } } } return t } func go() -> int { let t = Turtle().apply(Command.turn(Turn.right())) return t.facing } ``` ## FluentChainTests__Turtle_FullDrive_FluentChain (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FluentChainTests.cs::Turtle_FullDrive_FluentChain topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test enum Turn { left right } choice Command { forward(steps: int) turn(direction: Turn) } ref data Turtle { var x: int var y: int var facing: int init() { self.x = 0 self.y = 0 self.facing = 0 } } func apply(t: Turtle, cmd: Command) -> Turtle { match cmd { .forward(steps) { if t.facing == 0 { t.y += steps } else if t.facing == 1 { t.x += steps } else if t.facing == 2 { t.y -= steps } else { t.x -= steps } } .turn(direction) { match (direction: Turn) { .left { t.facing = (t.facing + 3) % 4 } .right { t.facing = (t.facing + 1) % 4 } } } } return t } func go() -> int { let t = Turtle() .apply(Command.forward(5)) .apply(Command.turn(Turn.right())) .apply(Command.forward(3)) .apply(Command.turn(Turn.right())) .apply(Command.forward(2)) return t.x * 100 + t.y } ``` ## FluentChainTests__ValueData_TransformChain (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: FluentChainTests.cs::ValueData_TransformChain topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Vec { x: int, y: int } func add(v: Vec, o: Vec) -> Vec = Vec { x: v.x + o.x, y: v.y + o.y } func scaled(v: Vec, k: int) -> Vec = Vec { x: v.x * k, y: v.y * k } func go() -> int { let r = (Vec { x: 3, y: 2 }).add(Vec { x: 1, y: 4 }).scaled(4) return r.x + r.y // (4,6)*4 = (16,24) → 40 } ``` ## InterpolationBraceTests__JsonObjectBraces_WithInterpolatedField (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: InterpolationBraceTests.cs::JsonObjectBraces_WithInterpolatedField topic: interpolation status: verified // verified behavior: Test.go(...) == "{\"k\":9}" namespace Test using "System.Text" func go() -> string { let key = "k" let val = 9 let sb = StringBuilder() sb.Append("{") sb.Append("\"{key}\":{val}") sb.Append("}") return sb.ToString() } ``` ## InterpolationBraceTests__InterpolationOnlyLocal_MemberAccessInHole (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: InterpolationBraceTests.cs::InterpolationOnlyLocal_MemberAccessInHole topic: interpolation status: verified // verified behavior: Test.go(...) == "3,4" namespace Test data P { x: int, y: int } func go() -> string { let p = P { x: 3, y: 4 } return "{p.x},{p.y}" } ``` ## InterpolationBraceTests__HoleWithCall (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: InterpolationBraceTests.cs::HoleWithCall topic: interpolation status: verified // verified behavior: Test.go(...) == "squared=9" namespace Test func sq(n: int) -> int = n * n func go() -> string { return "squared={sq(3)}" } ``` ## ILEmitterTests_AsyncLetMix__AsyncUserFn_TwoPending_OkFold (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::AsyncUserFn_TwoPending_OkFold topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) func combine() -> Result { async let a = loadAsync(2) async let b = loadAsync(3) let av = a? let bv = b? return ok(av + bv) } ``` ## ILEmitterTests_AsyncLetMix__AsyncUserFn_FirstError_ShortCircuits (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::AsyncUserFn_FirstError_ShortCircuits topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) func combine() -> Result { async let a = loadAsync(5) async let b = loadAsync(0 - 1) let av = a? let bv = b? return ok(av + bv) } ``` ## ILEmitterTests_AsyncLetMix__AsyncUserFn_SingleAsyncLet (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::AsyncUserFn_SingleAsyncLet topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) func combine() -> Result { async let a = loadAsync(7) let av = a? return ok(av) } ``` ## ILEmitterTests_AsyncLetMix__AsyncUserFn_ThreePending (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::AsyncUserFn_ThreePending topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) func combine() -> Result { async let a = loadAsync(1) async let b = loadAsync(2) async let c = loadAsync(3) let av = a? let bv = b? let cv = c? return ok(av + bv + cv) } ``` ## ILEmitterTests_AsyncLetMix__ExternalAwaitable_TaskFromResult (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::ExternalAwaitable_TaskFromResult topic: async status: verified // compiles cleanly (no auto-run claim was extracted) func combine() -> int { async let a = Task.FromResult(20) async let b = Task.FromResult(22) return a + b } ``` ## ILEmitterTests_AsyncLetMix__SyncUserFn_AsyncLet_Compiles (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::SyncUserFn_AsyncLet_Compiles topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func compute(n: int) -> int = n * 2 func combine() -> int { async let a = compute(4) async let b = compute(3) return a + b } ``` ## ILEmitterTests_AsyncLetMix__QuestionPropagation_InAsync_OkPath (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::QuestionPropagation_InAsync_OkPath topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func loadAsync(n: int) -> Result { let v = await Task.FromResult(n) if v < 0 { return error("neg") } return ok(v * 10) } func run() -> Result { let r = await loadAsync(4) let v = r? return ok(v + 1) } ``` ## ILEmitterTests_AsyncLetMix__QuestionPropagation_InAsync_ErrorPath (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::QuestionPropagation_InAsync_ErrorPath topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func loadAsync(n: int) -> Result { let v = await Task.FromResult(n) if v < 0 { return error("neg") } return ok(v * 10) } func run() -> Result { let r = await loadAsync(0 - 5) let v = r? return ok(v + 1) } ``` ## ILEmitterTests_AsyncLetMix__AsyncLet_SecondError_Propagates (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::AsyncLet_SecondError_Propagates topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) func combine() -> Result { async let a = loadAsync(3) async let b = loadAsync(0 - 9) let av = a? let bv = b? return ok(av + bv) } ``` ## ILEmitterTests_AsyncLetMix__AsyncLet_ResultInterpolatedAfterUnwrap (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::AsyncLet_ResultInterpolatedAfterUnwrap topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) func combine() -> Result { async let a = loadAsync(2) async let b = loadAsync(2) let av = a? let bv = b? let total = av + bv return ok(total) } ``` ## ILEmitterTests_AsyncLetMix__PlainAwait_AsyncUserFn (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::PlainAwait_AsyncUserFn topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test ``` ## ILEmitterTests_AsyncLetMix__AsyncLet_OrderIndependentUse (async, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_AsyncLetMix.cs::AsyncLet_OrderIndependentUse topic: async status: unverified // compiles cleanly (no auto-run claim was extracted) func combine() -> Result { async let a = loadAsync(1) async let b = loadAsync(2) let bv = b? let av = a? return ok(av + bv) } ``` ## ILEmitterTests_PtrListRepro__ListCtor_Alone_Resolves (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrListRepro.cs::ListCtor_Alone_Resolves topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = List() xs.Add(5) xs.Add(10) var t = 0 for x in xs { t += x } return t } ``` ## ILEmitterTests_PtrListRepro__ListCtor_WithHeapPointerData_Resolves (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrListRepro.cs::ListCtor_WithHeapPointerData_Resolves topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Counter { var total: int } func bump(c: *Counter, n: int) { c.total += n } func go() -> int { var c: *Counter = new Counter { total: 0 } let xs = List() xs.Add(5) xs.Add(10) for x in xs { bump(c, x) } return c.total } ``` ## ILEmitterTests_PtrListRepro__ListParamAndCtor_WithHeapPointerAlias_Resolves (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrListRepro.cs::ListParamAndCtor_WithHeapPointerAlias_Resolves topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Counter { var total: int var steps: int } func bump(c: *Counter, amount: int) { c.total += amount c.steps += 1 } func addAll(c: *Counter, xs: List) -> void { for x in xs { bump(c, x) } } func go() -> int { var tally: *Counter = new Counter { total: 0, steps: 0 } let alias = tally let xs = List() xs.Add(5) xs.Add(7) xs.Add(3) addAll(tally, xs) bump(alias, 100) return tally.total + tally.steps } ``` ## ILEmitterTests_CaseView__Positional_SinglePayload_UsedBare (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::Positional_SinglePayload_UsedBare topic: choice status: unverified // verified behavior: Test.go(...) == 7 func go() -> int { let t = Token.number(7) match (t: Token) { .word(w) { return 0 } .number(n) { return n } } return -1 } ``` ## ILEmitterTests_CaseView__Positional_TwoPayloads (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::Positional_TwoPayloads topic: choice status: unverified // verified behavior: Test.go(...) == 30 func go() -> int { let p = Pair2.couple(10, 20) match (p: Pair2) { .single(x) { return x } .couple(a, b) { return a + b } } return -1 } ``` ## ILEmitterTests_CaseView__View_MultiPayload_FieldA (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_MultiPayload_FieldA topic: choice status: unverified // verified behavior: Test.go(...) == 10 func go() -> int { let p = Pair2.couple(10, 20) match (p: Pair2) { .single(x) { return x } .couple(c) { return c.a } } return -1 } ``` ## ILEmitterTests_CaseView__View_MultiPayload_FieldB (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_MultiPayload_FieldB topic: choice status: unverified // verified behavior: Test.go(...) == 20 func go() -> int { let p = Pair2.couple(10, 20) match (p: Pair2) { .single(x) { return x } .couple(c) { return c.b } } return -1 } ``` ## ILEmitterTests_CaseView__View_MultiPayload_BothFields (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_MultiPayload_BothFields topic: choice status: unverified // verified behavior: Test.go(...) == 30 func go() -> int { let p = Pair2.couple(10, 20) match (p: Pair2) { .single(x) { return x } .couple(c) { return c.a + c.b } } return -1 } ``` ## ILEmitterTests_CaseView__View_SinglePayload_FieldAccess (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_SinglePayload_FieldAccess topic: choice status: unverified // verified behavior: Test.go(...) == 9 func go() -> int { let p = Pair2.single(9) match (p: Pair2) { .single(s) { return s.x } .couple(c) { return 0 } } return -1 } ``` ## ILEmitterTests_CaseView__View_SinglePayload_BareUse (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_SinglePayload_BareUse topic: choice status: unverified // verified behavior: Test.go(...) == 9 func go() -> int { let p = Pair2.single(9) match (p: Pair2) { .single(s) { return s } .couple(c) { return 0 } } return -1 } ``` ## ILEmitterTests_CaseView__NestedView_OneThenInnerMatch (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::NestedView_OneThenInnerMatch topic: choice status: unverified // verified behavior: Test.go(...) == "num:7" func desc(tok: Token) -> string { match (tok: Token) { .word(w) { return "w:{w.text}" } .number(n) { return "num:{n.value}" } } return "?" } func go() -> string { let lx = Lex.one(Token.number(7)) match (lx: Lex) { .one(o) { return desc(o.t) } .pair(p) { return "pair" } } return "?" } ``` ## ILEmitterTests_CaseView__NestedView_PairProjectsTwoTokens (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::NestedView_PairProjectsTwoTokens topic: choice status: unverified // verified behavior: Test.go(...) == "hi/9" func desc(tok: Token) -> string { match (tok: Token) { .word(w) { return w.text } .number(n) { let v = n.value return "{v}" } } return "?" } func go() -> string { let lx = Lex.pair(Token.word("hi"), Token.number(9)) match (lx: Lex) { .one(o) { return "one" } .pair(p) { return "{desc(p.a)}/{desc(p.b)}" } } return "?" } ``` ## ILEmitterTests_CaseView__ViewProjection_InInterpolation (choice, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::ViewProjection_InInterpolation topic: choice status: unverified // compiles cleanly (no auto-run claim was extracted) func go() -> string { let p = Pair2.couple(5, 6) match (p: Pair2) { .single(s) { return "{s.x}" } .couple(c) { return "x={c.a},y={c.b}" } } return "?" } ``` ## ILEmitterTests_CaseView__SinglePayloadView_InInterpolation (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::SinglePayloadView_InInterpolation topic: choice status: unverified // verified behavior: Test.go(...) == "v=42" func go() -> string { let p = Pair2.single(42) match (p: Pair2) { .single(s) { return "v={s.x}" } .couple(c) { return "?" } } return "?" } ``` ## ILEmitterTests_CaseView__ResultOfChoice_ViewProjection (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::ResultOfChoice_ViewProjection topic: choice status: unverified // verified behavior: Test.go(...) == 14 func fetch() -> Result = ok(Reply.accepted(7)) func go() -> int { let r = fetch()? match (r: Reply) { .accepted(a) { return a.id * 2 } .rejected(x) { return 0 } } return -1 } ``` ## ILEmitterTests_CaseView__View_InMatchExpression (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_InMatchExpression topic: choice status: unverified // verified behavior: Test.go(...) == 11 func go() -> int { let p = Pair2.couple(5, 6) return match (p: Pair2) { .single(s) { s.x } .couple(c) { c.a + c.b } } } ``` ## ILEmitterTests_CaseView__MixedArms_PositionalAndView (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::MixedArms_PositionalAndView topic: choice status: unverified // verified behavior: Test.go(...) == 2 func go() -> int { let p = Pair2.single(2) match (p: Pair2) { .single(s) { return s.x } .couple(a, b) { return a + b } } return -1 } ``` ## ILEmitterTests_CaseView__NestedView_SameNameShadowing (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::NestedView_SameNameShadowing topic: choice status: unverified // verified behavior: Test.go(...) == 3 func go() -> int { let outer = Pair2.couple(1, 2) match (outer: Pair2) { .single(c) { return c.x } .couple(c) { let inner = Pair2.single(3) match (inner: Pair2) { .single(c) { return c.x } .couple(c) { return c.a } } return -2 } } return -1 } ``` ## ILEmitterTests_CaseView__View_StringPayloadProjection (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_StringPayloadProjection topic: choice status: unverified // verified behavior: Test.go(...) == "hello" func go() -> string { let t = Token.word("hello") match (t: Token) { .word(w) { return w.text } .number(n) { return "n" } } return "?" } ``` ## ILEmitterTests_CaseView__View_SinglePayload_ArithmeticOnProjection (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_SinglePayload_ArithmeticOnProjection topic: choice status: unverified // verified behavior: Test.go(...) == 100 func go() -> int { let p = Pair2.single(10) match (p: Pair2) { .single(s) { return s.x * s.x } .couple(c) { return 0 } } return -1 } ``` ## ILEmitterTests_CaseView__View_MultiPayload_FieldOrderIndependent (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_MultiPayload_FieldOrderIndependent topic: choice status: unverified // verified behavior: Test.go(...) == 7 func go() -> int { let p = Pair2.couple(3, 4) match (p: Pair2) { .single(x) { return x } .couple(c) { let b = c.b let a = c.a return a + b } } return -1 } ``` ## ILEmitterTests_CaseView__ThreeLevel_OnePath (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::ThreeLevel_OnePath topic: choice status: verified // verified behavior: Test.go(...) == "one-num:7" choice Lex { one(t: Token) pair(a: Token, b: Token) } ``` ## ILEmitterTests_CaseView__View_ThreePayloads (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::View_ThreePayloads topic: choice status: unverified // verified behavior: Test.go(...) == 6 func go() -> int { let t = Triple.only(1, 2, 3) match (t: Triple) { .only(v) { return v.a + v.b + v.c } } return -1 } ``` ## ILEmitterTests_CaseView__Positional_ThreePayloads (choice, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::Positional_ThreePayloads topic: choice status: unverified // verified behavior: Test.go(...) == 6 func go() -> int { let t = Triple.only(1, 2, 3) match (t: Triple) { .only(a, b, c) { return a + b + c } } return -1 } ``` ## ILEmitterTests_CaseView__Enum_NoBindingsStillWorks (choice, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_CaseView.cs::Enum_NoBindingsStillWorks topic: choice status: verified // verified behavior: Test.go(...) == "N" enum Dir { north south } func go() -> string { let d = Dir.north() match (d: Dir) { .north { return "N" } .south { return "S" } } return "?" } ``` ## ILEmitterTests_Coverage_Misc__Await_TaskFromResult (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Await_TaskFromResult topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let v = await Task.FromResult(42) return v } ``` ## ILEmitterTests_Coverage_Misc__Await_TwoSequential (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Await_TwoSequential topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let a = await Task.FromResult(10) let b = await Task.FromResult(20) return a + b } ``` ## ILEmitterTests_Coverage_Misc__AsyncLet_Fanout (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::AsyncLet_Fanout topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { async let a = Task.FromResult(20) async let b = Task.FromResult(22) return a + b } ``` ## ILEmitterTests_Coverage_Misc__TaskFunc_SpawnAndWait (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::TaskFunc_SpawnAndWait topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test task func produce() -> int { return 42 } func go() -> int { let job = produce() return job.Wait() } ``` ## ILEmitterTests_Coverage_Misc__TryCatch_ConvertsException (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::TryCatch_ConvertsException topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var result = 0 try { result = int.Parse("not a number") } catch (Exception e) { result = 0 - 1 } return result } ``` ## ILEmitterTests_Coverage_Misc__TryCatch_Succeeds (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::TryCatch_Succeeds topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { var result = 0 try { result = int.Parse("123") } catch { result = 0 - 1 } return result } ``` ## ILEmitterTests_Coverage_Misc__BclStatic (core, unknown) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::BclStatic topic: core status: unverified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { return ``` ## ILEmitterTests_Coverage_Misc__Bcl_StringBuilder (interop, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Bcl_StringBuilder topic: interop status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let sb = StringBuilder() sb.Append("foo") sb.Append("bar") return sb.ToString().Length } ``` ## ILEmitterTests_Coverage_Misc__Bcl_ListAddSum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Bcl_ListAddSum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = List() xs.Add(1) xs.Add(2) xs.Add(3) var total = 0 for x in xs { total += x } return total } ``` ## ILEmitterTests_Coverage_Misc__Linq_Sum (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Linq_Sum topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [1, 2, 3, 4] return xs.Sum() } ``` ## ILEmitterTests_Coverage_Misc__OutParam_TryParse (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::OutParam_TryParse topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { if int.TryParse("77", out var n) { return n } return 0 } ``` ## ILEmitterTests_Coverage_Misc__Range_IndexFromEnd (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Range_IndexFromEnd topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [10, 20, 30] return xs[^1] } ``` ## ILEmitterTests_Coverage_Misc__Range_IndexFromEnd_Second (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Range_IndexFromEnd_Second topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let xs = [10, 20, 30] return xs[^2] } ``` ## ILEmitterTests_Coverage_Misc__NullableValueLetElse (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::NullableValueLetElse topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func find(id: int) -> int? { if id == 0 { return nil } return id * 10 } func lookup(id: int) -> int { let v = find(id) else { return 0 - 1 } return v } func go() -> int { return lookup(5) + lookup(0) } ``` ## ILEmitterTests_Coverage_Misc__NestedData_FieldChain (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::NestedData_FieldChain topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Inner { v: int } data Outer { inner: Inner, tag: int } func go() -> int { let o = Outer { inner: Inner { v: 4 }, tag: 3 } return o.inner.v + o.tag } ``` ## ILEmitterTests_Coverage_Misc__Spawn_ChannelProducerConsumer (async, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Spawn_ChannelProducerConsumer topic: async status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func go() -> int { let ch = chan(8) let producer = spawn { ch.Send(1) ch.Send(2) ch.Send(3) ch.Close() } producer.Wait() var total = 0 for v in ch { total += v } return total } ``` ## ILEmitterTests_Coverage_Misc__Pointer_LinkedListLength (pointers, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Pointer_LinkedListLength topic: pointers status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test data Node { value: int next: *Node } func go() -> int { var head: *Node = new Node { value: 1, next: nil } head = new Node { value: 2, next: head } head = new Node { value: 3, next: head } var len = 0 var cur = head while cur != nil { len += 1 cur = cur.next } return len } ``` ## ILEmitterTests_Coverage_Misc__Pointer_ByRefIntMutation (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Pointer_ByRefIntMutation topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func addTen(x: *int) { x += 10 } func go() -> int { var n = 5 addTen(&n) return n } ``` ## ILEmitterTests_Coverage_Misc__Enum_MatchWithDefault (choice, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Enum_MatchWithDefault topic: choice status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test enum Dir { north, south, east, west } func go() -> int { let d = Dir.north() match (d: Dir) { .north { return 1 } default { return 0 } } return -1 } ``` ## ILEmitterTests_Coverage_Misc__Recursion_Factorial (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Recursion_Factorial topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func fact(n: int) -> int { if n <= 1 { return 1 } return n * fact(n - 1) } func go() -> int { return fact(5) } ``` ## ILEmitterTests_Coverage_Misc__Recursion_Fibonacci (core, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Recursion_Fibonacci topic: core status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test func fib(n: int) -> int { if n < 2 { return n } return fib(n - 1) + fib(n - 2) } func go() -> int { return fib(7) } ``` ## ILEmitterTests_Coverage_Misc__Interface_Conformance (data, unknown, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_Coverage_Misc.cs::Interface_Conformance topic: data status: verified // compiles cleanly (no auto-run claim was extracted) namespace Test interface ISized { func size() -> int } data Crate : ISized { items: int } func size(c: Crate) -> int { return c.items + 1 } func measure(s: ISized) -> int { return s.size() } func go() -> int { let c = Crate { items: 10 } return measure(c) } ``` ## ILEmitterTests_PointerModel__Downgrade_ByRefParam_AliasesCallerLocal (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::Downgrade_ByRefParam_AliasesCallerLocal topic: pointers status: verified // verified behavior: Test.go(...) == 42 namespace Test data Counter { var value: int } func bump(p: *Counter) { p.value += 1 } func go() -> int { var c = Counter { value: 41 } bump(&c) return c.value } ``` ## ILEmitterTests_PointerModel__Downgrade_ByRefParam_RepeatedMutationAccumulates (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::Downgrade_ByRefParam_RepeatedMutationAccumulates topic: pointers status: verified // verified behavior: Test.go(...) == 42 namespace Test data Acc { var n: int } func add(a: *Acc, amount: int) { a.n += amount } func go() -> int { var acc = Acc { n: 0 } add(&acc, 10) add(&acc, 20) add(&acc, 12) return acc.n } ``` ## ILEmitterTests_PointerModel__Escaping_Param_StaysWrapper_RecursiveBuild (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::Escaping_Param_StaysWrapper_RecursiveBuild topic: pointers status: verified // verified behavior: Test.go(...) == 6 namespace Test data Node { value: int next: *Node } func prepend(head: *Node, v: int) -> *Node { return new Node { value: v, next: head } } func go() -> int { var list: *Node = nil list = prepend(list, 1) list = prepend(list, 2) list = prepend(list, 3) var total = 0 var cur = list while cur != nil { total += cur.value cur = cur.next } return total } ``` ## ILEmitterTests_PointerModel__NullCompared_Param_ForcesWrapper (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::NullCompared_Param_ForcesWrapper topic: pointers status: verified // verified behavior: Test.go(...) == 106 namespace Test data Box { var v: int } func valueOr(b: *Box, fallback: int) -> int { if b == nil { return fallback } return b.v } func go() -> int { let present = new Box { v: 7 } let a = valueOr(present, 99) let nothing: *Box = nil let bb = valueOr(nothing, 99) return a + bb } ``` ## ILEmitterTests_PointerModel__Coercion_WrapperPassedWithStarSyntax (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::Coercion_WrapperPassedWithStarSyntax topic: pointers status: verified // verified behavior: Test.go(...) == 12 namespace Test data Cell { var n: int } func inc(c: *Cell) { c.n += 1 } func go() -> int { var p: *Cell = new Cell { n: 10 } inc(*p) inc(p) return p.n } ``` ## ILEmitterTests_PointerModel__Coercion_WrapperArg_ToByRefParam_Mutates (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::Coercion_WrapperArg_ToByRefParam_Mutates topic: pointers status: verified // verified behavior: Test.go(...) == 33 namespace Test data Vec { var x: int var y: int } func shift(v: *Vec, dx: int, dy: int) { v.x += dx v.y += dy } func go() -> int { var v: *Vec = new Vec { x: 1, y: 2 } shift(v, 10, 20) return v.x + v.y } ``` ## ILEmitterTests_PointerModel__StarRefData_IsError (pointers, negative, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::StarRefData_IsError topic: pointers status: verified // verified behavior: reports diagnostic ES2003 namespace Test ref data Session { id: int } func touch(s: *Session) { s.id = 1 } ``` ## ILEmitterTests_PointerModel__PrimitivePointer_Field_IsNullableWrapper (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::PrimitivePointer_Field_IsNullableWrapper topic: pointers status: verified // verified behavior: Test.go(...) == true namespace Test ref data Slot { p: *int } func go() -> bool { var s = Slot() return s.p == nil } ``` ## ILEmitterTests_PointerModel__EscapingAddressOfLocal_ForwardValue (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::EscapingAddressOfLocal_ForwardValue topic: pointers status: verified // verified behavior: Test.go(...) == 5 namespace Test data P { var x: int } ref data H { slot: *P } func go() -> int { var local = P { x: 5 } var h = H() h.slot = &local return h.slot.x } ``` ## ILEmitterTests_PointerModel__EscapingAddressOfLocal_AliasesLocal (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::EscapingAddressOfLocal_AliasesLocal topic: pointers status: verified // verified behavior: Test.go(...) == 99 namespace Test data P { var x: int } ref data H { slot: *P } func go() -> int { var local = P { x: 5 } var h = H() h.slot = &local local.x = 99 return h.slot.x } ``` ## ILEmitterTests_PointerModel__ReturnHoist_AddressOfLocal (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::ReturnHoist_AddressOfLocal topic: pointers status: verified // verified behavior: Test.go(...) == 7 namespace Test data Node { value: int next: *Node } func makeNode(v: int) -> *Node { var n = Node { value: v, next: nil } return &n } func go() -> int { let p = makeNode(7) return p.value } ``` ## ILEmitterTests_PointerModel__EscapingAddressOfLocal_TwoAliasesShareCell (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::EscapingAddressOfLocal_TwoAliasesShareCell topic: pointers status: verified // verified behavior: Test.go(...) == 100 namespace Test data P { var x: int } ref data Pair { a: *P b: *P } func go() -> int { var local = P { x: 1 } var pr = Pair() pr.a = &local pr.b = &local local.x = 50 return pr.a.x + pr.b.x } ``` ## ILEmitterTests_PointerModel__MixedReceivers_Downgraded_Alias (pointers, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PointerModel.cs::MixedReceivers_Downgraded_Alias topic: pointers status: verified // verified behavior: Test.go(...) == 22 namespace Test data Reg { var hi: int var lo: int } func raise(r: *Reg, by: int) { r.hi += by } func total(r: Reg) -> int { return r.hi + r.lo } func go() -> int { var r = Reg { hi: 10, lo: 5 } raise(&r, 7) return r.total() } ``` ## ILEmitterTests_PtrEmbedIface__PointerEmbed_ValueReadOnly (core, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrEmbedIface.cs::PointerEmbed_ValueReadOnly topic: core status: verified // verified behavior: Test.go(...) == 40 func read(b: IBumper) -> int = b.value() ``` ## ILEmitterTests_PtrEmbedIface__PointerEmbed_BumpOnceThenValue (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrEmbedIface.cs::PointerEmbed_BumpOnceThenValue topic: core status: unverified // verified behavior: Test.go(...) == 41 func once(b: IBumper) -> int { b.bump() return b.value() } ``` ## ILEmitterTests_PtrEmbedIface__PointerEmbed_PromotedDirectAccess (pointers, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrEmbedIface.cs::PointerEmbed_PromotedDirectAccess topic: pointers status: unverified // verified behavior: Test.go(...) == 45 func go() -> int { var o: *Outer = new Outer { Inner: new Inner { n: 45 }, label: "x" } return o.value() } ``` ## ILEmitterTests_PtrEmbedIface__ValueEmbed_PromotedMethodThroughInterface (interpolation, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrEmbedIface.cs::ValueEmbed_PromotedMethodThroughInterface topic: interpolation status: verified // verified behavior: Test.go(...) == "hi kae" data Greeter { name: string func describe() -> string { return "hi {self.name}" } } ``` ## ILEmitterTests_PtrEmbedIface__ValueEmbed_PromotedFieldAccess (data, runnable, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrEmbedIface.cs::ValueEmbed_PromotedFieldAccess topic: data status: verified // verified behavior: Test.go(...) == 15 data Vec2 { var x: int var y: int } ``` ## ILEmitterTests_PtrEmbedIface__PointerEmbed_BumpMutatesThroughPointer (pointers, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrEmbedIface.cs::PointerEmbed_BumpMutatesThroughPointer topic: pointers status: unverified // verified behavior: Test.go(...) == 50 func go() -> int { var o: *Outer = new Outer { Inner: new Inner { n: 48 }, label: "x" } o.bump() o.bump() return o.value() } ``` ## ILEmitterTests_PtrEmbedIface__PointerEmbed_TwiceThenInterpolate (core, runnable) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: ILEmitterTests_PtrEmbedIface.cs::PointerEmbed_TwiceThenInterpolate topic: core status: unverified // verified behavior: Test.go(...) == "n=42" func twice(b: IBumper) -> int { b.bump() b.bump() return b.value() } ``` ## delegates_and_pointers (delegates-events, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: delegates_and_pointers.es topic: delegates-events status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // Passing behavior as a value: E# has three callable forms, chosen by intent. // // 1. Function pointer — `&func`, type `&(int, int -> int)`. Zero allocation, no GC: // `ldftn` + `calli`. The systems tier — hot paths, dispatch tables. (C# needs // `unsafe` + `delegate*` for this; E# makes it safe by construction.) // 2. Nominal delegate — `delegate func Name(...)`. A named `MulticastDelegate` type, // distinct from any structurally-identical delegate. Intent-named, interop-friendly. // 3. BCL delegate — `Func<...>` / `Action<...>`. Structural, heap, multicast. The // framework-callback tier. // // A bare function name converts to whichever delegate type is expected (method-group // conversion), and a lambda's parameter types are inferred from the target. // ═════════════════════════════════════════════════════════════════════════════ // (2) A NOMINAL delegate type. `BinOp` is its own type — a `Func` is NOT a // `BinOp`, even though both wrap (int, int) -> int. delegate func BinOp(a: int, b: int) -> int func add(a: int, b: int) -> int = a + b func mul(a: int, b: int) -> int = a * b // Parameter typed as the nominal delegate. A bare `add` passed here converts (method group). func apply(op: BinOp, a: int, b: int) -> int = op(a, b) // Parameter typed as a BCL `Func`. A lambda converts, its `x` inferred as int. func applyFunc(f: Func, x: int) -> int = f(x) // Parameter typed as a function POINTER. `&name` takes the address; the call is a `calli`, // with no delegate object allocated. func applyPtr(f: &(int, int -> int), a: int, b: int) -> int = f(a, b) func main() -> int { let viaDelegate = apply(add, 3, 4) // 7 — method group → nominal delegate let viaLambda = applyFunc((x) => x * 2, 10) // 20 — lambda → Func let viaPointer = applyPtr(&mul, 5, 6) // 30 — &mul → ldftn + calli, zero alloc return viaDelegate + viaLambda + viaPointer // 57 } ``` ## promotion_and_match (choice, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: promotion_and_match.es topic: choice status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // E#'s defining move: behavior lives in FREE FUNCTIONS, but a free function whose // first parameter is a value `data` is PROMOTED to a method on that type. You write // plain procedural code; you get to call it object-style — including chaining. // // func add(v: Vec, o: Vec) -> Vec is the method Vec.add → v.add(o) // // The free-call spelling `add(v, o)` is then a hard error (the compiler points you at // `v.add(o)`). The method travels with its receiver type, so it is reachable wherever // `Vec` is, regardless of which file declared the function. // // This file pairs that with the other half of E#'s type story — a `choice` (a closed // set of shapes) consumed by `match` (exhaustive pattern dispatch). A `choice` is NOT // a `data`, so functions over it are ordinary free functions, never promoted. // ═════════════════════════════════════════════════════════════════════════════ // A 2-D vector. A `data` is value-semantic: copying it copies the fields, and a // function that returns a new `Vec` never disturbs its input. data Vec { x: int y: int } // Each of these has `Vec` as its first parameter, so each is promoted onto `Vec`. // Call them `a.add(b)`, `a.scaled(2)`, `a.dot(b)` — never `add(a, b)`. func add(v: Vec, o: Vec) -> Vec { return Vec { x: v.x + o.x, y: v.y + o.y } } func scaled(v: Vec, k: int) -> Vec { return Vec { x: v.x * k, y: v.y * k } } func dot(v: Vec, o: Vec) -> int { return v.x * o.x + v.y * o.y } // Because `add` and `scaled` return a `Vec`, promoted calls CHAIN: each result is a // fresh value you can call the next method on. No mutation, no aliasing — just values // flowing through transformations. func combine(a: Vec, b: Vec) -> Vec { return a.add(b).scaled(2) } // The other half of the type story: a sum type. Each variant may carry payload fields. choice Shape { point // no payload segment(length: int) // one payload box(w: int, h: int) // two payloads } // `Shape` is a `choice`, not a `data`, so this is a plain free function — call it // `area(s)`. `match` must cover every variant (the compiler warns otherwise); each // arm binds that variant's payloads positionally. func area(s: Shape) -> int { match s { .point { return 0 } .segment(len) { return 0 } // a 1-D segment has no area .box(w, h) { return w * h } } return 0 } func main() -> int { let a = Vec { x: 1, y: 2 } let b = Vec { x: 3, y: 4 } let c = a.combine(b) // (a + b) then *2 → Vec { x: 8, y: 12 } — promoted, so `a.combine(b)` let d = a.dot(b) // 1*3 + 2*4 = 11 // Construct a choice value with its factory, then fold it with `match`. let boxArea = area(Shape.box(3, 5)) // 15 return c.x + c.y + d + boxArea // 8 + 12 + 11 + 15 = 46 } ``` ## json (choice, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: json.es topic: choice status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo using "System.Text" // StringBuilder // ═════════════════════════════════════════════════════════════════════════════ // A JSON value, modeled and serialized. The shape of JSON is a recursive sum type — // a value is null, a bool, a number, a string, an array OF values, or an object whose // fields hold values — so it is a `ref choice`: an identity-carrying tagged union whose // cases can recurse through each other (an array holds a `List`, and so on). // // `stringify` is the whole point: one `match` over the six cases, each arm building its // own text, the array/object arms recursing back into `stringify`. This is the canonical // "interpreter over an AST" shape — `match` for dispatch, recursion for structure, a // `StringBuilder` for the O(n) join, string interpolation for the leaves. // ═════════════════════════════════════════════════════════════════════════════ // One key/value entry of an object. A plain value `data` — copied by value, no identity. data Field { key: string value: Json } // The recursive value type. `ref choice` = abstract base + one sealed subclass per case; // the cases reference `Json` (and `List`) freely because each case is a real class. ref choice Json { jnull jbool(value: bool) jnum(value: double) jstr(value: string) jarr(items: List) jobj(fields: List) } // Serialize any value to its JSON text. Exhaustive `match` — every case is handled, so // the compiler needs no trailing fallback. Each single-payload case binds its payload // *transparently*: in `.jbool(b)` the name `b` IS the bool, in `.jarr(items)` `items` IS // the `List` — the case view unwraps to the payload value (and `b.value` / // `items.Count` still work). The array/object arms walk their collection and recurse. // // The transparent binding is pure SUGAR. A single-payload arm `.jbool(b) { … b … }` is // exactly the case view `.jbool(c) { … c.value … }` with the projection elided — both // lower to the identical IL (cast to the variant subclass, then load the one payload // field). So `.jbool(b)` and `.jbool(c)` + `c.value` are interchangeable; the bare name // is just the common case spelled shorter. (A multi-payload case has no single value to // unwrap to, so it keeps the explicit view: `.jobj(c)` then `c.fields`.) func stringify(j: Json) -> string { match j { .jnull { return "null" } .jbool(b) { return b ? "true" : "false" } .jnum(n) { return "{n}" } .jstr(s) { return "\"{s}\"" } .jarr(items) { let sb = StringBuilder() sb.Append("[") var i = 0 while i < items.Count { if i > 0 { sb.Append(",") } sb.Append(stringify(items[i])) // recurse into each element i += 1 } sb.Append("]") return sb.ToString() } .jobj(fields) { let sb = StringBuilder() sb.Append("{") var i = 0 while i < fields.Count { let f = fields[i] if i > 0 { sb.Append(",") } sb.Append("\"{f.key}\":") sb.Append(stringify(f.value)) // recurse into each value i += 1 } sb.Append("}") return sb.ToString() } } } // Build a small document and render it: {"name":"ada","tags":["math","engine"],"active":true} func main() -> string { let tags = List() tags.Add(Json.jstr("math")) tags.Add(Json.jstr("engine")) let fields = List() fields.Add(Field { key: "name", value: Json.jstr("ada") }) fields.Add(Field { key: "tags", value: Json.jarr(tags) }) fields.Add(Field { key: "active", value: Json.jbool(true) }) return stringify(Json.jobj(fields)) } ``` ## turtle (choice, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: turtle.es topic: choice status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // A turtle you drive with a CHAIN of commands — the fluent-builder pattern, and the // reason it works. // // The turtle is a `ref data`: it has identity and evolving state (position + heading). // Each command is applied by `apply`, which mutates the turtle and then **returns the // turtle itself**. Because a `ref data` is a reference, returning it hands back the SAME // object — so `apply` can be chained, and you never re-name the receiver: // // Turtle().apply(...).apply(...).apply(...) // // That return-`self` move is the whole trick behind fluent APIs (`StringBuilder`, // LINQ, query builders). Contrast it with a method that returns a `Result` or a fresh // value: those don't chain, because the next call would land on the wrong type. // // The commands themselves show the other half of the language: a `choice` whose // `forward` case carries a step count and whose `turn` case carries an `enum` // direction, dispatched with `match`. One `apply`, two payload shapes, no `if`-ladder. // ═════════════════════════════════════════════════════════════════════════════ // Which way to pivot. A plain `enum` — a closed set of named constants. enum Turn { left right } // What the turtle can be told to do. A `choice`: `forward` carries how far, `turn` // carries which way (the `Turn` enum). `match` in `apply` handles both. choice Command { forward(steps: int) turn(direction: Turn) } // The turtle. `ref data` = identity + mutable state; heading is 0=N, 1=E, 2=S, 3=W, // so a right turn is +1 (mod 4) and a left turn is +3 (mod 4). ref data Turtle { var x: int var y: int var facing: int init() { self.x = 0 self.y = 0 self.facing = 0 // start facing North } } // Apply one command and RETURN THE TURTLE — that return-self is what makes `apply` // chainable. `match` dispatches the command; `forward` walks in the current heading, // `turn` rotates. The nested `match (direction: Turn)` folds the enum to a delta. func apply(t: Turtle, cmd: Command) -> Turtle { match cmd { .forward(steps) { if t.facing == 0 { t.y += steps } // North else if t.facing == 1 { t.x += steps } // East else if t.facing == 2 { t.y -= steps } // South else { t.x -= steps } // West } .turn(direction) { match (direction: Turn) { .left { t.facing = (t.facing + 3) % 4 } .right { t.facing = (t.facing + 1) % 4 } } } } return t // the SAME turtle — the chain continues on it } // Drive the turtle with a single fluent chain — no intermediate `t` rebinding, just // commands flowing through the one object: // // start (0,0) facing N // forward 5 → (0,5) turn right → facing E // forward 3 → (3,5) turn right → facing S // forward 2 → (3,3) // // Final position (3, 3) → encoded as x*100 + y = 303. func main() -> int { let t = Turtle() .apply(Command.forward(5)) .apply(Command.turn(Turn.right())) .apply(Command.forward(3)) .apply(Command.turn(Turn.right())) .apply(Command.forward(2)) return t.x * 100 + t.y // 303 } ``` ## calculator (choice, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: calculator.es topic: choice status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // A tiny arithmetic calculator, end to end. // // It turns a string like "1 + 2 * 3" into a number — and gets 7, not 9, because it // respects operator precedence (multiplication binds tighter than addition). It is // written the way a real E# program is: a recursive-descent parser that builds an // abstract syntax tree (AST), then a recursive evaluator that walks it. // // If this is the first E# you have ever read, here is the whole tour in one file: // // • `ref choice` — a tagged union (a "sum type"). The AST is one of three shapes: // a number, an addition, or a multiplication. Because it is a // *ref* choice it is a reference type, so a variant may hold // another `Expr` and the tree can nest to any depth. // • `data` + `*P` — a small mutable parser-state struct. `data` is a value type // (copying it copies the bits), so to let every parse step share // and advance ONE cursor we put it on the heap with `new`, which // hands back a pointer, written `*P`. // • `new` — the heap-allocation operator: `new P { ... }` allocates a value // `data` on the heap and yields a `*P`. It is the only way to mint // a fresh pointer. // • `Result` — error handling without exceptions. A parse step returns either // `ok(tree)` or `error("message")`. The `?` after a call means // "if that was an error, stop and return the same error from here", // so the happy path stays flat and readable. // • `match` — exhaustive, binding pattern dispatch over a choice's variants. // ═════════════════════════════════════════════════════════════════════════════ // The AST. Each variant carries its own payload. `add` and `mul` hold two more // `Expr`s — legal because `ref choice` is a reference type, so the tree nests freely. ref choice Expr { num(value: int) // a literal integer, e.g. 42 add(left: Expr, right: Expr) // left + right mul(left: Expr, right: Expr) // left * right } // The parser's mutable state: the input text plus a cursor into it. It is a value // type (`data`), but we will hand around a *pointer* (`*P`) so every parse step // advances the same shared `pos` instead of mutating a private copy. data P { var src: string var pos: int } // --- small cursor helpers ----------------------------------------------------- // Each takes `*P` (a pointer). A pointer parameter is NOT promoted to a method, so // these stay plain free functions you call as `atEnd(p)` — only a direct `data` // receiver (e.g. `func f(v: Vec)`) would become `v.f()`. // True once the cursor has consumed the whole string. func atEnd(p: *P) -> bool { return p.pos >= p.src.Length } // Advance past spaces so the grammar can ignore whitespace. func skipWs(p: *P) { while !atEnd(p) { if p.src[p.pos] == ' ' { p.pos += 1 } else { return } } } // --- the grammar, highest-precedence first ------------------------------------ // // expr = term ('+' term)* (addition — lowest precedence) // term = factor ('*' factor)* (multiplication — binds tighter) // factor = number (a run of digits) // // Each rule returns `Result`: the parsed subtree, or an error message. // factor = number func parseFactor(p: *P) -> Result { skipWs(p) if atEnd(p) { return error("expected a number") } if !char.IsDigit(p.src[p.pos]) { return error("expected a digit") } let start = p.pos while !atEnd(p) && char.IsDigit(p.src[p.pos]) { p.pos += 1 } let text = p.src.Substring(start, p.pos - start) return ok(Expr.num(int.Parse(text))) } // term = factor ('*' factor)* — left-associative: fold each '*' into the tree. func parseTerm(p: *P) -> Result { var left = parseFactor(p)? // `?` unwraps ok, or returns the error from here while true { skipWs(p) if atEnd(p) || p.src[p.pos] != '*' { return ok(left) } p.pos += 1 let right = parseFactor(p)? left = Expr.mul(left, right) } return ok(left) } // expr = term ('+' term)* — same shape, one precedence level down. func parseExpr(p: *P) -> Result { var left = parseTerm(p)? while true { skipWs(p) if atEnd(p) || p.src[p.pos] != '+' { return ok(left) } p.pos += 1 let right = parseTerm(p)? left = Expr.add(left, right) } return ok(left) } // Entry point: put the cursor on the heap with `new`, parse a whole expression, and // confirm nothing is left over. func parse(src: string) -> Result { var p: *P = new P { src: src, pos: 0 } // `new` → heap value `data`, yields *P let tree = parseExpr(p)? skipWs(p) if !atEnd(p) { return error("trailing characters") } return ok(tree) } // --- evaluation --------------------------------------------------------------- // Walk the tree to an int. `match` dispatches on the variant and binds a "case view" // — `.add(n)` gives an `n` whose members are that variant's payloads, reached by their // declared names (`n.left`, `n.right`, `n.value`). Recursion follows the tree's shape. func eval(e: Expr) -> int { // `Expr` is a choice → not promoted → a free function match e { .num(n) { return n.value } .add(n) { return eval(n.left) + eval(n.right) } .mul(n) { return eval(n.left) * eval(n.right) } } return 0 } // Parse, then evaluate. Returns the answer, or -1 if the input did not parse — so the // precedence is visible in the result: 1 + 2 * 3 == 7, never 9. func calc(src: string) -> int { let r = parse(src) if r.IsError { return -1 } return eval(r.Value) } // The entry point is a `main` method on a `ref data Program` (the OO application shape, // the class-style alternative to a bare top-level `func main`). That method IS the entry // point; the compiler constructs the program (`Program()`) and calls `.main()`. ref data Program { func main() -> int { return calc("1 + 2 * 3") // 7 } } ``` ## vm (choice, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: vm.es topic: choice status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // A tiny stack machine — the smallest thing that is honestly a "virtual machine". // // A program is a list of instructions; execution is a loop that walks them, each // one pushing to or popping from an operand stack. This is how real bytecode VMs // (the CLR's own, the JVM, CPython, Lua) work underneath — just with more opcodes. // // The instruction set is a `choice` (a value tagged union): some variants carry a // payload (`push` carries the integer to push), most carry none (`add`, `dup`, …). // Executing one instruction is a `match` over the variant — the canonical use of a // sum type. The operand stack is a `List` used as a LIFO: `Add` is push, // `xs[xs.Count - 1]` is peek, `RemoveAt(xs.Count - 1)` is pop — a `List` from the // BCL, called directly. Anything that can fail (popping an empty stack, dividing by // zero, leaving the wrong number of results) is a `Result`, threaded with `?`. // ═════════════════════════════════════════════════════════════════════════════ // The instruction set. `push` is the only variant with a payload. choice Op { push(value: int) add sub mul div dup // duplicate the top of the stack swap // exchange the top two } // Pop the top of the stack, or fail on underflow. Takes `*List`... actually a // `List` is already a reference type, so it is passed and mutated directly — no // pointer needed. Returns the popped value (or an error), leaving the list shorter. func pop(stack: List) -> Result { if stack.Count == 0 { return error("stack underflow") } let top = stack[stack.Count - 1] stack.RemoveAt(stack.Count - 1) return ok(top) } // Execute one instruction against the stack. `match` covers every variant, so the // dispatch is exhaustive; each arm either pushes, or pops its operands (with `?` // propagating an underflow) and pushes the result. Single-payload `push` binds its // value transparently — `n` IS the int. func step(stack: List, op: Op) -> Result { match op { .push(n) { stack.Add(n) } .add { let b = pop(stack)? let a = pop(stack)? stack.Add(a + b) } .sub { let b = pop(stack)? let a = pop(stack)? stack.Add(a - b) } .mul { let b = pop(stack)? let a = pop(stack)? stack.Add(a * b) } .div { let b = pop(stack)? let a = pop(stack)? if b == 0 { return error("division by zero") } stack.Add(a / b) } .dup { let top = pop(stack)? stack.Add(top) stack.Add(top) } .swap { let b = pop(stack)? let a = pop(stack)? stack.Add(b) stack.Add(a) } } return ok(0) // step's value is unused; it reports success or the error } // Run a whole program: step through every instruction, then require exactly one value // left on the stack — that's the result. Too many or too few is a program error, not a // silent answer. func run(program: List) -> Result { let stack = List() var i = 0 while i < program.Count { step(stack, program[i])? // propagate the first runtime error i += 1 } if stack.Count != 1 { return error("program left {stack.Count} values on the stack, expected 1") } return ok(stack[0]) } // Build and run: (2 + 3) * (10 - 6) == 5 * 4 == 20 // push 2, push 3, add → stack [5] // push 10, push 6, sub → stack [5, 4] // mul → stack [20] // The entry point lives on a `ref data Program` — the OO "an object IS the application" // shape, the class-style alternative to a bare top-level `func main`. A `main` method on // a `ref data Program` IS the program's entry point; the compiler constructs the program // (`Program()`) and calls `.main()`, so no separate launcher function is needed. ref data Program { func main() -> int { let program = List() program.Add(Op.push(2)) program.Add(Op.push(3)) program.Add(Op.add()) program.Add(Op.push(10)) program.Add(Op.push(6)) program.Add(Op.sub()) program.Add(Op.mul()) let r = run(program) return r.IsOk ? r.Value : -1 // 20 } } ``` ## events (delegates-events, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: events.es topic: delegates-events status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // Events — a controlled subscription point over a delegate. The delegate is the payload; // the event only governs who may subscribe (`+=`) and unsubscribe (`-=`). Outside code // can't invoke or replace it. Events are declared on `ref data` (they imply identity), // fired with the null-safe `raise` statement, and emit exactly what C# emits for // `public event Action OnChanged;` — so a C# consumer subscribes with `+=` unchanged. // ═════════════════════════════════════════════════════════════════════════════ // A counter that announces every change. `event OnChanged: Action` declares the // subscription point, typed by the `Action` delegate. ref data Counter { var total: int event OnChanged: Action init() { self.total = 0 } func add(n: int) { self.total = self.total + n // `raise` captures the handler list then invokes it — a no-op when there are no // subscribers, and safe against a handler unsubscribing mid-raise. raise OnChanged(self.total) } } func main() -> int { var lastSeen = 0 // mutable local, captured by the handler below let c = Counter() // Subscribe a lambda whose shape matches the event's Action. Closures capture // outer `var`s mutably, so each raise writes the new total back into `lastSeen`. c.OnChanged += func(v: int) -> void { lastSeen = v } c.add(5) // total 5 → OnChanged(5) → lastSeen = 5 c.add(3) // total 8 → OnChanged(8) → lastSeen = 8 return lastSeen // 8 — proof the event fired and the handler ran } ``` ## wordcount (interop, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: wordcount.es topic: interop status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo using "System.Collections.Generic" // Dictionary // ═════════════════════════════════════════════════════════════════════════════ // Counting word frequencies — a tour of BCL interop, which is the soul of E#. // // There is no bespoke E# hash map: you reach straight for `Dictionary` // from the .NET base class library and call it directly — `ContainsKey`, the `[key]` // indexer for get and set, `Count`, `TryGetValue` with an `out` parameter. E# adds no // wrapper; a `Dictionary` here is the same `Dictionary` a C# caller would hand you. // `string.Split`, `.ToLower()`, and `.Length` are likewise just the BCL string API. // // The program reads a sentence, tallies each word, then finds the most frequent one // — a single pass to count, a single pass to pick the winner. `out` is the idiomatic // BCL "return a bool and a value" shape, and E# speaks it natively (`out var n`). // ═════════════════════════════════════════════════════════════════════════════ // Tally how many times each (lower-cased) word appears. Returns the populated map. func tally(text: string) -> Dictionary { let counts = Dictionary() let words = text.ToLower().Split(' ') var i = 0 while i < words.Length { let w = words[i] if w.Length > 0 { // get-or-zero then store back: the indexer reads and writes the same cell. if counts.ContainsKey(w) { counts[w] = counts[w] + 1 } else { counts[w] = 1 } } i += 1 } return counts } // How many times one word occurs, using the BCL `TryGetValue(key, out value)` pattern. // `out n` binds a fresh local the call fills; reading `n` afterward is the count (or 0 // when the word is absent and the call returned false). func frequency(counts: Dictionary, word: string) -> int { if counts.TryGetValue(word, out var n) { return n } return 0 } // Walk the entries to find the highest count. `for (k, v) in dict` destructures each // KeyValuePair into its key and value — tuple-style iteration over a BCL collection. func mostFrequentCount(counts: Dictionary) -> int { var best = 0 for (word, n) in counts { if n > best { best = n } } return best } // "the cat sat on the mat the cat ran" — "the" appears 3×, "cat" 2×, rest once. // frequency("the") is 3; the single most-frequent count is also 3. 3 + 3 = 6. // // The driver is a `main` method on a `ref data Program` — the class-style program. That // method IS the entry point; the compiler constructs the program (`Program()`) and calls // `.main()`, so no separate launcher function is needed. ref data Program { func main() -> int { let counts = tally("the cat sat on the mat the cat ran") return frequency(counts, "the") + mostFrequentCount(counts) } } ``` ## money (result, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: money.es topic: result status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // Money done right: a fixed-point amount in integer cents, never a float. // // Money is the textbook case for value semantics. An amount has no identity — two // $5.00 bills are interchangeable — and you never want one assignment to mutate // another ledger entry by surprise. So `Money` is a `data`: copied on assignment, // equal by its field, no shared mutation. And it's stored as `cents: int`, because // binary floating point cannot represent 0.10 exactly and money math must be exact. // // Every operation is a free function whose first parameter is `Money`, so by // promotion it reads as a method on the value — `a.plus(b)`, `price.times(3)`, // `total.format()` — and because each returns a fresh `Money` (or a `Result`), the // calls chain without ever mutating the input. Division can fail (zero divisor), so // it returns `Result` and the `?` operator threads the failure. // ═════════════════════════════════════════════════════════════════════════════ // A value amount. One field, integer cents. No constructor — value `data` is built // with a composite literal; a factory gives a readable surface. data Money { cents: int } // Factories. `dollars(5)` → $5.00; `of(12, 34)` → $12.34. func dollars(d: int) -> Money = Money { cents: d * 100 } func of(d: int, c: int) -> Money = Money { cents: d * 100 + c } // --- promoted arithmetic (first param `Money` ⇒ method on `Money`) ---------------- // Each returns a new value; the receiver is never touched. func plus(a: Money, b: Money) -> Money = Money { cents: a.cents + b.cents } func minus(a: Money, b: Money) -> Money = Money { cents: a.cents - b.cents } func times(a: Money, factor: int) -> Money = Money { cents: a.cents * factor } func isNegative(a: Money) -> bool = a.cents < 0 // Splitting a bill N ways can fail (N <= 0), so it speaks `Result`. Integer division // floors, so the remainder cents are handed back too — no money is silently lost. func splitEvenly(a: Money, ways: int) -> Result { if ways <= 0 { return error("cannot split into {ways} shares") } return ok(Money { cents: a.cents / ways }) } // Render as "$D.CC", padding the cents and handling a negative amount cleanly. func format(a: Money) -> string { let neg = a.cents < 0 let abs = neg ? 0 - a.cents : a.cents let d = abs / 100 let c = abs % 100 let cc = c < 10 ? "0{c}" : "{c}" let sign = neg ? "-" : "" return "{sign}${d}.{cc}" } // A small end-to-end calculation: three items, a discount, split two ways. // The `?` after splitEvenly unwraps the ok value or returns the error from here. func checkout() -> Result { let apple = of(0, 99) // $0.99 let bread = of(2, 49) // $2.49 let coffee = dollars(8) // $8.00 let subtotal = apple.plus(bread).plus(coffee) // chained, no mutation: $11.48 let discount = of(1, 48) // $1.48 off let total = subtotal.minus(discount) // $10.00 let perPerson = total.splitEvenly(2)? // $5.00, or propagate the error return ok("total {total.format()}, each {perPerson.format()}") } func main() -> string { let r = checkout() return r.IsOk ? r.Value : "error: {r.Error}" // "total $10.00, each $5.00" } ``` ## vending (choice, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: vending.es topic: choice status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // A vending machine — a small stateful protocol, and the one place E# reaches for // the object world on purpose. // // The machine HAS IDENTITY: there is one of it, money accumulates in it, stock // depletes from it, and every command acts on that same evolving thing. That is the // definition of `ref data` — a class with reference semantics — as opposed to the // value `data` used elsewhere in this corpus. Commands arrive as a `choice` (insert a // coin, buy, cancel) and are dispatched with `match`. Coins are an `enum` with // explicit denominations, decoded by a second `match`. Anything the user can get // wrong (too little credit, sold out) is a `Result`, so the caller always gets a // clear outcome instead of a silent failure. // ═════════════════════════════════════════════════════════════════════════════ // Coin denominations, in cents. An `enum` emits as a real CLR enum; the explicit // values are the actual coin worth. enum Coin { nickel = 5 dime = 10 quarter = 25 } // Decode a coin to its cent value. `match` over an enum needs the type named so the // `.nickel` shorthand resolves to `Coin`. func cents(c: Coin) -> int { match (c: Coin) { .nickel { return 5 } .dime { return 10 } .quarter { return 25 } } return 0 } // The three things a customer can do. A `choice`: `insert` carries which coin; the // others carry nothing. choice Command { insert(coin: Coin) buy cancel } // The machine itself — a `ref data`, because it has identity and evolving state. // `var` fields mutate in place; `price` is fixed at construction. ref data Machine { var credit: int var stock: int let price: int init(stock: int, price: int) { self.credit = 0 self.stock = stock self.price = price } } // Apply one command to the machine, mutating it and reporting the outcome. Promoted // onto `Machine` (first parameter), so the caller writes `machine.apply(cmd)`. Each // arm reads/writes the shared state through the reference — the changes persist // across calls because a `ref data` is one object, not a copy. func apply(m: Machine, cmd: Command) -> Result { match cmd { .insert(coin) { m.credit += cents(coin) // coin IS the Coin (transparent view) return ok("credit: {m.credit}c") } .buy { if m.stock == 0 { return error("sold out") } if m.credit < m.price { return error("need {m.price - m.credit}c more") } let change = m.credit - m.price m.credit = 0 // bank the price, return the rest m.stock -= 1 return ok("dispensed — change {change}c, {m.stock} left") } .cancel { let refund = m.credit m.credit = 0 return ok("refunded {refund}c") } } } // A short session against ONE machine: the mutations accumulate because `m` is a // single identity-bearing object, not re-copied each call. Two quarters + a dime is // 60c against a 50c price → dispensed with 10c change. // The application is itself a `ref data` — `Program` OWNS the machine and drives the // session in `main`. A `main` method on a `ref data Program` IS the program's entry // point (the class-style alternative to a bare top-level `func main`); the compiler // constructs the program (`Program()`) and calls `.main()`, so no launcher is needed. ref data Program { func main() -> string { let m = Machine(3, 50) // 3 items, 50c each m.apply(Command.insert(Coin.quarter())) // credit 25 m.apply(Command.insert(Coin.quarter())) // credit 50 m.apply(Command.insert(Coin.dime())) // credit 60 let result = m.apply(Command.buy()) // dispense, 10c change, 2 left return result.IsOk ? result.Value : "error: {result.Error}" } } ``` ## pointers_and_sharing (pointers, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: pointers_and_sharing.es topic: pointers status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // Value vs. shared — the heart of E#'s memory model, and what `new` is for. // // A `data` type is a VALUE, like an int. Assigning it COPIES; two variables holding a // `data` never affect each other. That is the default, and it is usually what you // want — no spooky action at a distance. // // Sometimes you need the opposite: several places that read and write ONE shared // piece of state (a counter threaded through a computation, a node in a linked // structure). For that you put the `data` on the heap with `new`, which yields a // POINTER, written `*T`. Everyone holding the `*T` sees the same mutations. // // `new Counter { ... }` → allocate on the heap, hand back a `*Counter` // `c: *Counter` → a pointer; `c.total` reads/writes the shared cell // `let alias = c` → copies the POINTER, not the counter — same object // // `new` is exactly "put this value on the heap and give me a pointer to it". It is // the one allocation expression in the language and the only way to mint a fresh `*T`. // ═════════════════════════════════════════════════════════════════════════════ // A plain value `data`: a running tally. No `init` block — value types are built with // a composite literal that names each field (`Counter { total: 0, steps: 0 }`). data Counter { var total: int var steps: int } // `bump` takes a POINTER (`*Counter`), so it mutates the caller's counter in place. // A pointer parameter stays a free function (only a direct-value receiver like // `func f(c: Counter)` would become the method `c.f()`). func bump(c: *Counter, amount: int) { c.total += amount c.steps += 1 } // Had this taken a value `Counter` instead of `*Counter`, `add` would receive its own // COPY and the caller would never see the change. The pointer is what makes the // sharing real. // Optional: You can annotate return type as void if you prefer visibility. func addAll(c: *Counter, xs: List) -> void { for x in xs { bump(c, x) } } func main() -> int { // `new` allocates the counter on the heap and returns a *Counter. `tally` and // `alias` are then two NAMES for the SAME heap counter. var tally: *Counter = new Counter { total: 0, steps: 0 } let alias = tally let xs = List() xs.Add(5) xs.Add(7) xs.Add(3) addAll(tally, xs) // through the pointer: total = 15, steps = 3 bump(alias, 100) // through the OTHER name — same object: total = 115, steps = 4 // The writes via `alias` are visible through `tally` — both point at one heap cell. // Read the shared fields back through the pointer (auto-deref): total = 115, steps = 4. return tally.total + tally.steps // 119 } ``` ## linked_list_and_tail (pointers, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: linked_list_and_tail.es topic: pointers status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // Two flavors of recursion, and a thing E# does that C# can't. // // 1. Structural recursion over a heap-linked list. A value `data` can't contain itself // by value (that would be infinitely large — a hard error), so the `next` link is a // pointer, `*Node`. `new Node { ... }` allocates a node on the heap and yields a // `*Node`; `nil` ends the list. // // 2. Tail recursion. When a recursive call is the LAST thing a function does // (`return f(...)`), E# emits the CLR `tail.` prefix — the frame is REUSED, not // stacked — and GUARANTEES it, so an accumulator loop written as recursion runs in // constant stack however deep. (Roslyn emits `tail.` only opportunistically and gives // C# no language-level control or guarantee, so you can't rely on TCO there; E#, like // F#, makes it a guarantee.) // ═════════════════════════════════════════════════════════════════════════════ // The self-reference is a pointer — `next: Node` would be ES2002 (infinite-size value). data Node { value: int next: *Node } // Structural recursion: this node's value plus the sum of the rest. NOT a tail call (the // addition happens after the recursive call returns) — and that's fine for a short list. func sumList(n: *Node) -> int { if n == nil { return 0 } return n.value + sumList(n.next) } // Tail recursion: the recursive call is in tail position, so it compiles to a guaranteed // CLR tail call. At large `n` a non-TCO'd version risks a StackOverflow; here it's flat. func sumTo(n: int, acc: int) -> int { if n <= 0 { return acc } return sumTo(n - 1, acc + n) } func main() -> int { // Build 1 -> 2 -> 3 on the heap, tail first so each node can point at the next. let third = new Node { value: 3, next: nil } let second = new Node { value: 2, next: third } let first = new Node { value: 1, next: second } return sumList(first) + sumTo(100, 0) // 6 + 5050 = 5056 } ``` ## interfaces_and_static (static-func, authored, verified) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: interfaces_and_static.es topic: static-func status: verified // hand-authored, idiomatic E# — verified through the E# compiler namespace Demo // ═════════════════════════════════════════════════════════════════════════════ // E#'s object side: interfaces, the two kinds of type that satisfy them, methods that // live inside a `ref data` body, and a `static func` static class. // // An `interface` is nominal: a type satisfies it only by NAMING it after `:` — there is // no structural auto-matching. Both kinds of user type can conform: // // • a value `data` conforms by PROMOTION — a free `func` whose first parameter is the // data type becomes the interface method. (Storing a value type behind an interface // boxes it; the compiler warns. Use `ref data` when you'll pass it as the interface a // lot.) // • a `ref data` conforms with methods written INSIDE its body (they get an implicit // `self`), and constructs via an `init` block. // // A `static func Name { ... }` is a static class: a bag of constants and stateless // functions, called `Name.member(...)`. // ═════════════════════════════════════════════════════════════════════════════ // The contract. By .NET convention interface names start with `I`. interface IArea { func area() -> int } // A value `data` conforming via promotion. `func area(r: Rect)` has `Rect` as its first // parameter, so it IS `Rect.area()` — and that satisfies `IArea`. (Passing a `Rect` where // an `IArea` is expected boxes the struct; fine here, the compiler just notes it.) data Rect : IArea { w: int h: int } func area(r: Rect) -> int { return r.w * r.h } // A `ref data` conforming with an in-body method. It has identity, an `init` constructor, // and `self` inside its methods. ref data Disk : IArea { radius: int init(r: int) { self.radius = r } // Methods inside a `ref data` body read/write fields through `self`. This one // satisfies `IArea.area()`. (Rough integer area, π ≈ 3.) func area() -> int { return 3 * self.radius * self.radius } } // Dispatch through the interface: `describe` neither knows nor cares whether it holds a // `Rect` or a `Disk` — it calls `area()` virtually. This is the one place E# reaches for // the object world on purpose. func describe(s: IArea) -> int { return s.area() } // A `static func` static class: constants + stateless helpers, reached as `Geo.member`. static func Geo { const UNIT = 1 func unitSquare() -> Rect { return Rect { w: UNIT, h: UNIT } } func biggest(a: int, b: int) -> int { return a > b ? a : b } } func main() -> int { let r = Rect { w: 3, h: 4 } // value type let d = Disk(5) // ref data via init let viaInterface = describe(r) + describe(d) // 12 + 75 = 87 (both as IArea) let unit = Geo.unitSquare().area() // 1 (static class → promoted method) let pick = Geo.biggest(viaInterface, 100) // 100 return viaInterface + unit + pick // 87 + 1 + 100 = 188 } ``` ## extract_corpus__extract (programs, program) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: extract.es topic: programs status: unverified // part of extract_corpus — the first real E# program (multi-file, dogfood) namespace ExtractCorpus // Stage 1 — Extract: walk the test corpus's C# host files via Roslyn and lift the // embedded `.es` programs + their behavioral claims out of each `[Fact]`. This is // the interop-aggressive half of the dogfood: E# consuming Roslyn's generic, // type-pattern-heavy API. LINQ (`OfType`) resolves from the implicit System.Linq // import; the Roslyn syntax types come from the two imports below. The walk is // deliberately string-centric (`.ToString()` on nodes) rather than type-pattern // matching, so it leans on Roslyn's enumerables, not `is`-patterns over CLR types. using "Microsoft.CodeAnalysis" using "Microsoft.CodeAnalysis.CSharp" using "Microsoft.CodeAnalysis.CSharp.Syntax" // One extracted example: an `.es` program plus the behavioral claim its [Fact] made. // id (provenance) is `file::method`; kind is the classification bucket. ref data Fact { var file: string = "" var method: string = "" var source: string = "" var kind: string = "unknown" // "runnable" | "negative" | "unknown" var entry: string = "" // E# function to invoke (runnable) var args: List = List() // literal arg texts (runnable) var expected: string = "" // literal expected text (runnable) var diag: string = "" // expected diagnostic code (negative) var verified: bool = false // re-verified through the E# compiler (Stage 2) var topic: string = "core" // taxonomy bucket (file + content) var origins: List = List() // every file::method whose source is identical (dedup) var duplicateCount: int = 1 // how many test methods carried this exact source var canonical: bool = true // false for absorbed duplicates (not written) var program: string = "" // non-empty for multi-file flagship-program files (kind "program") } // True when a method declaration carries an xUnit [Fact] or [Theory] attribute. func isTestMethod(m: MethodDeclarationSyntax) -> bool { for a in m.DescendantNodes().OfType() { let name = a.Name.ToString() if name == "Fact" || name == "Theory" { return true } } return false } // Heuristic: a string literal is an embedded E# program if it carries E# structure. func looksLikeEsharp(s: string) -> bool { return s.Contains("namespace ") || s.Contains("func ") || s.Contains("data ") || s.Contains("choice ") } // "ES2151" / "ES3012" etc. — a diagnostic-code literal (E + S + four digits). func isDiagCode(s: string) -> bool { if s.Length != 6 { return false } if s[0] != 'E' || s[1] != 'S' { return false } var i = 2 while i < 6 { if !char.IsDigit(s[i]) { return false } i += 1 } return true } // Strip a single layer of surrounding double quotes from an argument's source text. func unquote(s: string) -> string { if s.Length >= 2 && s[0] == '"' && s[s.Length - 1] == '"' { return s.Substring(1, s.Length - 2) } return s } // Split a call's argument text at top-level commas (ignoring commas nested inside // (), [], <>, {}, ordinary "..." strings, or """...""" raw strings). Works off the // invocation's source text so it never touches Roslyn's `SeparatedSyntaxList` struct // (a known interop gap). Brace + raw-string awareness is what keeps object initializers // like `new object?[] { "/users/{id}", x }` and multi-line raw-string args from // mis-splitting at an interior comma. func splitTopLevel(inner: string) -> List { let result = List() var depth = 0 var inStr = false // inside an ordinary "..." literal var inRaw = false // inside a """...""" raw-string literal var start = 0 var i = 0 while i < inner.Length { let c = inner[i] if inRaw { // Only a closing triple-quote exits a raw string; everything else is inert. if c == '"' && i + 2 < inner.Length && inner[i + 1] == '"' && inner[i + 2] == '"' { inRaw = false i += 3 continue } } else if inStr { if c == '"' { inStr = false } } else if c == '"' && i + 2 < inner.Length && inner[i + 1] == '"' && inner[i + 2] == '"' { inRaw = true i += 3 continue } else if c == '"' { inStr = true } else if c == '(' || c == '[' || c == '<' || c == '{' { depth += 1 } else if c == ')' || c == ']' || c == '>' || c == '}' { depth -= 1 } else if c == ',' && depth == 0 { result.Add(inner.Substring(start, i - start).Trim()) start = i + 1 } i += 1 } if start < inner.Length { result.Add(inner.Substring(start, inner.Length - start).Trim()) } return result } // An E# identifier: [A-Za-z_][A-Za-z0-9_]* (specification/lexical.md). Used to reject // mis-parsed `entry` values (object initializers, `new`, fragments with spaces/braces) // before a fact is allowed to claim a runnable behavior. func isIdentifier(s: string) -> bool { if s.Length == 0 { return false } let c0 = s[0] if !char.IsLetter(c0) && c0 != '_' { return false } var i = 1 while i < s.Length { let c = s[i] if !char.IsLetter(c) && !char.IsDigit(c) && c != '_' { return false } i += 1 } return true } // The argument-list text inside the outermost parentheses of a call expression's // source, e.g. `Invoke(asm, "Test", "sumTo", 10)` -> `asm, "Test", "sumTo", 10`. func innerArgs(callText: string) -> string { let open = callText.IndexOf('(') let close = callText.LastIndexOf(')') if open < 0 || close <= open { return "" } return callText.Substring(open + 1, close - open - 1) } // The source-text of each argument of an invocation, parsed from its source text. func argTexts(inv: InvocationExpressionSyntax) -> List { return splitTopLevel(innerArgs(inv.ToString())) } // The first embedded E# program in a test method (most tests carry exactly one). func primarySource(m: MethodDeclarationSyntax) -> string { for lit in m.DescendantNodes().OfType() { let v = lit.Token.ValueText if looksLikeEsharp(v) { return v } } return "" } // The diagnostic code a negative test asserts, if any ("" otherwise). func diagCode(m: MethodDeclarationSyntax) -> string { for lit in m.DescendantNodes().OfType() { let v = lit.Token.ValueText if isDiagCode(v) { return v } } return "" } // Parse a runnable claim from an `Assert.Equal(expected, Invoke/Run(...))` invocation. // Fills entry/args/expected on `fact` and returns true on the dominant shapes: // Invoke(asm, "Test", "method", args...) — typeName + method, then args // Run(asm, "Test", "method", args...) // EsHarness.Run(src, "method", args...) — source expr, method, then args func tryRunnable(assertInv: InvocationExpressionSyntax, fact: Fact) -> bool { let assertArgs = argTexts(assertInv) if assertArgs.Count != 2 { return false } // The inner Invoke/Run call lives among the assert's descendants. for inner in assertInv.DescendantNodes().OfType() { let callee = inner.Expression.ToString() if callee.EndsWith("Invoke") || callee.EndsWith("Run") { let ia = argTexts(inner) if ia.Count < 2 { continue } var entry = "" let candidateArgs = List() // typeName-shape when the second arg is the literal "Test". if ia.Count >= 3 && ia[1] == "\"Test\"" { entry = unquote(ia[2]) var i = 3 while i < ia.Count { candidateArgs.Add(ia[i]) i += 1 } } else { // Run(src, "method", args...) shape. entry = unquote(ia[1]) var i = 2 while i < ia.Count { candidateArgs.Add(ia[i]) i += 1 } } // Guard: a mis-parsed entry (object initializer, `new`, a fragment with // braces/spaces) is not a valid method name. Skip it — the fact still ships // its source as compile-only ("unknown"), never a garbled runnable claim. if !isIdentifier(entry) { continue } fact.entry = entry for a in candidateArgs { fact.args.Add(a) } fact.expected = assertArgs[0] fact.kind = "runnable" return true } } return false } // Extract every [Fact]/[Theory] in one C# host file into Fact records. func extractFile(path: string) -> List { let facts = List() let text = System.IO.File.ReadAllText(path) let tree = CSharpSyntaxTree.ParseText(text) let root = tree.GetRoot() let fileName = System.IO.Path.GetFileName(path) for m in root.DescendantNodes().OfType() { if !isTestMethod(m) { continue } let src = primarySource(m) if src == "" { continue } // no embedded E# program — metadata/reflection test let fact = Fact { file: fileName, method: m.Identifier.ValueText, source: src, topic: classifyTopic(fileName, src) } // Runnable: an Assert.Equal whose second argument runs the program. var matched = false for inv in m.DescendantNodes().OfType() { if inv.Expression.ToString() == "Assert.Equal" { if tryRunnable(inv, fact) { matched = true } } } // Negative: asserts a diagnostic code instead of a value. if !matched { let code = diagCode(m) if code != "" { fact.kind = "negative" fact.diag = code } } facts.Add(fact) } return facts } // Read every hand-authored `.es` under `authoredDir` into "authored" Facts — the // curated, idiomatic tier. Topic is content-classified so they also surface under their // feature's topic; they are written to `corpus/authored/` regardless (see esPathOf). func ingestAuthored(authoredDir: string) -> List { let facts = List() if !System.IO.Directory.Exists(authoredDir) { return facts } for path in System.IO.Directory.GetFiles(authoredDir, "*.es") { let src = System.IO.File.ReadAllText(path) let name = System.IO.Path.GetFileName(path) let fact = Fact { file: name, method: "", source: src, kind: "authored", topic: classifyTopic(name, src) } facts.Add(fact) } return facts } // Read a multi-file program's `.es` files (one Fact per file, kind "program") — the // flagship "first real E# program". Written to `corpus/programs//`. func ingestProgram(programName: string, srcDir: string, fileNames: List) -> List { let facts = List() for fn in fileNames { let path = System.IO.Path.Combine(srcDir, fn) if !System.IO.File.Exists(path) { continue } let src = System.IO.File.ReadAllText(path) let fact = Fact { file: fn, method: "", source: src, kind: "program", program: programName, topic: "programs" } facts.Add(fact) } return facts } ``` ## extract_corpus__emit (programs, program) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: emit.es topic: programs status: unverified // part of extract_corpus — the first real E# program (multi-file, dogfood) namespace ExtractCorpus // Corpus output: write each example to a standalone `.es` file (by topic, or to authored/ // programs), plus a structured manifest, a JSONL training payload, and a coverage report. // Featured curation is applied post-hoc from an external `featured.txt` — tests are never // touched. A literal `{` anywhere in a string is mis-lexed as an interpolation-hole start // (known compiler gap), so JSON braces are emitted as char codes (123='{', 125='}') and // banners/ids are built with `+` rather than interpolation holes that contain `{`. // ---- Topic classification ------------------------------------------------- // Taxonomy bucket from the host test file name (fast path). func topicOf(file: string) -> string { if file.Contains("HeapPointer") || file.Contains("Refs") || file.Contains("Pointer") { return "pointers" } if file.Contains("Inheritance") { return "inheritance" } if file.Contains("Async") { return "async" } if file.Contains("Delegates") || file.Contains("Events") { return "delegates-events" } if file.Contains("Const") { return "const" } if file.Contains("Embedding") { return "embedding" } if file.Contains("StaticFunc") { return "static-func" } if file.Contains("Result") || file.Contains("Combinator") { return "result" } if file.Contains("FunctionPointers") { return "function-pointers" } if file.Contains("FieldDefaults") { return "field-defaults" } if file.Contains("Interop") || file.Contains("External") { return "interop" } if file.Contains("New") { return "allocation" } if file.Contains("TaskScope") || file.Contains("Concurrency") { return "concurrency" } if file.Contains("DataContract") { return "data" } return "core" } // True when an ordinary "..." string in `source` contains an interpolation hole ({letter). func hasInterpolation(source: string) -> bool { var inStr = false var i = 0 while i < source.Length { let c = source[i] if inStr { if c == '"' { inStr = false } else if c == '{' && i + 1 < source.Length && char.IsLetter(source[i + 1]) { return true } } else if c == '"' { inStr = true } i += 1 } return false } // True when `source` uses a pointer type `*T` ('*' directly followed by an uppercase letter). func hasStarType(source: string) -> bool { var i = 0 while i + 1 < source.Length { if source[i] == '*' && char.IsUpper(source[i + 1]) { return true } i += 1 } return false } // Content-based bucket for examples the filename heuristic dropped into "core". Order is // precedence: the most distinctive feature wins. func topicOfContent(source: string) -> string { if source.Contains("task func") || source.Contains("await ") || source.Contains("async ") || source.Contains("Job<") || source.Contains("chan<") { return "async" } if source.Contains("open ref data") || source.Contains("abstract ref data") || source.Contains("virtual func") || source.Contains("abstract func") || source.Contains(": base(") { return "inheritance" } if source.Contains("choice ") || source.Contains("match ") { return "choice" } if hasStarType(source) || source.Contains("HeapPointer") || source.Contains("StackAlloc") || source.Contains("HeapAlloc") { return "pointers" } if source.Contains("enum ") { return "enum" } if source.Contains("Result<") || source.Contains("ok(") || source.Contains("error(") { return "result" } if source.Contains("delegate func") || source.Contains("event ") || source.Contains("raise ") || source.Contains("&(") { return "delegates-events" } if source.Contains("") || source.Contains("") { return "generics" } if hasInterpolation(source) { return "interpolation" } if source.Contains("static func ") { return "static-func" } if source.Contains("using \"System") || source.Contains("using \"Microsoft") || source.Contains("StringBuilder") || source.Contains("Dictionary<") { return "interop" } if source.Contains("data ") { return "data" } return "core" } // Final topic: filename heuristic first, content classification for the "core" residue. func classifyTopic(file: string, source: string) -> string { let t = topicOf(file) if t == "core" { return topicOfContent(source) } return t } // ---- Identity / banner / paths -------------------------------------------- // Strip a trailing ".cs" or ".es" extension. func stripExt(file: string) -> string { if file.EndsWith(".cs") || file.EndsWith(".es") { return file.Substring(0, file.Length - 3) } return file } // Stable provenance id, as a free function over primitives. Program files: // `__`. Otherwise `[__]`. Kept // receiver-free so it can be called on `let`-bound Fact locals (a promoted method on a // `let`-local `ref data` receiver currently mis-emits — see tickets/compiler-gaps). func computeId(program: string, file: string, method: string) -> string { if program.Length > 0 { return program + "__" + stripExt(file) } let f = stripExt(file) if method.Length > 0 { return f + "__" + method } return f } // Promoted convenience: `fact.idOf()`. Safe on loop-variable / parameter receivers. func idOf(fact: Fact) -> string { return computeId(fact.program, fact.file, fact.method) } // Relative path of the example's `.es` within the corpus dir. func esPathOf(fact: Fact) -> string { if fact.kind == "program" { return "programs/" + fact.program + "/" + fact.file } if fact.kind == "authored" { return "authored/" + fact.idOf() + ".es" } return "examples/" + fact.topic + "/" + fact.idOf() + ".es" } // Per-`.es` header banner: an E#-identity line (doubles as the .es-vs-ECMAScript // disambiguator), provenance, and the verified behavior. Built with `+` so an `expected` // value containing `{` never trips interpolation-hole lexing. func banner(fact: Fact) -> string { var claim = "// compiles cleanly (no auto-run claim was extracted)" if fact.kind == "runnable" { claim = "// verified behavior: Test." + fact.entry + "(...) == " + fact.expected } else if fact.kind == "negative" { claim = "// verified behavior: reports diagnostic " + fact.diag } else if fact.kind == "authored" { claim = "// hand-authored, idiomatic E# — verified through the E# compiler" } else if fact.kind == "program" { claim = "// part of extract_corpus — the first real E# program (multi-file, dogfood)" } var status = "unverified" if fact.verified { status = "verified" } var prov = fact.file if fact.method.Length > 0 { prov = fact.file + "::" + fact.method } let l1 = "// E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript).\n" let l2 = "// provenance: " + prov + " topic: " + fact.topic + " status: " + status + "\n" return l1 + l2 + claim + "\n\n" } func jsonEscape(s: string) -> string { var r = s r = r.Replace("\\", "\\\\") r = r.Replace("\"", "\\\"") r = r.Replace("\r", "") r = r.Replace("\n", "\\n") r = r.Replace("\t", "\\t") return r } // Append a JSON string literal (quotes + escaped value), piece-by-piece — a hole with a // NESTED call (`{jsonEscape(f.idOf())}`, parens depth > 1) currently mis-parses. func appendStr(sb: StringBuilder, value: string) { sb.Append("\"") sb.Append(jsonEscape(value)) sb.Append("\"") } // ---- Dedup ---------------------------------------------------------------- // Conservative content key: normalize line endings + outer whitespace only (do not strip // comments) so we only collapse genuinely identical programs. func normalizeBody(source: string) -> string { var s = source.Replace("\r\n", "\n") s = s.Replace("\r", "\n") return s.Trim() } // Canonical preference (inlined in dedup to avoid a two-`ref data`-param promoted // method, which currently mis-emits the receiver — see tickets/compiler-gaps): // a non-core topic beats core, then verified beats unverified, then the shorter id. func betterCanonical(candTopic: string, candVerified: bool, candIdLen: int, curTopic: string, curVerified: bool, curIdLen: int) -> bool { let candCore = candTopic == "core" let curCore = curTopic == "core" if candCore != curCore { return !candCore } if candVerified != curVerified { return candVerified } return candIdLen < curIdLen } // Collapse identical-source facts to one canonical each, preserving every absorbed // `file::method` in `origins` and the group size in `duplicateCount`. No silent drops: // Σ duplicateCount == input count, and every input id lands in some `origins`. // // Implementation note: every Fact member is touched only through a *loop variable*. // All maps hold strings / List / bool — never a Fact — because member access on // a ref-data value pulled out of a generic collection currently mis-emits (the receiver // is loaded by address). See tickets/compiler-gaps-corpus-extractor.md. func dedup(facts: List) -> List { // Pass 1 — group by normalized source. Track all ids per key (the future // `origins`), and the chosen-canonical's identity as primitives. let idsByKey = Dictionary>() // key -> every id in the group let bestId = Dictionary() // key -> chosen canonical id let bestTopic = Dictionary() let bestVer = Dictionary() let bestLen = Dictionary() for fact in facts { let key = normalizeBody(fact.source) let id = computeId(fact.program, fact.file, fact.method) if !idsByKey.ContainsKey(key) { idsByKey[key] = List() bestId[key] = id bestTopic[key] = fact.topic bestVer[key] = fact.verified bestLen[key] = id.Length } else if betterCanonical(fact.topic, fact.verified, id.Length, bestTopic[key], bestVer[key], bestLen[key]) { bestId[key] = id bestTopic[key] = fact.topic bestVer[key] = fact.verified bestLen[key] = id.Length } idsByKey[key].Add(id) } // Pass 2 — emit the canonical fact of each group (the one whose id is `bestId`), // stamping its provenance; mark the rest non-canonical. Both happen on loop vars. let result = List() for fact in facts { let key = normalizeBody(fact.source) let id = computeId(fact.program, fact.file, fact.method) if id == bestId[key] { fact.origins = idsByKey[key] fact.duplicateCount = idsByKey[key].Count fact.canonical = true result.Add(fact) } else { fact.canonical = false } } return result } // ---- Writers -------------------------------------------------------------- // Delete the generated example trees so a re-run never leaves stale files (a renamed // topic, a removed test, a different dedup choice) behind in the published corpus. // Only the generated subdirs are touched; manifest.json / corpus.jsonl / coverage.md are // overwritten in place, and featured.txt (curation input) is left alone. func cleanOutput(corpusDir: string) { let dirs = List() dirs.Add("examples") dirs.Add("authored") dirs.Add("programs") dirs.Add("featured") for d in dirs { let p = System.IO.Path.Combine(corpusDir, d) if System.IO.Directory.Exists(p) { System.IO.Directory.Delete(p, true) } } } // Write every example to its `.es` path (examples//, authored/, or programs/

/). func writeCorpus(facts: List, corpusDir: string) { cleanOutput(corpusDir) for fact in facts { let path = System.IO.Path.Combine(corpusDir, fact.esPathOf()) let dir = System.IO.Path.GetDirectoryName(path) System.IO.Directory.CreateDirectory(dir) System.IO.File.WriteAllText(path, fact.banner() + fact.source) } } // Write manifest.json — one entry per example, hand-rolled so source stays in the .es // files (esPath points at them) and only metadata lands here. func writeManifest(facts: List, corpusDir: string) { let sb = StringBuilder() sb.Append("[\n") var first = true for fact in facts { if !first { sb.Append(",\n") } first = false var v = "false" if fact.verified { v = "true" } let dc = fact.duplicateCount sb.Append(" ") sb.Append(Convert.ToChar(123)) sb.Append("\"id\":") appendStr(sb, fact.idOf()) sb.Append(",\"topic\":") appendStr(sb, fact.topic) sb.Append(",\"kind\":") appendStr(sb, fact.kind) sb.Append(",\"program\":") appendStr(sb, fact.program) sb.Append(",\"esPath\":") appendStr(sb, fact.esPathOf()) sb.Append(",\"entry\":") appendStr(sb, fact.entry) sb.Append(",\"expected\":") appendStr(sb, fact.expected) sb.Append(",\"diag\":") appendStr(sb, fact.diag) sb.Append(",\"verified\":") sb.Append(v) sb.Append(",\"duplicateCount\":") sb.Append(Convert.ToString(dc)) sb.Append(",\"args\":[") var af = true for a in fact.args { if !af { sb.Append(",") } af = false appendStr(sb, a) } sb.Append("]") sb.Append(",\"origins\":[") var of = true for o in fact.origins { if !of { sb.Append(",") } of = false appendStr(sb, o) } sb.Append("]") sb.Append(Convert.ToChar(125)) } sb.Append("\n]\n") System.IO.File.WriteAllText(System.IO.Path.Combine(corpusDir, "manifest.json"), sb.ToString()) } // Write corpus.jsonl — one JSON object per line with INLINE source + metadata. This is // the HuggingFace-ready training payload; consumers load it directly. func writeJsonl(facts: List, corpusDir: string) { let sb = StringBuilder() for fact in facts { var v = "false" if fact.verified { v = "true" } let dc = fact.duplicateCount sb.Append(Convert.ToChar(123)) sb.Append("\"id\":") appendStr(sb, fact.idOf()) sb.Append(",\"topic\":") appendStr(sb, fact.topic) sb.Append(",\"kind\":") appendStr(sb, fact.kind) sb.Append(",\"program\":") appendStr(sb, fact.program) sb.Append(",\"entry\":") appendStr(sb, fact.entry) sb.Append(",\"expected\":") appendStr(sb, fact.expected) sb.Append(",\"diag\":") appendStr(sb, fact.diag) sb.Append(",\"verified\":") sb.Append(v) sb.Append(",\"duplicateCount\":") sb.Append(Convert.ToString(dc)) sb.Append(",\"source\":") appendStr(sb, fact.source) sb.Append(Convert.ToChar(125)) sb.Append("\n") } System.IO.File.WriteAllText(System.IO.Path.Combine(corpusDir, "corpus.jsonl"), sb.ToString()) } // Write coverage.md — totals per bucket, verification rate, and dedup summary. No silent // drops: the unknown bucket and the collapsed-duplicate counts are reported. func writeCoverage(facts: List, corpusDir: string, fileCount: int) { var runnable = 0 var negative = 0 var unknown = 0 var authored = 0 var program = 0 var verified = 0 var redundant = 0 var groups = 0 for fact in facts { if fact.kind == "runnable" { runnable += 1 } else if fact.kind == "negative" { negative += 1 } else if fact.kind == "authored" { authored += 1 } else if fact.kind == "program" { program += 1 } else { unknown += 1 } if fact.verified { verified += 1 } if fact.duplicateCount > 1 { groups += 1 redundant += fact.duplicateCount - 1 } } let sb = StringBuilder() sb.Append("# E# corpus — extraction & verification coverage\n\n") sb.Append("Generated by `tools/extract_corpus` (written in E#).\n\n") sb.Append("| metric | count |\n") sb.Append("|---|---|\n") sb.Append("| host files scanned | {fileCount} |\n") sb.Append("| canonical examples | {facts.Count} |\n") sb.Append("| runnable (value claim) | {runnable} |\n") sb.Append("| negative (diagnostic) | {negative} |\n") sb.Append("| unknown (compile-only) | {unknown} |\n") sb.Append("| authored (artisanal) | {authored} |\n") sb.Append("| program (flagship) | {program} |\n") sb.Append("| re-verified through the E# compiler | {verified} |\n") sb.Append("| duplicate groups collapsed | {groups} |\n") sb.Append("| redundant files removed | {redundant} |\n") System.IO.File.WriteAllText(System.IO.Path.Combine(corpusDir, "coverage.md"), sb.ToString()) } // Featured curation, applied post-hoc: read `featured.txt` (one id per line) and copy the // named examples into `featured/`. The test files are never touched. func applyFeatured(facts: List, corpusDir: string) { let listPath = System.IO.Path.Combine(corpusDir, "featured.txt") if !System.IO.File.Exists(listPath) { return } let wanted = List() for line in System.IO.File.ReadAllLines(listPath) { let t = line.Trim() if t.Length > 0 && !t.StartsWith("#") { wanted.Add(t) } } if wanted.Count == 0 { return } let featuredDir = System.IO.Path.Combine(corpusDir, "featured") System.IO.Directory.CreateDirectory(featuredDir) for fact in facts { let id = fact.idOf() if wanted.Contains(id) { let dst = System.IO.Path.Combine(featuredDir, id + ".es") System.IO.File.WriteAllText(dst, fact.banner() + fact.source) } } } ``` ## extract_corpus__verify (programs, program) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: verify.es topic: programs status: unverified // part of extract_corpus — the first real E# program (multi-file, dogfood) namespace ExtractCorpus // Stage 2 — Re-verify: each extracted example is recompiled through the E# IL backend // (the source-of-truth pipeline EsHarness uses) so every published example is provably // green, decoupled from xUnit. This is the cleanest dogfood: E# invoking the E# compiler. // // Per-file `using`s scope these Esharp.* imports to this file only — extract.es imports // Roslyn under the same namespace with no collision (per-file import scoping). using "Esharp.Compiler.Parsing" using "Esharp.Compiler.Binding" using "Esharp.Compiler.Diagnostics" using "Esharp.ILEmit" // True when `source` parses, binds, and emits verifiable IL with zero errors — the same // parse -> bind -> emit(verify) pipeline the test harness runs. A corpus example that // passes here is provably compilable independent of the test suite. func verifyCompiles(source: string) -> bool { let parser = Parser(source, "corpus.es") let unit = parser.ParseCompilationUnit() // Only hard parse ERRORS disqualify an example — a warning (e.g. a deprecation // notice) still compiles and runs. Mirror the binder/emit error filtering below. for d in parser.Diagnostics { if d.Severity == DiagnosticSeverity.Error { return false } } let binder = Binder() let bound = binder.Bind(unit) for d in binder.Diagnostics { if d.Severity == DiagnosticSeverity.Error { return false } } let tmp = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "corpus_verify.dll") // Pass implicitUsings=true explicitly (final arg). Omitting this trailing optional // makes E# zero-fill it to default(bool)=false rather than honoring C#'s default // (true), which disables the implicit BCL-namespace search and leaves unqualified // types like `List()` unresolved. See tickets/compiler-gaps-corpus-extractor.md. let emitDiags = ILEmitter.EmitToFile(bound, "corpus_verify", tmp, false, nil, true, true) for d in emitDiags { if d.Severity == DiagnosticSeverity.Error { return false } } return true } // True when binding `source` reports the expected diagnostic code — a negative example // is "verified" when it still produces the error its [Fact] asserted. func verifyDiagnostic(source: string, code: string) -> bool { let parser = Parser(source, "corpus.es") let unit = parser.ParseCompilationUnit() let binder = Binder() binder.Bind(unit) for d in binder.Diagnostics { if d.Message.Contains(code) { return true } } return false } // Set `verified` on each fact by re-running it through the compiler: runnable/unknown // examples must compile clean; negative examples must still surface their diagnostic. func verifyAll(facts: List) { for fact in facts { try { if fact.kind == "negative" { fact.verified = verifyDiagnostic(fact.source, fact.diag) } else { fact.verified = verifyCompiles(fact.source) } } catch { // A malformed extraction that throws inside the compiler is simply // unverified — never abort the whole run. fact.verified = false } } } ``` ## extract_corpus__main (programs, program) ```es // E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript). // provenance: main.es topic: programs status: unverified // part of extract_corpus — the first real E# program (multi-file, dogfood) namespace ExtractCorpus // extract_corpus — the E#-written tool that lifts the verified `.es` corpus out of the // test suite (Stage 1, Roslyn) and independently re-verifies each example through the E# // compiler (Stage 2), then writes corpus/examples + authored + the flagship program, plus // manifest.json, corpus.jsonl (training payload), and coverage.md. Dogfood: the toolchain // that ships E# runs on E#. // // Stage 1 (extract.es) C# host files -> per-[Fact] Fact records via Roslyn // Stage 2 (verify.es) each example recompiled through the E# IL backend // dedup (emit.es) collapse identical sources, preserve provenance // output (emit.es) corpus/{examples,authored,programs} + manifest + jsonl + coverage func main() { // Paths are relative to the esharp repo root (run the tool from there), or pass // absolute positional argv overrides for CI: // extract_corpus var testDir = "tests/Esharp.Tests" var corpusDir = "corpus" var toolDir = "tools/extract_corpus" let argv = System.Environment.GetCommandLineArgs() if argv.Length > 1 { testDir = argv[1] } if argv.Length > 2 { corpusDir = argv[2] } if argv.Length > 3 { toolDir = argv[3] } // Stage 1 — extract from C# host files. let files = System.IO.Directory.GetFiles(testDir, "*.cs") let extracted = List() for f in files { for fact in extractFile(f) { extracted.Add(fact) } } Console.WriteLine("Stage 1: extracted {extracted.Count} examples from {files.Length} host files.") // Stage 2 — re-verify each through the E# compiler. Console.WriteLine("Stage 2: re-verifying extracted examples (this recompiles every one)...") verifyAll(extracted) // Dedup the extracted bulk (authored + program are curated/unique, kept as-is). let canon = dedup(extracted) Console.WriteLine("Dedup: {extracted.Count} -> {canon.Count} canonical.") // Artisanal hand-authored examples. let authoredDir = System.IO.Path.Combine(toolDir, "authored") let authored = ingestAuthored(authoredDir) verifyAll(authored) Console.WriteLine("Authored: {authored.Count} artisanal examples.") // Flagship program: extract_corpus's own source — the first real E# program. let programFiles = List() programFiles.Add("extract.es") programFiles.Add("emit.es") programFiles.Add("verify.es") programFiles.Add("main.es") let program = ingestProgram("extract_corpus", toolDir, programFiles) verifyAll(program) Console.WriteLine("Program: {program.Count} flagship files.") // Combine and write. let all = List() for fact in canon { all.Add(fact) } for fact in authored { all.Add(fact) } for fact in program { all.Add(fact) } writeCorpus(all, corpusDir) writeManifest(all, corpusDir) writeJsonl(all, corpusDir) writeCoverage(all, corpusDir, files.Length) applyFeatured(all, corpusDir) var runnable = 0 var negative = 0 var unknown = 0 for fact in canon { if fact.kind == "runnable" { runnable += 1 } else if fact.kind == "negative" { negative += 1 } else { unknown += 1 } } var verified = 0 for fact in all { if fact.verified { verified += 1 } } Console.WriteLine("=== extract_corpus complete ===") Console.WriteLine(" total: {all.Count}") Console.WriteLine(" runnable {runnable} negative {negative} unknown {unknown} authored {authored.Count} program {program.Count}") Console.WriteLine(" re-verified: {verified}/{all.Count}") Console.WriteLine(" written to: {corpusDir}") } ```