// ── FeatureMixingTests__Axis2_DeferLifoOrder_InsideAndAroundSpawn ── // 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_SpawnCapturesPointer_MutatesThroughIt ── // 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__Axis4_PointerEmbedded_PointerReceiverSatisfiesProtocol ── // 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) } // ── ForwardReferenceTests__Data_PointerField_Of_LaterData ── // 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 } // ── ILEmitterTests_Coverage_Adversarial__Ns_PointerReceiverFreeCall_IsAllowed ── // 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_Collections__Added_DictStringToPointer ── // 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_ControlFlow__Added_Defer_RunsInReverse ── // 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_If_PointerNilGuard ── // 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_While_EarlyReturnViaPointer ── // 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__Defer_LifoOrder ── // 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_NestedScopes ── // 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__Defer_RunsAfterLoopBody ── // 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_RunsOnEarlyReturn ── // 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 ── // 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_Data__Defer_RunsInLifoOrder ── // 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_Errors__Defer_RunsAsCleanupInTry ── // 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 ── // 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_Misc__Pointer_LinkedListLength ── // 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_FunctionPointers__FunctionPointer_CallThroughLocal_ReturnsCorrectResult ── // 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_InStructField_Works ── // 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) } // ── ILEmitterTests_FunctionPointers__FunctionPointer_TypedParameter_Works ── // 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_VoidReturn_Works ── // 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 ── // 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_HeapPointer__Added_New_FieldSum ── // 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_NilPointerDefaultThenAssign ── // 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_PointerFieldReassignedThroughChain ── // 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 ── // 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_PointerReturnedAndChained ── // 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 ── // 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 } // ── ILEmitterTests_HeapPointer__HeapPointer_AddressOfLocal_CopiesToHeap ── // 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_AssignNil ── // 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_Auto_Deref_Field_Access ── // 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__HeapPointer_AutoDeref_Read ── // 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 ── // 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_BothCallSyntaxes ── // 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__HeapPointer_CompoundAssignment ── // 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_DotSyntax_StaticCall ── // 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_FieldDeclaration_Compiles ── // 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_FieldInStruct ── // 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_HeapAlloc_StoresValue ── // 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_LinkedList_EndToEnd ── // 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_LocalVariable_ExplicitType ── // 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 ── // 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 ── // 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_NamedReceiver_DataType ── // 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 ── // 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_NestedAutoDeref ── // 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 ── // 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_Nil_Default_Construction ── // 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_NilByDefault ── // 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 ── // 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_NonNil_Compare_Returns_False_To_Nil ── // 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_ReceiverMutatesThroughPointer ── // 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_ReturnType ── // 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_SelfReferential_StaysStruct ── // 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_StarRefData_Error ── // 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_StructProtocol_ImplicitSatisfaction ── // 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__PointerProtocol_AllMethodsRequired ── // 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_Compiles ── // 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_MixedMethodSet ── // 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_ValueReceiverInBothSets ── // 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_ValueTypeDoesNotSatisfy ── // 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_WrapperHasDelegateMethods ── // 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_Nominal__Added_PointerOnlyConformance_Wrapper ── // 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__PointerOnlyReceiver_Declared_SatisfiedViaWrapper ── // 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_PointerCollections__Dictionary_PointerValue_Iterate ── // 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__DictionaryStringToPointer ── // 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__ExplicitListOfPointers_AddThenIndex ── // 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 ── // 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__GenericData_HoldingPointer ── // 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__GenericData_Nested_PointerInner ── // 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__GenericData_PointerField_Mutate ── // 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__List_OfInts_Index ── // 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_OfPointers_Count ── // 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__List_OfPointers_ForIn_Sum ── // 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_OfPointers_IndexZero ── // 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_OfValueData_ForIn_Sum ── // 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_OfValueData_Index ── // 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__NestedListOfPointerLists ── // 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 ── // 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_CountAfterAdds ── // 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__PointerList_IterateAndMutate ── // 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__PointerList_NestedFieldAccess ── // 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__PointerList_PassToValueDataMethod ── // 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__PointerListField_RoundTrip ── // 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__PointerListParam_Sum ── // 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__PointerListReturn ── // 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__PointerReturnedFromListBoundMethod ── // 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__TupleOfInts_Item ── // 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__TupleOfMixed_PointerAndInt ── // 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__TupleOfPointers_Destructure ── // 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__TupleOfPointers_ItemDeref ── // 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__TupleOfThreePointers_Destructure ── // 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_PointerModel__Coercion_WrapperArg_ToByRefParam_Mutates ── // 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__Coercion_WrapperPassedWithStarSyntax ── // 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__Downgrade_ByRefParam_AliasesCallerLocal ── // 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 ── // 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 ── // 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__EscapingAddressOfLocal_AliasesLocal ── // 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__EscapingAddressOfLocal_ForwardValue ── // 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_TwoAliasesShareCell ── // 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 ── // 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_PointerModel__NullCompared_Param_ForcesWrapper ── // 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__PrimitivePointer_Field_IsNullableWrapper ── // 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__ReturnHoist_AddressOfLocal ── // 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__StarRefData_IsError ── // 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_PtrListRepro__ListCtor_WithHeapPointerData_Resolves ── // 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 ── // 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_Refs__AddressOf_PassedToByRefParam_Works ── // 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__OutParam_HasByRefAndOutAttribute ── // 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_Int_WritesThrough ── // 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 ── // 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_TryPattern_BothBranchesAssign ── // 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 } // ── ILEmitterTests_Refs__ReadOnlyByRef_CanReadThrough ── // 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_HasInAttribute ── // 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__ReadOnlyByRef_StructFieldAccess_Works ── // 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__RefLocal_MultipleWrites_Accumulate ── // 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__RefLocal_ReadThroughPointer_Works ── // 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 ── // 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 } // ── ILEmitterTests2__LinkedList_Length_Via_HeapPointer_Pin ── // 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) } // ── ILEmitterTests3__HeapPointer_Nil_Comparison_True ── // 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 ── // 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__HeapPointer_To_Data_Carries_Value ── // 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__LinkedList_Sum_Pin ── // 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__Tree_Structure_Compiles_Pin ── // 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 } // ── linked_list_and_tail ── // 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 } // ── pointers_and_sharing ── // 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 } // ── TranspilerTests__Transpiles_ByRef_Parameters ── // 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 } // ── ILEmitterTests_HeapPointer__HeapPointer_AssignT_ToStarT_WithoutAmpersand_Error ── // 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_PointerCollections__GenericFirst_OverPointerList ── // 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__GenericFirst_PointerInferred ── // 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__GenericIdentity_OnPointer ── // 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_PtrEmbedIface__PointerEmbed_BumpMutatesThroughPointer ── // 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_PromotedDirectAccess ── // 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_Refs__OutParam_EsharpCallSite_PassesByRef ── // 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 }