[TIMOB-13358] Code Analyzer: Native methods that modify their objects don't respect ambiguous blocks
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-05-31T02:46:57.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | 2013 Sprint 07 JS, 2013 Sprint 07, 2013 Sprint 10 JS, 2013 Sprint 10, Release 3.1.1, Release 3.2.0 |
Components | Code Processor |
Labels | qe-closed-3.1.1, qe-testadded |
Reporter | Bryan Hughes |
Assignee | Bryan Hughes |
Created | 2013-04-03T23:01:04.000+0000 |
Updated | 2014-02-24T23:36:35.000+0000 |
Description
If a native method is called that modifies the base object and is in an ambiguous block, it needs to convert the object to unknown. For example:
var x = ['1', '2', '3'];
if (Date.now()) {
delete x[2];
} else {
x[2] = x[2].length + 1;
}
console.log(x.join());
both branches of the if are evaluated, but the first branch is evaluated first and deletes x[2] before the second branch is evaluated, resulting in a "undefined value has no property "length"" exception. Instead, the array needs to be converted to unknown.
Attachments
File | Date | Size |
---|---|---|
iphoneResults_Alloy.zip | 2013-05-30T19:27:08.000+0000 | 761531 |
newAlloy.zip | 2013-05-30T19:27:08.000+0000 | 7404780 |
Screen Shot 2013-05-08 at 3.40.52 PM.png | 2013-05-08T22:43:57.000+0000 | 11965 |
PR: https://github.com/appcelerator/titanium-code-processor/pull/152 1_0_X PR: https://github.com/appcelerator/titanium-code-processor/pull/162
Still seeing this with 1.0.1: Mac OS 10.8.3 Safari: 6.0.4 Xcode 4.6 CLI: 3.1.0 titanium-code-processor: 1.0.1 Alloy: 1.1.2 Appcelerator Studio, build: 3.1.1.201305072102 Titanium SDK version 3.1.1.v20130508001914
Please see the attached screen shot
PR: https://github.com/appcelerator/titanium-code-processor/pull/192 1_0_X PR: https://github.com/appcelerator/titanium-code-processor/pull/193
[undefined value has no property "length"] exception is no longer visible on a classic Titanium Project. However, is still visible on an Alloy project. See the attached 'newAlloy' sample project and 'iphoneResults_Alloy' results. Environment: Appcelerator Studio 3.1.1.201305292130 Titanium SDK 3.1.1.v20130529114554 Alloy 1.1.3-alpha Titanium-Code-Processor 1.1.3-alpha3 Reopening.
PR: https://github.com/appcelerator/titanium-code-processor/pull/208 1_0_X PR: https://github.com/appcelerator/titanium-code-processor/pull/209
Testing instructions (for the alloy reopen): 1) Add the above test code to index.js in an alloy controller. 2) Run using "ti analyze -p iphone -A" 3) If the bug is fixed, the error listed in the description will not appear
Code and functional review passed. Both PRs merged.
Verified as fixed. Environment: Appcelerator Studio 3.1.1.201305312408 Titanium SDK 3.1.1.v20130530204550 Alloy 1.1.3-alpha Titanium-Code-Processor 1.1.3-alpha4 Closing.