You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CaseiType.oAccessSelectCaseop.subTypeCaseISubType.argumentDimiArgIndexAsLong:iArgIndex=val(mid(op.value,2))+LBound(vLastArgs)-1IfiArgIndex<=UBound(vLastArgs)ThenCallpushV(stack,stackPtr,vLastArgs(iArgIndex))ElseCallThrow("Argument "&iArgIndex&" not supplied to Lambda.")EndIfCaseElseCallpushV(stack,stackPtr,stack(stackPtr-op.value))
Call pushV(stack, stackPtr, stack(stackPtr - op.value)) can sometimes error when the variable at stack(stackPtr - op.value) is an object. See explanation for details. As a temporary work around we can do the following:
'@FIX bug where if stack(stackPtr-op.value) was an object, then array will become locked. Array locking occurs by compiler to try to protect'instances when re-allocation would move the array, and thus corrupt the pointers. By copying the variant we redivert the compiler's efforts,'but we might actually open ourselves to errors...DimvAccessVar:CallCopyVariant(vAccessVar,stack(stackPtr-op.value))CallpushV(stack,stackPtr,vAccessVar)
This may still break so we need to consider a better solution. Our suggestion is to use a Collection (i.e. linked list) instead of a dynamic array. This should have fewer issues but might sacrifice on some performance.
Explanation:
Minimal examples where error occurs:
SubExample()'Initialize the array with 3 elementsDimmyArray()AsstringReDimmyArray(0)SetmyArray(0)="yop"CallPush(myArray,myArray(0))EndSubSubPush(ByRefmyArray()Asstring,ByRefelementAsstring)'Lock the array to prevent deallocation of memory for the reference parameterReDimPreservemyArray(UBound(myArray)+1)IfIsObject(element)ThenSetmyArray(UBound(myArray))=elementElsemyArray(UBound(myArray))=elementEndIfEndSub
The issue is that element, in this case is a reference to an element within myArray... The solution to above is change element to ByVal:
SubExample()'Initialize the array with 3 elementsDimmyArray()AsVariantReDimmyArray(0)SetmyArray(0)=CreateObject("scripting.dictionary")CallPush(myArray,myArray(0))EndSubSubPush(ByRefmyArray()AsVariant,ByValelementAsVariant)'Lock the array to prevent deallocation of memory for the reference parameterReDimPreservemyArray(UBound(myArray)+1)IfIsObject(element)ThenSetmyArray(UBound(myArray))=elementElsemyArray(UBound(myArray))=elementEndIfEndSub
Also errors because we have a pointer directly to myArray(0) object. So the real work around is
SubExample()'Initialize the array with 3 elementsDimmyArray()AsVariantReDimmyArray(0)SetmyArray(0)=CreateObject("scripting.dictionary")Dimv:CopyVariant(v,myArray(0))CallPush(myArray,v)EndSub
The text was updated successfully, but these errors were encountered:
Currently in
evaluate
:Call pushV(stack, stackPtr, stack(stackPtr - op.value))
can sometimes error when the variable atstack(stackPtr - op.value)
is an object. See explanation for details. As a temporary work around we can do the following:This may still break so we need to consider a better solution. Our suggestion is to use a
Collection
(i.e. linked list) instead of a dynamic array. This should have fewer issues but might sacrifice on some performance.Explanation:
Minimal examples where error occurs:
The issue is that
element
, in this case is a reference to an element withinmyArray
... The solution to above is changeelement
toByVal
:When extended to the variant case however:
Objects are also pointers... so
Also errors because we have a pointer directly to myArray(0) object. So the real work around is
The text was updated successfully, but these errors were encountered: