Allow chaining off method calls. (bug 6178)

This commit is contained in:
David Anderson 2014-07-12 10:05:43 -07:00
parent 9e1fef9775
commit 1a83ca57fc
2 changed files with 43 additions and 0 deletions

View File

@ -2250,12 +2250,17 @@ restart:
error(4,symname); /* function not defined */ error(4,symname); /* function not defined */
} /* if */ } /* if */
callfunction(sym,implicitthis,lval1,TRUE); callfunction(sym,implicitthis,lval1,TRUE);
if (lexpeek('.')) {
lvalue = FALSE;
goto restart;
}
return FALSE; /* result of function call is no lvalue */ return FALSE; /* result of function call is no lvalue */
} /* if */ } /* if */
} /* if */ } /* if */
if (sym!=NULL && lval1->ident==iFUNCTN) { if (sym!=NULL && lval1->ident==iFUNCTN) {
assert(sym->ident==iFUNCTN); assert(sym->ident==iFUNCTN);
if (sc_allowproccall) { if (sc_allowproccall) {
// Note: this is unreachable in SourceMod, we don't support paren-less calls.
callfunction(sym,NULL,lval1,FALSE); callfunction(sym,NULL,lval1,FALSE);
} else if ((sym->usage & uNATIVE) != uNATIVE) { } else if ((sym->usage & uNATIVE) != uNATIVE) {
symbol *oldsym=sym; symbol *oldsym=sym;

View File

@ -0,0 +1,38 @@
methodmap Duck
{
property bool MyProp
{
public get() {
return true;
}
}
};
public bool OnPluginStart()
{
Duck duck = GiveMeADuck();
// no compile errors or warnings
if (duck.MyProp)
{
}
// error 001: expected token: ")", but found "."
// error 029: invalid expression, assumed zero
// error 017: undefined symbol "MyProp"
if (GiveMeADuck().MyProp)
{
}
// warning 213: tag mismatch
// error 001: expected token: ";", but found "."
// error 029: invalid expression, assumed zero
// error 017: undefined symbol "MyProp"
bool prop = GiveMeADuck().MyProp;
return prop
}
stock Duck GiveMeADuck()
{
return Duck:1;
}