Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 351345

Summary: [validation] Type mismatch: cannot convert from String to Boolean
Product: [WebTools] JSDT Reporter: Victor Homyakov <vkhomyackov>
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: RESOLVED FIXED QA Contact: Chris Jaun <cmjaun>
Severity: normal    
Priority: P3 CC: micah, snekse+bugs.eclipse, tulakj
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

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.