✓
Passing This code compiles and runs correctly.
Code
// PINS: a handle-addressed READ survives both places it used to be dropped —
// inside a MULTI-FIELD envelope, and inside another indexed read's INDEX.
//
// Two defects, one shape, found together by trying to walk an intrusive chain.
//
// (1) `stored` has TWO lowerings. A row-addressed envelope and the
// single-write path both ran the full expression lowering; the
// non-row-addressed plural envelope ran only its OWN store's rewrite, so
// a value reading any other store — or reading one through a handle at
// all — reached the host verbatim as `cells[...]`. One field worked and
// two did not, which is the tell for a second lowering rather than a
// missing feature.
//
// (2) `indexedFieldRefs` consumed the whole matched span, so an indexed read
// sitting INSIDE another one's index was never visited. That is exactly
// one hop along a chain — `cells[cells[h].next].v` — and it is the shape
// any linked structure is walked with.
//
// The consumer's spelling, not the minimal one: three rows chained at insert
// (`| row` is the only place a handle is minted), then walked THREE hops deep
// through a plural envelope. Handles are opaque and branded, so the oracle is
// the values they reach, never the handle numbers.
//
// Found writing the ECS benchmark's spatial grid: an intrusive bucket chain
// needs no nested collections, no positional addressing and no new verb — only
// these two reads. What it still lacks is a way to name the handle of the row a
// SWEEP is visiting; `[id]` is refused-and-named by the request block today.
import std/io
import std/store
std/store:new(cells, capacity: 8) { v: i64, next: -1[i64] }
std/store:new(head) { h: -1[i64] }
std/store:new(probe) { v1: 0[i64], v2: 0[i64], v3: 0[i64] }
std/store:insert(cells) { v: 10, next: -1 }
| row a |> std/store:stored { head.h: a }
| full |> _
std/store:insert(cells) { v: 20, next: head.h }
| row b |> std/store:stored { head.h: b }
| full |> _
std/store:insert(cells) { v: 30, next: head.h }
| row c |> std/store:stored { head.h: c }
| full |> _
// Multi-field envelope, and the second field is a NESTED indexed read.
std/store:stored { probe.v1: cells[head.h].v, probe.v2: cells[cells[head.h].next].v }
// Three hops — the nesting recurses, it does not merely survive one level.
std/store:stored { probe.v3: cells[cells[cells[head.h].next].next].v }
std/io:print.ln("hop1 {{ probe.v1:d }} hop2 {{ probe.v2:d }} hop3 {{ probe.v3:d }}")
Supporting Files
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"a_cs_equiv/1.0.0": {
"runtime": {
"a_cs_equiv.dll": {}
}
}
}
},
"libraries": {
"a_cs_equiv/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}hop1 30 hop2 20 hop3 10
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<AssemblyName>a_cs_equiv</AssemblyName>
<WarningLevel>0</WarningLevel>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<Compile Include="output_emitted.cs" />
</ItemGroup>
</Project>
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("a_cs_equiv")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+73ba11db56be006bccd0e336c10b98e84afb8a8a")]
[assembly: System.Reflection.AssemblyProductAttribute("a_cs_equiv")]
[assembly: System.Reflection.AssemblyTitleAttribute("a_cs_equiv")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.
781bcb8eb7f6067e092418577e860799fe5cda0e2c63b7711dbb724cd1e01e1a
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = koru
build_property.ProjectDir = /Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =
5be0995b741828a5c320155d1f80abdffa79d05541ea191d12e3a61e37fca459
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/koru.GeneratedMSBuildEditorConfig.editorconfig
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/koru.AssemblyInfoInputs.cache
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/koru.AssemblyInfo.cs
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/koru.csproj.CoreCompileInputs.cache
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/koru.sourcelink.json
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/a_cs_equiv
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/refint/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/a_cs_equiv.pdb
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/a_cs_equiv.deps.json
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/koru.genruntimeconfig.cache
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/a_cs_equiv.runtimeconfig.json
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/Debug/net8.0/ref/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/a_cs_equiv.pdb
c3d6f118f34a58da33ee3f7afdb402340ee6ec60dfb29ae4e17a351f9b1bc803
{"documents":{"/Users/larsde/src/koru/*":"https://raw.githubusercontent.com/korulang/koru/73ba11db56be006bccd0e336c10b98e84afb8a8a/*"}}{
"format": 1,
"restore": {
"/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/koru.csproj": {}
},
"projects": {
"/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/koru.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/larsde/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"/opt/homebrew/Cellar/dotnet/9.0.0/libexec/library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Host.osx-arm64",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/opt/homebrew/Cellar/dotnet/9.0.0/libexec/sdk/9.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/larsde/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/larsde/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/Users/larsde/.nuget/packages/" />
</ItemGroup>
</Project><?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />{
"version": 3,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"/Users/larsde/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/larsde/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"/opt/homebrew/Cellar/dotnet/9.0.0/libexec/library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Host.osx-arm64",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/opt/homebrew/Cellar/dotnet/9.0.0/libexec/sdk/9.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}{
"version": 2,
"dgSpecHash": "kszw7AFnyV8=",
"success": true,
"projectFilePath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_245_indexed_read_in_plural_envelope_and_nested/koru.csproj",
"expectedPackageFiles": [
"/Users/larsde/.nuget/packages/microsoft.netcore.app.ref/8.0.11/microsoft.netcore.app.ref.8.0.11.nupkg.sha512",
"/Users/larsde/.nuget/packages/microsoft.aspnetcore.app.ref/8.0.11/microsoft.aspnetcore.app.ref.8.0.11.nupkg.sha512",
"/Users/larsde/.nuget/packages/microsoft.netcore.app.host.osx-arm64/8.0.11/microsoft.netcore.app.host.osx-arm64.8.0.11.nupkg.sha512"
],
"logs": []
}static class main_module {
public static void __koru_stdout_write(dynamic s) => global::System.Console.Out.Write(s);
public static void __koru_stderr_write(dynamic s) => global::System.Console.Error.Write(s);
// The mutable handle carrier — `*String`-style resources are
// `new __KoruBox { data = … }` because C# anonymous types are
// read-only: `s.data = …` (std/string append/clear, handle
// mutation generally) needs a settable member.
public class __KoruBox { public dynamic data; }
// Textification for `{{ … }}` operands: C# bool ToStrings as
// `True` where Koru prints `true`, and the operand's static type
// is unknown at this boundary — a `(x) is bool` inline test would
// be a compile error on statically-typed operands instead. Generic
// on purpose: `dynamic` boxed every value-type operand — measured
// ~1s/10M elements on 012_threat_scanner — while T specializes to
// the operand's own ToString() with no box.
public static string __koru_str<T>(T v) => v is bool b ? (b ? "true" : "false") : v?.ToString();
// std/store: plural store 'cells' created (SoA cell + insert/query/write/take/stripe units); fields v: i64, next: i64
// std/store: 'head' created (cell + write-subflow at module scope); fields h: i64
// std/store: 'probe' created (cell + write-subflow at module scope); fields v1: i64, v2: i64, v3: i64
static class __koru_store_cells {
public static long[] v = new long[8];
public static dynamic __koru_read_v(long __h) { long __r = __koru_resolve(__h); return v[(int)__r]; }
public static long[] next = new long[8];
public static dynamic __koru_read_next(long __h) { long __r = __koru_resolve(__h); return next[(int)__r]; }
public static long len = 0;
public static long[] __koru_hslot_row = new long[8];
public static long[] __koru_hslot_gen = new long[8];
public static long[] __koru_row_hslot = new long[8];
public static long[] __koru_hslot_free = new long[8];
public static long __koru_hslot_free_len = 0;
public static long __koru_hslot_next = 0;
public static long __koru_brand = 1;
public static bool __koru_ident = true;
public static bool __koru_gen0 = true;
public static void __koru_materialize() {
if (!__koru_ident) return;
for (long __i = 0; __i < len; __i++) { __koru_hslot_row[__i] = __i; __koru_row_hslot[__i] = __i; }
__koru_ident = false;
}
public static long __koru_row_of(long h) {
if (h < 0) return -1;
ulong __u = (ulong)h;
long __slot32 = (long)(__u & 0xFFFFFFFFUL);
if ((__slot32 >> 24) != __koru_brand) return -1;
long __slot = __slot32 & 0xFFFFFF;
if (__slot >= __koru_hslot_next) return -1;
if (__koru_gen0) { if ((__u >> 32) != 0) return -1; return __slot; }
if ((long)(__u >> 32) != __koru_hslot_gen[__slot]) return -1;
if (__koru_ident) return __slot;
long __r = __koru_hslot_row[__slot];
if (__r >= len) return -1;
return __r;
}
public static long __koru_resolve(long h) {
if (h >= 0) {
ulong __u = (ulong)h;
long __slot32 = (long)(__u & 0xFFFFFFFFUL);
if ((__slot32 >> 24) != __koru_brand) throw new global::System.Exception("std/store: 'cells[...]' does not address a row - the value is not a handle this store issued (handles come from `| row` and row cursors)");
long __slot = __slot32 & 0xFFFFFF;
if (__koru_gen0) {
if ((__u >> 32) != 0 && __slot < __koru_hslot_next) throw new global::System.Exception("std/store: stale row handle into store 'cells' - the row it addressed was removed (stale-handle trap pinned at 690_115)");
} else if (__slot < __koru_hslot_next && (long)(__u >> 32) != __koru_hslot_gen[__slot]) throw new global::System.Exception("std/store: stale row handle into store 'cells' - the row it addressed was removed (stale-handle trap pinned at 690_115)");
}
long __r = __koru_row_of(h);
if (__r < 0) throw new global::System.Exception("std/store: 'cells[...]' does not address a row - the value is not a handle this store issued (handles come from `| row` and row cursors)");
return __r;
}
public static long __koru_handle_of(long dense) {
if (__koru_gen0) return dense | (__koru_brand << 24);
long __slot = dense;
if (!__koru_ident) __slot = __koru_row_hslot[dense];
return (__slot | (__koru_brand << 24)) | (__koru_hslot_gen[__slot] << 32);
}
}
static class __koru_store_head {
public static long h = -1;
public static long __koru_brand = -1;
}
static class __koru_store_probe {
public static long v1 = 0;
public static long v2 = 0;
public static long v3 = 0;
public static long __koru_brand = -1;
}
public static class __store_insertf_cells_event {
public struct Input {
public long v;
public long next;
public long __site_line;
}
public struct Output {
public string tag;
public long row;
public dynamic full;
}
public static Output handler(Input __koru_input) {
var v = __koru_input.v;
var next = __koru_input.next;
var __site_line = __koru_input.__site_line;
if (__koru_store_cells.len >= 8) return new Output { tag = "full", full = new { } };
if (__koru_store_cells.len >= 8) throw new global::System.Exception("std/store: store 'cells' is full (capacity 8) - declared capacity and the `| full` branch are pinned at 690_011");
long __koru_new_row = __koru_store_cells.len;
long __koru_hslot;
if (__koru_store_cells.__koru_hslot_free_len > 0) {
__koru_store_cells.__koru_hslot_free_len -= 1;
__koru_hslot = __koru_store_cells.__koru_hslot_free[__koru_store_cells.__koru_hslot_free_len];
} else {
__koru_hslot = __koru_store_cells.__koru_hslot_next;
__koru_store_cells.__koru_hslot_next += 1;
}
if (!__koru_store_cells.__koru_ident) {
__koru_store_cells.__koru_hslot_row[__koru_hslot] = __koru_new_row;
__koru_store_cells.__koru_row_hslot[__koru_new_row] = __koru_hslot;
}
__koru_store_cells.v[__koru_new_row] = v;
__koru_store_cells.next[__koru_new_row] = next;
__koru_store_cells.len += 1;
return new Output { tag = "row", row = __koru_store_cells.__koru_handle_of(__koru_new_row) };
return default;
}
}
public static class __store_apply_cells_event {
public struct Input {
public long row;
public long field;
public long value_0;
public long value_1;
}
public struct Output {
public string tag;
public long v;
public long next;
}
public static Output handler(Input __koru_input) {
var row = __koru_input.row;
var field = __koru_input.field;
var value_0 = __koru_input.value_0;
var value_1 = __koru_input.value_1;
var __koru_r = row;
switch (field) {
case 0: { __koru_store_cells.v[__koru_r] = value_0; return new Output { tag = "v", v = value_0 }; }
case 1: { __koru_store_cells.next[__koru_r] = value_1; return new Output { tag = "next", next = value_1 }; }
}
throw new global::System.Exception("__store_apply_cells: field index " + field + " is not a column of store 'cells'");
return default;
}
}
public static class __store_apply_head_event {
public struct Input {
public long field;
public long value;
}
public struct Output {
public string tag;
public long h;
}
public static Output handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
switch (field) {
case 0: { __koru_store_head.h = value; return new Output { tag = "h", h = value }; }
}
throw new global::System.Exception("__store_apply_head: field index " + field + " is not a column of store 'head'");
return default;
}
}
public static class __store_write_head_event {
public struct Input {
public long field;
public long value;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
var result_0 = main_module.__store_apply_head_event.handler(new __store_apply_head_event.Input { field = (long)(field), value = (long)(value)});
var _auto_8 = result_0.h;
return default;
}
}
public static class __store_announce_head_event {
public struct Input {
public long field;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
return default;
}
}
public static class __store_apply_probe_event {
public struct Input {
public long field;
public long value;
}
public struct Output {
public string tag;
public long v1;
public long v2;
public long v3;
}
public static Output handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
switch (field) {
case 0: { __koru_store_probe.v1 = value; return new Output { tag = "v1", v1 = value }; }
case 1: { __koru_store_probe.v2 = value; return new Output { tag = "v2", v2 = value }; }
case 2: { __koru_store_probe.v3 = value; return new Output { tag = "v3", v3 = value }; }
}
throw new global::System.Exception("__store_apply_probe: field index " + field + " is not a column of store 'probe'");
return default;
}
}
public static class __store_write_probe_event {
public struct Input {
public long field;
public long value;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
var result_1 = main_module.__store_apply_probe_event.handler(new __store_apply_probe_event.Input { field = (long)(field), value = (long)(value)});
if (result_1.tag == "v1") {
var _auto_9 = result_1.v1;
}
if (result_1.tag == "v2") {
var _auto_10 = result_1.v2;
}
if (result_1.tag == "v3") {
var _auto_11 = result_1.v3;
}
return default;
}
}
public static class __store_announce_probe_event {
public struct Input {
public long field;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
return default;
}
}
public static class __store_envwrite_probe_event {
public struct Input {
public long field;
public long value;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
var __koru_mask = (ulong)field;
if ((__koru_mask & (1UL << 0)) != 0) __koru_store_probe.v1 = value;
if ((__koru_mask & (1UL << 1)) != 0) __koru_store_probe.v2 = value;
if ((__koru_mask & (1UL << 2)) != 0) __koru_store_probe.v3 = value;
return default;
}
}
public static class std_io_print_ln_event {
public struct Input {
public dynamic expr;
public dynamic invocation;
public dynamic item;
public dynamic program;
public dynamic reporter;
public dynamic allocator;
}
public static dynamic handler(Input __koru_input) {
var expr = __koru_input.expr;
var invocation = __koru_input.invocation;
var item = __koru_input.item;
var program = __koru_input.program;
var reporter = __koru_input.reporter;
var allocator = __koru_input.allocator;
throw new global::System.Exception("ln: [transform] tor is lowered at compile time and must never be called");
}
}
public static class std_io_print_impl_event {
public struct Input {
public dynamic expr;
}
public static dynamic handler(dynamic __koru_input) {
throw new global::System.Exception("std.io:impl has no C# implementation — its body resolves only to a non-cs target (|zig / [comptime]), directly or through a callee");
}
}
public static void flow0() {
var result_2 = main_module.__store_insertf_cells_event.handler(new __store_insertf_cells_event.Input { v = (long)(10), next = (long)(-1), __site_line = (long)(36)});
if (result_2.tag == "row") {
var a = result_2.row;
main_module.__store_write_head_event.handler(new __store_write_head_event.Input { field = (long)(0), value = (long)(a)});
}
if (result_2.tag == "full") {
}
}
public static void flow1() {
var result_3 = main_module.__store_insertf_cells_event.handler(new __store_insertf_cells_event.Input { v = (long)(20), next = (long)(__koru_store_head.h), __site_line = (long)(40)});
if (result_3.tag == "row") {
var b = result_3.row;
main_module.__store_write_head_event.handler(new __store_write_head_event.Input { field = (long)(0), value = (long)(b)});
}
if (result_3.tag == "full") {
}
}
public static void flow2() {
var result_4 = main_module.__store_insertf_cells_event.handler(new __store_insertf_cells_event.Input { v = (long)(30), next = (long)(__koru_store_head.h), __site_line = (long)(44)});
if (result_4.tag == "row") {
var c = result_4.row;
main_module.__store_write_head_event.handler(new __store_write_head_event.Input { field = (long)(0), value = (long)(c)});
}
if (result_4.tag == "full") {
}
}
public static void flow3() {
{
var __koru_p_field = (long)((long)((long)((ulong)((ulong)(1) << 0))));
var __koru_p_value = (long)(__koru_store_cells.__koru_read_v(__koru_store_head.h));
var __koru_mask = (ulong)__koru_p_field;
if ((__koru_mask & (1UL << 0)) != 0) __koru_store_probe.v1 = __koru_p_value;
if ((__koru_mask & (1UL << 1)) != 0) __koru_store_probe.v2 = __koru_p_value;
if ((__koru_mask & (1UL << 2)) != 0) __koru_store_probe.v3 = __koru_p_value;
}
{
var __koru_p_field = (long)((long)((long)((ulong)((ulong)(1) << 1))));
var __koru_p_value = (long)(__koru_store_cells.__koru_read_v(__koru_store_cells.__koru_read_next(__koru_store_head.h)));
var __koru_mask = (ulong)__koru_p_field;
if ((__koru_mask & (1UL << 0)) != 0) __koru_store_probe.v1 = __koru_p_value;
if ((__koru_mask & (1UL << 1)) != 0) __koru_store_probe.v2 = __koru_p_value;
if ((__koru_mask & (1UL << 2)) != 0) __koru_store_probe.v3 = __koru_p_value;
}
{
var __koru_p_field = (long)(0);
}
{
var __koru_p_field = (long)(1);
}
}
public static void flow4() {
main_module.__store_write_probe_event.handler(new __store_write_probe_event.Input { field = (long)(2), value = (long)(__koru_store_cells.__koru_read_v(__koru_store_cells.__koru_read_next(__koru_store_cells.__koru_read_next(__koru_store_head.h))))});
}
public static void flow5() {
__koru_stdout_write("hop1 " + __koru_str(__koru_store_probe.v1) + " hop2 " + __koru_str(__koru_store_probe.v2) + " hop3 " + __koru_str(__koru_store_probe.v3) + "\n");
}
}
static class Program {
static void Main() {
main_module.flow0();
main_module.flow1();
main_module.flow2();
main_module.flow3();
main_module.flow4();
main_module.flow5();
}
}
Actual
hop1 30 hop2 20 hop3 10
Expected output
✓ Zig✓ C#hop1 30 hop2 20 hop3 10
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (cells, capacity: 8, source: v: i64, next: -1[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (head, source: h: -1[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (probe, source: v1: 0[i64], v2: 0[i64], v3: 0[i64])
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (cells, source: v: 10, next: -1)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (cells, source: v: 20, next: head.h)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (cells, source: v: 30, next: head.h)
flow ~stored click a branch to expand · @labels scroll to their anchor
stored (source: probe.v1: cells[head.h].v, probe.v2: cells[cells[head.h].next].v)
flow ~stored click a branch to expand · @labels scroll to their anchor
stored (source: probe.v3: cells[cells[cells[head.h].next].next].v)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "hop1 {{ probe.v1:d }} hop2 {{ probe.v2:d }} hop3 {{ probe.v3:d }}")
Test Configuration
MUST_RUN LANGUAGES: zig cs