✓
Passing This code compiles and runs correctly.
Code
// Pins: Koru `%` on a SIGNED runtime value in an `if` condition, on BOTH
// targets. Koru's `%` is C's truncated remainder: the comptime fold
// (comptime_eval.zig folds `.modulo` with `@rem` — its own comment calls that
// "the C-parity choice") and the JS target (its `%` on numbers IS that same
// remainder) already agreed; this pins the Zig emission (`@rem`) into the same
// meaning, where bare `%` is unsigned-only and dies at Stage D quoting Zig's
// builtin list. The shape is 320_140's if-dispatch with the numeric operator.
//
// The condition of a `std/control:if` is a per-call TEMPLATE arg, so it is
// baked into the rendered body before the emitter runs — this pins that seam.
import std/io
pub tor parity { n: i32 } -> string
parity = if (n % 2 == 0)
| then -> "even"
| else -> "odd"
// A two-module hand-off, so `n` is a RUNTIME value: a literal call site
// const-folds, and the body it folded away is never analyzed by the backend.
pub tor via { n: i32 } -> string
via = parity(n): r -> r
via(n: 7): a |> std/io:print.ln(a)
via(n: 8): b |> std/io:print.ln(b)
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
}
}
}odd
even
<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_144_modulo_if_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_144_modulo_if_dispatch/obj/Debug/net8.0/koru.GeneratedMSBuildEditorConfig.editorconfig
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/koru.AssemblyInfoInputs.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/koru.AssemblyInfo.cs
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/koru.csproj.CoreCompileInputs.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/koru.sourcelink.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/a_cs_equiv
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/refint/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/a_cs_equiv.pdb
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/a_cs_equiv.deps.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/koru.genruntimeconfig.cache
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/a_cs_equiv.runtimeconfig.json
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/obj/Debug/net8.0/ref/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/a_cs_equiv.pdb
48c869d2882c5968ba3861c8e62f9e4632179d72f03e70849a13ebb92be5a395
{"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_144_modulo_if_dispatch/koru.csproj": {}
},
"projects": {
"/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/koru.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_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_144_modulo_if_dispatch/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_dispatch/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_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": "Hm62TPCEy08=",
"success": true,
"projectFilePath": "/Users/larsde/src/koru/tests/regression/320_CONTROL_FLOW/320_144_modulo_if_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 parity_event {
public struct Input {
public int n;
}
public static string handler(Input __koru_input) {
var n = __koru_input.n;
if (n % 2 == 0) {
{ return "even";
}
} else {
{ return "odd";
}
}
return default;
}
}
public static class via_event {
public struct Input {
public int n;
}
public static string handler(Input __koru_input) {
var n = __koru_input.n;
var r = main_module.parity_event.handler(new parity_event.Input { n = (int)(n)});
return (string)(r);
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 a = main_module.via_event.handler(new via_event.Input { n = (int)(7)});
__koru_stdout_write("" + (a) + "\n");
}
public static void flow1() {
var b = main_module.via_event.handler(new via_event.Input { n = (int)(8)});
__koru_stdout_write("" + (b) + "\n");
}
}
static class Program {
static void Main() {
main_module.flow0();
main_module.flow1();
}
}
Actual
odd
even
Expected output
✓ Zig✓ JavaScript✓ C#odd
even
Flows
subflow ~parity click a branch to expand · @labels scroll to their anchor
if (n % 2 == 0)
subflow ~via click a branch to expand · @labels scroll to their anchor
parity (n)
flow ~via click a branch to expand · @labels scroll to their anchor
via (n: 7)
flow ~via click a branch to expand · @labels scroll to their anchor
via (n: 8)
Test Configuration
MUST_RUN LANGUAGES: zig js cs