Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350537 - [validation] Type mismatch when rewriting an object
Summary: [validation] Type mismatch when rewriting an object
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 minor (vote)
Target Milestone: 3.2.5   Edit
Assignee: Chris Jaun CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-28 05:37 EDT by Dusan Smolnikar CLA
Modified: 2011-07-01 10:42 EDT (History)
1 user (show)

See Also:
thatnitind: review+


Attachments
patch (1.30 KB, patch)
2011-06-29 15:15 EDT, Chris Jaun CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dusan Smolnikar CLA 2011-06-28 05:37:42 EDT
Build Identifier: 20110407183333

Enter the following code into a .js file:
-----
// Create objects
var foo = {
	bar : {}
};

// Set some properties
foo.bar.one = 1;
foo.bar.two = 2;

// Reset the object
foo.bar = {};
-----

On the last line, I will get a javascript warning:
Type mismatch: cannot convert from ___anonymous346782_346783 to ___anonymous346761_346762

There doesn't seem to be anything wrong with the code. I am simply overwriting an object with a new object.

If, however, I do the following:
-----
...
// Reset the object
foo.bar = new Object();
-----

I do not get a warning. From my understanding of javascript, the two declarations are equivalent.

Reproducible: Always

Steps to Reproduce:
In eclipse preferences go to:
JavaScript > Validator > Error/Warnings
and enable JavaScript semantic validation.

This will enable display of warnings, such as described above.
Comment 1 Chris Jaun CLA 2011-06-29 15:15:33 EDT
Created attachment 198856 [details]
patch

Removes error reported for mis-matched types on assignment statements.

Anything can be assigned to anything in JavaScript, no need for such checking.
Comment 2 Chris Jaun CLA 2011-07-01 10:42:49 EDT
Checked into 3.2.5 and HEAD.