Script: Allow "new Foo {}" in constant expressions

epoxy
Günther Brammer 2014-04-20 21:43:55 +02:00
parent f6c2906660
commit 93bf8f4779
2 changed files with 7 additions and 1 deletions

View File

@ -1963,7 +1963,12 @@ C4Value C4AulParse::Parse_ConstPropList(C4PropListStatic * parent, C4String * Na
p->Thaw();
}
Store_Const(parent, Name, v);
Shift();
if (TokenType == ATT_IDTF && SEqual(Idtf, C4AUL_New))
{
Shift();
Parse_ConstExpression(p, &Strings.P[P_Prototype]);
}
Match(ATT_BLOPEN);
while (TokenType != ATT_BLCLOSE)
{
C4String * pKey;

View File

@ -115,6 +115,7 @@ TEST_F(AulTest, Locals)
EXPECT_EQ(C4VInt(42), RunCode("func Main() { local i = 42; return i; }", false));
EXPECT_EQ(C4VInt(42), RunCode("local i = [42]; func Main() { return i[0]; }", false));
EXPECT_EQ(C4VInt(42), RunCode("local p = { i = 42 }; func Main() { return p.i; }", false));
EXPECT_EQ(C4VInt(42), RunCode("local p1 = { i = 42 }, p2 = new p1 {}; func Main() { return p2.i; }", false));
}
TEST_F(AulTest, Eval)