✓
Passing This code compiles and runs correctly.
Code
// Pins: `cond` arms guarded by string equality against literals, on BOTH
// targets — the app-router shape of 320_137 with the scrutinee a STRING,
// not a numeric code. Before string `==` reached the Zig target, exactly
// this router had to stamp numeric codes into its markup to dispatch.
import std/io
tor page-route { page: string }
| catalog
| progress
| other
page-route = cond(page)
| c p when p == "catalog" => catalog
| c p when p == "progress" => progress
| c _ => other
page-route(page: "catalog")
| catalog |> std/io:print.ln("catalog")
| progress |> std/io:print.ln("progress")
| other |> std/io:print.ln("other")
page-route(page: "progress")
| catalog |> std/io:print.ln("catalog")
| progress |> std/io:print.ln("progress")
| other |> std/io:print.ln("other")
page-route(page: "missing")
| catalog |> std/io:print.ln("catalog")
| progress |> std/io:print.ln("progress")
| other |> std/io:print.ln("other")
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
}
}
}catalog
progress
other
<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+7c0d9582d1eb20b955d8d738392d413fc20d4a16")]
[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.
fa089d3ad8a8b936c7f28ae6bf470b231b6c626f753b342560218119d90f917e
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/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =
5be0995b741828a5c320155d1f80abdffa79d05541ea191d12e3a61e37fca459
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/koru.GeneratedMSBuildEditorConfig.editorconfig
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/koru.AssemblyInfoInputs.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/koru.AssemblyInfo.cs
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/koru.csproj.CoreCompileInputs.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/koru.sourcelink.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/a_cs_equiv
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/refint/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/a_cs_equiv.pdb
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/a_cs_equiv.deps.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/koru.genruntimeconfig.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/a_cs_equiv.runtimeconfig.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/obj/Debug/net8.0/ref/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/a_cs_equiv.pdb
e9597706b324e56f1b04fe38479b7008262cfdab6ffc87d47f3be6066c686baa
{"documents":{"/Users/larsde/src/koru/*":"https://raw.githubusercontent.com/korulang/koru/7c0d9582d1eb20b955d8d738392d413fc20d4a16/*"}}{
"format": 1,
"restore": {
"/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/koru.csproj": {}
},
"projects": {
"/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/koru.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/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/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/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": "g9AGSSSTUrE=",
"success": true,
"projectFilePath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_141_cond_string_guard_dispatch/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);
public static class page_route_event {
public struct Input {
public string page;
}
public struct Output {
public string tag;
public dynamic catalog;
public dynamic progress;
public dynamic other;
}
public static Output handler(Input __koru_input) {
var page = __koru_input.page;
var p = page;
if (p == "catalog") {
{ return new Output { tag = "catalog" };
}
} else if (p == "progress") {
{ return new Output { tag = "progress" };
}
} else {
{ return new Output { tag = "other" };
}
}
return default;
}
}
public static class 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 cond_event {
public struct Input {
public dynamic expr;
}
public struct Output {
public string tag;
public dynamic c;
}
public static Output handler(Input __koru_input) {
var expr = __koru_input.expr;
throw new global::System.Exception("cond: |template| proc is inlined at call sites and must never be called");
}
}
public static void flow0() {
var result_0 = main_module.page_route_event.handler(new page_route_event.Input { page = (string)("catalog")});
if (result_0.tag == "catalog") {
__koru_stdout_write("catalog" + "\n");
}
if (result_0.tag == "progress") {
__koru_stdout_write("progress" + "\n");
}
if (result_0.tag == "other") {
__koru_stdout_write("other" + "\n");
}
}
public static void flow1() {
var result_1 = main_module.page_route_event.handler(new page_route_event.Input { page = (string)("progress")});
if (result_1.tag == "catalog") {
__koru_stdout_write("catalog" + "\n");
}
if (result_1.tag == "progress") {
__koru_stdout_write("progress" + "\n");
}
if (result_1.tag == "other") {
__koru_stdout_write("other" + "\n");
}
}
public static void flow2() {
var result_2 = main_module.page_route_event.handler(new page_route_event.Input { page = (string)("missing")});
if (result_2.tag == "catalog") {
__koru_stdout_write("catalog" + "\n");
}
if (result_2.tag == "progress") {
__koru_stdout_write("progress" + "\n");
}
if (result_2.tag == "other") {
__koru_stdout_write("other" + "\n");
}
}
}
static class Program {
static void Main() {
main_module.flow0();
main_module.flow1();
main_module.flow2();
}
}
Actual
catalog
progress
other
Expected output
✓ Zig✓ JavaScript✓ C#catalog
progress
other
Flows
subflow ~page-route click a branch to expand · @labels scroll to their anchor
cond (page)
flow ~page-route click a branch to expand · @labels scroll to their anchor
page-route (page: "catalog")
flow ~page-route click a branch to expand · @labels scroll to their anchor
page-route (page: "progress")
flow ~page-route click a branch to expand · @labels scroll to their anchor
page-route (page: "missing")
Test Configuration
MUST_RUN LANGUAGES: zig js cs