Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351345 - [validation] Type mismatch: cannot convert from String to Boolean
Summary: [validation] Type mismatch: cannot convert from String to Boolean
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Chris Jaun CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-06 11:34 EDT by Victor Homyakov CLA
Modified: 2013-08-02 11:00 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Homyakov CLA 2011-07-06 11:34:54 EDT
Warning "Type mismatch: cannot convert from String to Boolean" is shown on each statement like <code>x = x || "default value";</code>.

Steps to Reproduce:
Create in JavaScript project JavaScript file with code:

function defVal(x) {
  x = x || "default value";
  return x;
}

Actual Results:
warning about type mismatch.

Expected Results:
no warning, this style of default value assignment is widely used.

Platform:
Eclipse Indigo, JavaScript Development Tools 1.3.0.
Comment 1 Victor Homyakov CLA 2012-06-29 05:57:36 EDT
This bug is still present in Eclipse Java EE IDE for Web Developers.
Version: Juno Release
Build id: 20120322-1740
Comment 2 Micah Freedman CLA 2012-08-15 16:38:33 EDT
I'm getting the same kind of thing with this code:

    function foo() {
        var temp = {};
        if (true) {
            temp = 1;
        }
        return temp;
    }

    (Type mismatch: cannot convert from Number to ___anonymous6554_6555)

If I change it to:

    function foo() {
        var temp = new Object();
        if (true) {
            temp = 1;
        }
        return temp;
    }


the warning goes away, but then jsHint warns me to use object literal notation. Grrr...
Comment 3 Chris Jaun CLA 2013-08-02 11:00:22 EDT
This error is gone in WTP 3.5.1. Checked against 7/18 build.