What version of Kimi Code is running?
None
Which open platform/subscription were you using?
None
Which model were you using?
None
What platform is your computer?
Windows ARM64
What issue are you seeing?
The Detect-Target function in [file/path] returns a malformed target string of win32-arm64 arm64 on ARM64 Windows machines, instead of the expected win32-arm64.
Root Cause
The switch statement matches architecture strings case-insensitively by default, and PowerShell's switch does not stop after the first match unless a break is explicitly added to each case:
$arch = switch ($rawArch) {
'X64' { 'x64' }
'X86' { 'x86' }
'Arm64' { 'arm64' }
'ARM64' { 'arm64' }
'AMD64' { 'x64' }
'IA64' { 'ia64' }
default { Die "unsupported architecture: $rawArch" }
}
On an ARM64 machine, $rawArch is the literal string "ARM64", which matches both the 'Arm64' and 'ARM64' cases (case-insensitive, no break). Both blocks execute, producing the array @('arm64', 'arm64') instead of a single string. When that array is interpolated in "win32-$arch", PowerShell joins the elements with a space (via $OFS), producing win32-arm64 arm64.
Fix
Remove the redundant duplicate case and add break to every case to prevent this class of bug in general:
$arch = switch ($rawArch) {
'X64' { 'x64'; break }
'X86' { 'x86'; break }
'ARM64' { 'arm64'; break }
'AMD64' { 'x64'; break }
'IA64' { 'ia64'; break }
default { Die "unsupported architecture: $rawArch" }
}
Environment
- OS: Windows on ARM64
- PowerShell version: [fill in, e.g. 7.4.x or 5.1]
Steps to Reproduce
- Run
Detect-Target on a Windows ARM64 machine.
- Observe the returned value is
win32-arm64 arm64 instead of win32-arm64.
What version of Kimi Code is running?
None
Which open platform/subscription were you using?
None
Which model were you using?
None
What platform is your computer?
Windows ARM64
What issue are you seeing?
The
Detect-Targetfunction in [file/path] returns a malformed target string ofwin32-arm64 arm64on ARM64 Windows machines, instead of the expectedwin32-arm64.Root Cause
The
switchstatement matches architecture strings case-insensitively by default, and PowerShell'sswitchdoes not stop after the first match unless abreakis explicitly added to each case:On an ARM64 machine,
$rawArchis the literal string"ARM64", which matches both the'Arm64'and'ARM64'cases (case-insensitive, nobreak). Both blocks execute, producing the array@('arm64', 'arm64')instead of a single string. When that array is interpolated in"win32-$arch", PowerShell joins the elements with a space (via$OFS), producingwin32-arm64 arm64.Fix
Remove the redundant duplicate case and add
breakto every case to prevent this class of bug in general:Environment
Steps to Reproduce
Detect-Targeton a Windows ARM64 machine.win32-arm64 arm64instead ofwin32-arm64.