Fixed #5452 (AST: wrong handling of unary ::)

This commit is contained in:
Daniel Marjamäki 2014-02-25 06:36:10 +01:00
parent 0747b55485
commit 8550289722
2 changed files with 7 additions and 1 deletions

View File

@ -531,7 +531,10 @@ static void compileScope(Token *&tok, std::stack<Token*> &op)
compileTerm(tok,op);
while (tok) {
if (tok->str() == "::") {
compileBinOp(tok, compileTerm, op);
if (tok->previous() && tok->previous()->isName())
compileBinOp(tok, compileTerm, op);
else
compileUnaryOp(tok, compileDot, op);
} else break;
}
}

View File

@ -10191,6 +10191,9 @@ private:
ASSERT_EQUALS("1a--+", testAst("1 + a--"));
ASSERT_EQUALS("ab+!", testAst("!(a+b)"));
// Unary :: operator
ASSERT_EQUALS("abc?d12,(::e/:=",testAst("a = b ? c : ::d(1,2) / e;"));
// how is "--" handled here:
ASSERT_EQUALS("ab4<<c--+?1:", testAst("a ? (b << 4) + --c : 1"));
ASSERT_EQUALS("ab4<<c--+?1:", testAst("a ? (b << 4) + c-- : 1"));