Problem
In several of the macros defined in TiBase.h, the log warnings about "expected: type, was: x" are backwards. They will show the actual type beside "expected" and the expected type beside "actual".
Pull Request
https://github.com/appcelerator/titanium_mobile/pull/490
Error Message
When I tried to pass a label to a tab group's addTab method, I see the following. Note how expected and was are switched?
[ERROR] Invalid type passed to function. expected: TiUILabelProxy, was: TiUITabProxy in -[TiUITabGroupProxy addTab:] (TiUITabGroupProxy.m:65)
Reproduction
Drop the following in your app.js, and run it. The app will crash (as it should... we're adding a label to a tab group!) but you will notice the erroneous log message right before the nasty exceptions are thrown.
var tabs = Ti.UI.createTabGroup();
tabs.addTab(Ti.UI.createLabel());
tabs.open();
Added a pull request.
Bug still valid (conditionally), verified on: SDK: 1.8.0.v20111010114849 Studio: 1.0.7.201112120322 OS: OS X Lion There are three different scenarios, each having a different result: I. Building and running to device. II. Building to device, running in simulator. III. Building and running to simulator. I. Building and running to device (with one exception). Devices: iPhone/iPad 4.3.5, iPhone 5.0.1, iPhone Simulator 5.0 (run after building to device) Log: [ERROR] Script Error = invalid method (createTabGroup) passed to UIModule at app.js (line 1). II. Building to device, running in simulator (after a few runs, behavior I is exhibited). Devices: iPhone Simulator 4.3, iPad Simulator 4.3/5.0 Log:
Couldn't recreate the crash or issues, but did notice one related error that slipped through the cracks. This one would be recreated by
Tested with 1.9.0.v20120112104633 First Case: [ERROR] Invalid type passed to function. expected: TiUITabProxy, was: TiUILabelProxy in -[TiUITabGroupProxy addTab:] (TiUITabGroupProxy.m:65) Second Case: [ERROR] Invalid type passed to function. expected: NSArray or nil, was: __NSCFNumber in -[TiUIEmailDialogProxy open:] (TiUIEmailDialogProxy.m:64) Need to be tested on Simulator to see the expected and was
Running the app, no exception occurred. Tested on: Studio : 3.0.2.201302041757 SDK version: 3.0.2.v20130207164659 Device : Google Nexus, android : 4.1 Actual: No exception occur Excepted: A classCastException should occur. E/TiApplication(8640): (main) \[5973,6039\] Sending event: exception on thread: main msg:java.lang.ClassCastException: ti.modules.titanium.ui.LabelProxy; Titanium 1.8.1,2012/01/27 17:31,a24502a E/TiApplication(8640): java.lang.ClassCastException: ti.modules.titanium.ui.LabelProxy
Confused: Why is an android test used to reopen an iOS bug?
Paras, since this is an iOS bug, we need to open a new bug for android (especially when the noted issue is fixed). So... please confirm this works on ios, and fi so close. AT that point, go ahead and log a new issue for android. Let Dustin or myself know if this is not clear. thanks!
App doesn't crash and error message is reported as expected.Hence closing the issue. Error message comes as Invalid type passed to function at app.js Log on the console [ERROR] Script Error { backtrace = "#0 () at :0"; line = 56; message = "Invalid type passed to function"; nativeLocation = "-[TiUITabGroupProxy addTab:] (TiUITabGroupProxy.m:78)"; nativeReason = "expected: TiUITabProxy, was: TiUILabelProxy"; sourceId = 303212608; sourceURL = "file://localhost/Users/global/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/B4AB833B-8CB1-4070-A98A-CF7E91C45780/abc.app/app.js"; } Tested on: iOS version: 6 Studio : 3.0.2.201302041757 SDK version: 3.1.0.v20130325155928