Summary#
컴파일러나 런타임을 다른 언어로 포팅할 때, 겉보기에는 같은 수학 연산이라도 대상 플랫폼의 표준 의미론과 호스트 언어 라이브러리의 동작이 다를 수 있다. 상수 접기나 최적화는 런타임 결과를 바꾸기 쉬우므로, 표준의 예외 케이스를 명시적으로 테스트하고 원본 구현과 비교해야 한다.
Problem#
JavaScript의 exponentiation을 Rust 컴파일러에서 f64::powf로 상수 접기하면서 IEEE 754 pow 동작이 ECMAScript Number::exponentiate와 달라 1 ** Infinity 같은 케이스의 결과가 NaN이 아니라 1로 바뀌었다.
Solution#
최적화 구현에서 호스트 언어의 유사 API를 그대로 신뢰하지 말고, ECMAScript 등 대상 언어 명세의 특수 케이스를 별도로 반영한다. NaN, Infinity, ±1, -0 같은 경계값을 회귀 테스트로 추가해 기존 TypeScript/JS 백엔드와 결과가 일치하는지 확인한다.
Failure Modes#
- 수학적으로 비슷해 보이는 표준 라이브러리 함수를 그대로 사용함
- 일반 케이스만 테스트하고 NaN/Infinity/-0 같은 명세 경계값을 누락함
- 상수 접기가 런타임 평가와 다른 결과를 만들어 프로그램 의미를 변경함
- 다중 백엔드 간 결과 비교 테스트가 없어 포팅 구현의 차이를 늦게 발견함
Sources#
- https://github.com/Comfy-Org/ComfyUI/pull/16369
- https://github.com/Comfy-Org/ComfyUI/pull/16333
- https://github.com/Comfy-Org/ComfyUI/pull/16366
- https://github.com/Comfy-Org/ComfyUI/pull/16227
- https://github.com/Comfy-Org/ComfyUI/pull/16250
- https://github.com/Comfy-Org/ComfyUI/pull/16350
- https://github.com/Comfy-Org/ComfyUI/pull/16345
- https://github.com/Comfy-Org/ComfyUI/pull/16347
- https://github.com/Comfy-Org/ComfyUI/pull/16320
- https://github.com/GitHubDaily/GitHubDaily/pull/267
- https://github.com/GitHubDaily/GitHubDaily/pull/52
- https://github.com/react/react/pull/37587
- https://github.com/react/react/pull/37618
- https://github.com/react/react/pull/37633
- https://github.com/react/react/pull/37576
- https://github.com/react/react/pull/37622
- https://github.com/react/react/pull/34759
- https://github.com/react/react/pull/37613
- https://github.com/react/react/pull/37580
- https://github.com/react/react/pull/37608
- https://github.com/thedaviddias/Front-End-Checklist/pull/737
- https://github.com/thedaviddias/Front-End-Checklist/pull/664
- mined_at: 2026-09-17T12:10:42Z
Sagwan Revalidation 2026-09-17T12:45:34Z#
- verdict:
ok - note: ECMAScript 특수 케이스와 powf 차이 주장은 여전히 유효하다.