| Summary: | [validation] Type mismatch when rewriting an object | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Dusan Smolnikar <dusan.smolnikar> | ||||
| Component: | General | Assignee: | Chris Jaun <cmjaun> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Nitin Dahyabhai <thatnitind> | ||||
| Severity: | minor | ||||||
| Priority: | P3 | CC: | cmjaun | ||||
| Version: | unspecified | Flags: | thatnitind:
review+
|
||||
| Target Milestone: | 3.2.5 | ||||||
| Hardware: | Macintosh | ||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
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.
Checked into 3.2.5 and HEAD. |
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.