[TIMOB-7559] iOS: CommonJS require: undeclared variable referenced from module fails to generate error
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Won't Do |
Resolution Date | 2020-01-09T19:48:22.000+0000 |
Affected Version/s | Release 1.8.0.1, Release 2.0.0, Release 1.8.1, Release 3.1.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | parity |
Reporter | Dustin Hyde |
Assignee | Ingo Muschenetz |
Created | 2012-02-06T16:36:11.000+0000 |
Updated | 2020-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
File | Date | Size |
---|---|---|
android.png | 2012-02-06T16:36:11.000+0000 | 75640 |
ios - undeclared var added to window.png | 2012-02-06T16:36:11.000+0000 | 96191 |
RequireTest.zip | 2012-02-06T16:36:11.000+0000 | 2322325 |
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.
This issue can be taken up during JSCore upgrade.
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
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.