Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7559] iOS: CommonJS require: undeclared variable referenced from module fails to generate error

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-09T19:48:22.000+0000
Affected Version/sRelease 1.8.0.1, Release 2.0.0, Release 1.8.1, Release 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsparity
ReporterDustin Hyde
AssigneeIngo Muschenetz
Created2012-02-06T16:36:11.000+0000
Updated2020-01-09T19:48:22.000+0000

Description

Undeclared variables referenced from a module fail to generate an error. Android does generate the error. Screenshot attached. The undeclared variable can then be used in further logic, such as adding it to a window. Screenshot attached. If an undeclared variable is used in the module itself, there is an error. If an undeclared variable is returned from an exports function-call, there is an error. If an undeclared variable is defined as a return value in an exports function, but the function is never called, there is no error. If an undeclared variable is returned from an exports function-call and assigned to a new variable outside the module, there is no error, and the variable can continue to be used. Steps to Reproduce: 1. Run Code (also attached):
var undeclaredVar = require('Module').getUndeclaredVar();

Ti.UI.createWindow().add(undeclaredVar);
exports.getUndeclaredVar = function()
{
	return undeclaredVar;
};
Expected Result: Runtime error indicating undeclared variable. Actual Result: No runtime error.

Attachments

FileDateSize
android.png2012-02-06T16:36:11.000+000075640
ios - undeclared var added to window.png2012-02-06T16:36:11.000+000096191
RequireTest.zip2012-02-06T16:36:11.000+00002322325

Comments

  1. Ivan Skugor 2012-02-07

    Hi. This should be duplicate (I think). The problem is that global variables are still allowed in CommonJS implementation on iOS (so, the problem is not undeclared variable as test case suggests). "undeclaredVar" is actually in global scope (in "app.js"). Since there is a bug on iOS that allows referening global scope variables from module scope, when "getUndeclaredVar" is called from module scope, it references "undeclaredVar" global variable and therefore does not produce JS reference error. Change "undeclaredVar" to "undeclaredGlobalVar" and error should be thrown.
  2. Neeraj Gupta 2012-02-07

    This issue can be taken up during JSCore upgrade.
  3. Ivan Skugor 2012-02-08

  4. Shameer Jan 2013-04-19

    Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
  5. Alan Hutton 2020-01-09

    It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source