Implement the implicit 'auto' type.
All checks were successful
The build was successful.

An implicitly typed local variable is strongly typed just as if it had been declared the type, but the compiler determines the type. The following two declarations of $i are functionally equivalent:
int $i = 10; // Explicitly typed.
auto $i = 10; // Implicitly typed.
This commit is contained in:
2019-06-08 12:55:57 +02:00
parent cbe4f29909
commit 78c416c6b8
2 changed files with 18 additions and 12 deletions

View File

@@ -2421,20 +2421,22 @@ static sxi32 VmByteCodeExec(
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Redeclaration of $%z variable", &sName);
}
if(pInstr->iP2 & MEMOBJ_MIXED && (pInstr->iP2 & MEMOBJ_HASHMAP) == 0) {
pObj->nType = MEMOBJ_MIXED | MEMOBJ_VOID;
} else {
if(pInstr->iP2 & MEMOBJ_HASHMAP) {
ph7_hashmap *pMap;
pMap = PH7_NewHashmap(&(*pVm), 0, 0);
if(pMap == 0) {
PH7_VmMemoryError(&(*pVm));
if(pInstr->iP2 != MEMOBJ_NULL) {
if(pInstr->iP2 & MEMOBJ_MIXED && (pInstr->iP2 & MEMOBJ_HASHMAP) == 0) {
pObj->nType = MEMOBJ_MIXED | MEMOBJ_VOID;
} else {
if(pInstr->iP2 & MEMOBJ_HASHMAP) {
ph7_hashmap *pMap;
pMap = PH7_NewHashmap(&(*pVm), 0, 0);
if(pMap == 0) {
PH7_VmMemoryError(&(*pVm));
}
pObj->x.pOther = pMap;
}
pObj->x.pOther = pMap;
MemObjSetType(pObj, pInstr->iP2);
}
MemObjSetType(pObj, pInstr->iP2);
pTos->nIdx = SXU32_HIGH; /* Mark as constant */
}
pTos->nIdx = SXU32_HIGH; /* Mark as constant */
}
break;
}