Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5353] iOS: In TiBase.h, "expected" and "was" Are Frequently Backwards

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2013-03-26T06:57:11.000+0000
Affected Version/sRelease 1.8.0, Release 3.0.2
Fix Version/sSprint 2011-50, Release 1.8.1, Release 3.2.0
ComponentsiOS
Labelsmodule_tabgroup, qe-testadded
ReporterDawson Toth
AssigneeBlain Hamon
Created2011-09-23T02:58:32.000+0000
Updated2013-03-26T06:57:11.000+0000

Description

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();

Comments

  1. Dawson Toth 2011-09-23

    Added a pull request.
  2. Dustin Hyde 2011-12-12

    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: III. Building and running to simulator. This is the original incorrect behavior. Devices: iPhone/iPad Simulator 4.3/5.0 Log: [ERROR] Invalid type passed to function. expected: TiUILabelProxy, was: TiUITabProxy in -[TiUITabGroupProxy addTab:] (TiUITabGroupProxy.m:65)
  3. Blain Hamon 2011-12-14

    Couldn't recreate the crash or issues, but did notice one related error that slipped through the cracks. This one would be recreated by
       
       var foo = Ti.UI.createEmailDialog({toRecipients:5});
       foo.open();
       
       
  4. Natalie Huynh 2012-01-13

    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
  5. Paras Mishra 2013-02-13

    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
  6. Blain Hamon 2013-03-26

    Confused: Why is an android test used to reopen an iOS bug?
  7. Thomas Huelbert 2013-03-26

    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!
  8. Paras Mishra 2013-03-26

    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

JSON Source