Bug 32342 - Javascript string comparison
Summary: Javascript string comparison
Status: RESOLVED DUPLICATE of bug 32256
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh Intel OS X 10.6
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2009-12-09 12:49 PST by Matt O
Modified: 2009-12-09 23:01 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt O 2009-12-09 12:49:06 PST
This broken with the nightly build from Monday, Dec 7.  Javascript appears to be evaluating the following code properly in console until you get to the last line.  The expression is always being evaluated as "true".

mystring = "02122010";
digits = mystring.substr(2,2);

console.log("Digits value:");
console.log(digits);

console.log("Digits type:");
console.log(typeof digits);

console.log("This expression evaluates correctly as false: (digits > 12)");
console.log(digits < 1);

console.log("This expression evaluates correctly as false: (digits > 12)");
console.log(digits > 12);

console.log("This expression evaluates correctly as false: (digits < 1) || (digits > 12)");
console.log((digits < 1) || (digits > 12));

console.log("But it fails in real use:  if ((digits < 1) || (digits > 12)) { console.log(\"Sorry, I don't like strings - even though I should.\"); }")
if ((digits < 1) || (digits > 12)) { console.log("Sorry, I don't like strings - even though I should."); }
Comment 1 Mark Rowe (bdash) 2009-12-09 13:41:25 PST
<rdar://problem/7457885>
Comment 2 Maciej Stachowiak 2009-12-09 23:01:07 PST
This is caused by the same underlying bug as bug 32256. Marking duplicate of the higher-numbered bug because the other bug better reflects the impact.

*** This bug has been marked as a duplicate of bug 32256 ***