From 6c277c1ecaa4c4df1536cb322026c5c6faf154a7 Mon Sep 17 00:00:00 2001 From: belliash Date: Sat, 8 Jun 2019 13:35:16 +0200 Subject: [PATCH] Allow implicitly-typed variable declarations inside 'for' and 'foreach' loops. --- engine/compiler.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/compiler.c b/engine/compiler.c index d82a7b6..d6b488a 100644 --- a/engine/compiler.c +++ b/engine/compiler.c @@ -1879,7 +1879,7 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) { pTmp = pGen->pEnd; pGen->pEnd = pEnd; sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData)); - if(nKey & PH7_KEYWORD_TYPEDEF) { + if(nKey & (PH7_KEYWORD_AUTO | PH7_KEYWORD_TYPEDEF)) { PH7_CompileVar(&(*pGen)); } /* Compile initialization expressions if available */ @@ -2062,7 +2062,7 @@ static sxi32 PH7_CompileForeach(ph7_gen_state *pGen) { pTmp = pGen->pEnd; pGen->pEnd = pCur; nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData)); - if(nKey & PH7_KEYWORD_TYPEDEF) { + if(nKey & (PH7_KEYWORD_AUTO | PH7_KEYWORD_TYPEDEF)) { /* Hack to compile variable */ pGen->pEnd->nType = PH7_TK_SEMI; if(pGen->pIn[3].nType != PH7_TK_SEMI) { @@ -2111,7 +2111,7 @@ static sxi32 PH7_CompileForeach(ph7_gen_state *pGen) { pTmp = pGen->pEnd; pGen->pEnd = pCur; nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData)); - if(nKey & PH7_KEYWORD_TYPEDEF) { + if(nKey & (PH7_KEYWORD_AUTO | PH7_KEYWORD_TYPEDEF)) { /* Hack to compile variable */ pGen->pEnd->nType = PH7_TK_SEMI; if(pGen->pIn[3].nType != PH7_TK_SEMI) {