[TIMOB-18137] iOS: app crashes when comparing variables against null or undefined in the same 'if' statement
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-12-07T23:34:42.000+0000 |
Affected Version/s | Release 3.5.0 |
Fix Version/s | Release 3.5.0, Release 4.0.0 |
Components | iOS |
Labels | qe-3.5.0, qe-assigned, regression |
Reporter | Visalakshi Chidambaram |
Assignee | Vishal Duggal |
Created | 2014-12-04T08:32:59.000+0000 |
Updated | 2014-12-09T22:21:10.000+0000 |
Description
When a variable is compared against null or undefined in the same 'if' clause as shown below the app crashes:
if (result == null || result == undefined )
{....}
however, if they are done separately, i.e,
if (result == null)
if (result == undefined)
there is no issue and both the if statements are executed as the actual value of the results in this example will be undefined. Likewise comparing undefined before null also works fine:
if (result== undefined || result == null){...}
This is a regression as it works fine with 3.4.1
Steps to reproduce:
1. run the attached app.js
2. click on the TEXTFIELD button
Actual results:
2. log displays :
[INFO] :
[INFO] :
[INFO] : ****************
[INFO] : TEXTFIELD
[INFO] : result undefined
and the app also crashes
Expected Results:
2. log should display :
[INFO] :
[INFO] :
[INFO] : ****************
[INFO] : TEXTFIELD
[INFO] : result undefined
[INFO] : NO selection info available from property
[INFO] : ****************
and the app should not crash
Attachments
File | Date | Size |
---|---|---|
app.js | 2014-12-04T08:32:59.000+0000 | 1424 |
Pretty sure this is an expected Javascript behavior. null is a special value in most languages, and when you try to type-covert and check an object to null, unexpected (to you) things may happen. See http://stackoverflow.com/questions/16672743/javascript-null-check
It may be expected, but it appears to be a behavior change from 3.4.1.
Does condition have sense or not have nothing to do with app crash (which should really not happen!)
Verified working as expected using: Titanium SDK 3.5.0.v20141208092926 Studio 3.4.1.201410281743 Xcode 6.1.1 On: iPad mini, iOS 8.1 iPhone 6, iOS 8.2b iPhone 4S Sim, iOS 8.1