mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed some places where variable declarations should be illegal
This commit is contained in:
parent
26604017f8
commit
b128180a15
4 changed files with 18 additions and 4 deletions
|
@ -2456,6 +2456,16 @@ bool BfExprEvaluator::HasVariableDeclaration(BfAstNode* checkNode)
|
|||
void BfExprEvaluator::Visit(BfVariableDeclaration* varDecl)
|
||||
{
|
||||
mModule->UpdateExprSrcPos(varDecl);
|
||||
|
||||
if ((mModule->mCurMethodState == NULL) || (!mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations))
|
||||
{
|
||||
mModule->Fail("Variable declarations are not allowed in this context", varDecl);
|
||||
if (varDecl->mInitializer != NULL)
|
||||
{
|
||||
VisitChild(varDecl->mInitializer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CheckVariableDeclaration(varDecl, true, false, false);
|
||||
if (varDecl->mInitializer == NULL)
|
||||
|
@ -5017,6 +5027,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
|
||||
// Temporarily disable so we don't capture calls in params
|
||||
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
||||
SetAndRestoreValue<bool> prevAllowVariableDeclarations(mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations, false); // Don't allow variable declarations in arguments
|
||||
|
||||
BfMethodInstance* methodInstance = moduleMethodInstance.mMethodInstance;
|
||||
|
||||
|
@ -5827,7 +5838,7 @@ BfTypedValue BfExprEvaluator::ResolveArgValue(BfResolvedArg& resolvedArg, BfType
|
|||
{
|
||||
BfExprEvaluator exprEvaluator(mModule);
|
||||
exprEvaluator.mReceivingValue = receivingValue;
|
||||
BfEvalExprFlags flags = BfEvalExprFlags_NoCast;
|
||||
BfEvalExprFlags flags = (BfEvalExprFlags)(BfEvalExprFlags_NoCast);
|
||||
if ((paramKind == BfParamKind_Params) || (paramKind == BfParamKind_DelegateParam))
|
||||
flags = (BfEvalExprFlags)(flags | BfEvalExprFlags_AllowParamsExpr);
|
||||
|
||||
|
@ -6154,6 +6165,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
|
||||
// Temporarily disable so we don't capture calls in params
|
||||
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
||||
SetAndRestoreValue<bool> prevAllowVariableDeclarations(mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations, false); // Don't allow variable declarations in arguments
|
||||
|
||||
sInvocationIdx++;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue