fix(managed): preserve negative zero in CIL operands (#2437)

This commit is contained in:
Harly
2026-10-13 18:19:44 +08:00
committed by GitHub
parent ab02f3c8d6
commit 6c816af119
2 changed files with 66 additions and 2 deletions
@@ -265,6 +265,10 @@ type OperandResult = {
type OperandReader = (il: Buffer, offset: number) => OperandResult;
// String(-0) loses a CIL constant's sign in both anchors and normalized hashes.
const floatingPointOperand = (value: number): string =>
Object.is(value, -0) ? "-0" : String(value);
const FIXED_OPERAND_READERS = new Map<string, OperandReader>([
[
"none",
@@ -315,7 +319,7 @@ const FIXED_OPERAND_READERS = new Map<string, OperandReader>([
(il, offset) => ({
next: offset + 4,
anchorKind: "constant",
value: String(il.readFloatLE(offset)),
value: floatingPointOperand(il.readFloatLE(offset)),
}),
],
[
@@ -323,7 +327,7 @@ const FIXED_OPERAND_READERS = new Map<string, OperandReader>([
(il, offset) => ({
next: offset + 8,
anchorKind: "constant",
value: String(il.readDoubleLE(offset)),
value: floatingPointOperand(il.readDoubleLE(offset)),
}),
],
[