feat(codemode): complete date parity (#37960)

This commit is contained in:
Aiden Cline 2026-07-20 12:13:16 -05:00 committed by GitHub
commit 98c29075b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 401 additions and 12 deletions

View file

@ -1324,9 +1324,11 @@ export class Interpreter<R> {
throw new InterpreterRuntimeError("Binary operators require data values in CodeMode.", node, "InvalidDataValue")
}
// Null-prototype data needs explicit primitive coercion; identity and `in` retain raw objects.
// Dates use string coercion for `+` and epoch time elsewhere.
// Dates use their default string hint for addition and loose equality, and epoch time elsewhere.
const coerceOperand = (operand: unknown): unknown => {
if (operand instanceof CodeModeDate) return operator === "+" ? coerceToString(operand) : operand.time
if (operand instanceof CodeModeDate) {
return operator === "+" || operator === "==" || operator === "!=" ? coerceToString(operand) : operand.time
}
return operand !== null && typeof operand === "object" ? coerceToString(operand) : operand
}
const bothObjects = lhs !== null && typeof lhs === "object" && rhs !== null && typeof rhs === "object"