✓
Passing This code compiles and runs correctly.
Code
// Pins: a call-site `when` guard comparing a STRING branch-payload field to
// a literal, on BOTH targets. The destructure + guard shape is 670_070's
// (`| found { name, age } when age > 40`) with the guard on the string
// field instead of the numeric one.
import std/io
tor fetch { id: i64 }
| found { name: string, age: i64 }
| missing
fetch = if(id == 1)
| then => found { name: "lars", age: 44 }
| else => missing
fetch(id: 1)
| found { name, age } when name == "lars" |> std/io:print.ln("match {{ age:d }}")
| found { name, age } |> std/io:print.ln("other {{ name:s }} {{ age:d }}")
| missing |> std/io:print.ln("nope")
fetch(id: 2)
| found { name, age } when name == "lars" |> std/io:print.ln("match {{ age:d }}")
| found { name, age } |> std/io:print.ln("other {{ name:s }} {{ age:d }}")
| missing |> std/io:print.ln("nope")
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
}
}
}match 44
nope
<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_142_when_guard_string_payload/
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_142_when_guard_string_payload/obj/Debug/net8.0/koru.GeneratedMSBuildEditorConfig.editorconfig
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/koru.AssemblyInfoInputs.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/koru.AssemblyInfo.cs
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/koru.csproj.CoreCompileInputs.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/koru.sourcelink.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/a_cs_equiv
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/refint/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/a_cs_equiv.pdb
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/a_cs_equiv.deps.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/koru.genruntimeconfig.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/a_cs_equiv.runtimeconfig.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/obj/Debug/net8.0/ref/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/a_cs_equiv.pdb
4cd8e799ff3dd667b4654a3101ca13a760330287d0706846ad4eb963c59be18d
{"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_142_when_guard_string_payload/koru.csproj": {}
},
"projects": {
"/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/koru.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/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_142_when_guard_string_payload/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/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": "4jAdRU4P9u8=",
"success": true,
"projectFilePath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_142_when_guard_string_payload/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 fetch_event {
public struct Input {
public long id;
}
public struct Output {
public string tag;
public dynamic found;
public dynamic missing;
}
public static Output handler(Input __koru_input) {
var id = __koru_input.id;
if (id == 1) {
{ return new Output { tag = "found", found = new { name = "lars", age = 44 } };
}
} else {
{ return new Output { tag = "missing" };
}
}
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 if_event {
public struct Input {
public dynamic expr;
}
public struct Output {
public string tag;
public dynamic then;
public dynamic @else;
}
public static Output handler(Input __koru_input) {
var expr = __koru_input.expr;
throw new global::System.Exception("if: |template| proc is inlined at call sites and must never be called");
}
}
public static void flow0() {
var result_0 = main_module.fetch_event.handler(new fetch_event.Input { id = (long)(1)});
var __matched_1 = false;
if (!__matched_1 && result_0.tag == "found") {
var name = result_0.found.name;
var age = result_0.found.age;
if (name == "lars") {
__matched_1 = true;
__koru_stdout_write("match " + (age) + "\n");
}
}
if (!__matched_1 && result_0.tag == "found") {
var name = result_0.found.name;
var age = result_0.found.age;
__matched_1 = true;
__koru_stdout_write("other " + (name) + " " + (age) + "\n");
}
if (!__matched_1 && result_0.tag == "missing") {
__matched_1 = true;
__koru_stdout_write("nope" + "\n");
}
}
public static void flow1() {
var result_2 = main_module.fetch_event.handler(new fetch_event.Input { id = (long)(2)});
var __matched_3 = false;
if (!__matched_3 && result_2.tag == "found") {
var name = result_2.found.name;
var age = result_2.found.age;
if (name == "lars") {
__matched_3 = true;
__koru_stdout_write("match " + (age) + "\n");
}
}
if (!__matched_3 && result_2.tag == "found") {
var name = result_2.found.name;
var age = result_2.found.age;
__matched_3 = true;
__koru_stdout_write("other " + (name) + " " + (age) + "\n");
}
if (!__matched_3 && result_2.tag == "missing") {
__matched_3 = true;
__koru_stdout_write("nope" + "\n");
}
}
}
static class Program {
static void Main() {
main_module.flow0();
main_module.flow1();
}
}
Actual
match 44
nope
Expected output
✓ Zig✓ JavaScript✓ C#match 44
nope
Flows
subflow ~fetch click a branch to expand · @labels scroll to their anchor
if (id == 1)
flow ~fetch click a branch to expand · @labels scroll to their anchor
fetch (id: 1)
flow ~fetch click a branch to expand · @labels scroll to their anchor
fetch (id: 2)
Test Configuration
MUST_RUN LANGUAGES: zig js cs