Fix case that had been getting a ClassCastException (then changed to be a

Kit.codeBug) that I now report an error on.
This commit is contained in:
nboyd%atg.com 2008-01-10 22:47:26 +00:00
Родитель b44703d683
Коммит 2eb389fe0c
2 изменённых файлов: 13 добавлений и 11 удалений

Просмотреть файл

@ -540,14 +540,14 @@ final class IRFactory
Node lvalue; Node lvalue;
int type = lhs.getType(); int type = lhs.getType();
if (type == Token.VAR || type == Token.LET) { if (type == Token.VAR || type == Token.LET) {
/*
* check that there was only one variable given.
* we can't do this in the parser, because then the
* parser would have to know something about the
* 'init' node of the for-in loop.
*/
Node lastChild = lhs.getLastChild(); Node lastChild = lhs.getLastChild();
if (lhs.getFirstChild() != lastChild) { if (lhs.getFirstChild() != lastChild) {
/*
* check that there was only one variable given.
* we can't do this in the parser, because then the
* parser would have to know something about the
* 'init' node of the for-in loop.
*/
parser.reportError("msg.mult.index"); parser.reportError("msg.mult.index");
} }
if (lastChild.getType() == Token.ARRAYLIT || if (lastChild.getType() == Token.ARRAYLIT ||
@ -557,13 +557,16 @@ final class IRFactory
lvalue = lastChild; lvalue = lastChild;
destructuringLen = lastChild.getIntProp( destructuringLen = lastChild.getIntProp(
Node.DESTRUCTURING_ARRAY_LENGTH, 0); Node.DESTRUCTURING_ARRAY_LENGTH, 0);
} else { } else if (lastChild.getType() == Token.NAME) {
lvalue = Node.newString(Token.NAME, lastChild.getString()); lvalue = Node.newString(Token.NAME, lastChild.getString());
} else {
parser.reportError("msg.bad.for.in.lhs");
return obj;
} }
} else if (type == Token.ARRAYLIT || type == Token.OBJECTLIT) { } else if (type == Token.ARRAYLIT || type == Token.OBJECTLIT) {
destructuring = type; destructuring = type;
lvalue = lhs; lvalue = lhs;
destructuringLen = lhs.getIntProp(Node.DESTRUCTURING_ARRAY_LENGTH, 0); destructuringLen = lhs.getIntProp(Node.DESTRUCTURING_ARRAY_LENGTH, 0);
} else { } else {
lvalue = makeReference(lhs); lvalue = makeReference(lhs);
if (lvalue == null) { if (lvalue == null) {

Просмотреть файл

@ -672,7 +672,6 @@ public class Node
/** Can only be called when node has String context. */ /** Can only be called when node has String context. */
public final String getString() { public final String getString() {
if (!(this instanceof StringNode)) Kit.codeBug();
return ((StringNode)this).str; return ((StringNode)this).str;
} }