Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13358] Code Analyzer: Native methods that modify their objects don't respect ambiguous blocks

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-05-31T02:46:57.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2013 Sprint 07 JS, 2013 Sprint 07, 2013 Sprint 10 JS, 2013 Sprint 10, Release 3.1.1, Release 3.2.0
ComponentsCode Processor
Labelsqe-closed-3.1.1, qe-testadded
ReporterBryan Hughes
AssigneeBryan Hughes
Created2013-04-03T23:01:04.000+0000
Updated2014-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

FileDateSize
iphoneResults_Alloy.zip2013-05-30T19:27:08.000+0000761531
newAlloy.zip2013-05-30T19:27:08.000+00007404780
Screen Shot 2013-05-08 at 3.40.52 PM.png2013-05-08T22:43:57.000+000011965

Comments

  1. Bryan Hughes 2013-04-17

    PR: https://github.com/appcelerator/titanium-code-processor/pull/152 1_0_X PR: https://github.com/appcelerator/titanium-code-processor/pull/162
  2. Eric Merriman 2013-05-08

    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
  3. Eric Merriman 2013-05-08

    Please see the attached screen shot
  4. Bryan Hughes 2013-05-17

    PR: https://github.com/appcelerator/titanium-code-processor/pull/192 1_0_X PR: https://github.com/appcelerator/titanium-code-processor/pull/193
  5. Federico Casali 2013-05-30

    [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.
  6. Bryan Hughes 2013-05-31

    PR: https://github.com/appcelerator/titanium-code-processor/pull/208 1_0_X PR: https://github.com/appcelerator/titanium-code-processor/pull/209
  7. Bryan Hughes 2013-05-31

    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
  8. Tony Lukasavage 2013-05-31

    Code and functional review passed. Both PRs merged.
  9. Federico Casali 2013-05-31

    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.

JSON Source