Bug 15445
Summary: | NaN is not converted correctly from Math functions | ||
---|---|---|---|
Product: | WebKit | Reporter: | Scott Trenda <korisu> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED WORKSFORME | ||
Severity: | Normal | CC: | ap, oliver |
Priority: | P2 | ||
Version: | 523.x (Safari 3) | ||
Hardware: | PC | ||
OS: | Windows Server 2003 |
Scott Trenda
Running Safari (Windows) 3.0.3 v 522.15.5.
Try these in the address bar:
javascript:var x = Math.sqrt(-1); alert(x || "fallback value")
javascript:var x = Math.pow(-1, .5); alert(x || "fallback value")
javascript:var x = NaN; alert(x || "fallback value")
Local behavior: In Safari, alerts "NaN" for the first two, and "fallback value" for the third. Alerts "fallback value" (expected behavior) in IE6/7, Firefox 2.0.0.7 and Opera 9.23. The same behavior happens with an explicit alert(x ? x : "fallback value").
NaN should always convert to Boolean false; it seems that the Math functions are at fault here.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
This works correctly for me with Safari 3.1.
There were some bug fixes made for NaN and Boolean expressions made in 3.1, but I'm surprised that these cases worked differently.