Bug 268051 - Posibility to suppress 'case expressions should be constant expressions' warning
Summary: Posibility to suppress 'case expressions should be constant expressions' warning
Status: RESOLVED DUPLICATE of bug 268542
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: 3.0.4   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Chris Jaun CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-11 04:19 EDT by Robin CLA
Modified: 2010-03-03 11:17 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin CLA 2009-03-11 04:19:29 EDT
function doSomething(node) {
	switch (node.type) {
	case Node.TEXT_NODE:
		break;
	}
}

results in warning 'case expressions should be constant expressions'.

since the is no way (at the moment) to define const in JS, this warning should be suppressed or at least optional.

for the next example

function MyObject() {
}

MyObject.MyConstant = 1;
MyObject.prototype.MyOtherConstant = 2;

MyObject.prototype.doSomething(value) {
	switch (node.type) {
	case MyObject.MyConstant:
		break;
	case this.MyOtherConstant:
		break;
	}

}

probably you should always generate a warning for 'case this.MyOtherConstant' but not for 'case MyObject.MyConstant:'
Comment 1 Chris Jaun CLA 2009-04-06 14:35:27 EDT
This problem has been removed as part of the work in https://bugs.eclipse.org/bugs/show_bug.cgi?id=268542.

Case statements in JavaScript are not required to be constant values.

*** This bug has been marked as a duplicate of bug 268542 ***