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
Use this new type for a state parameter that does not explicitly set array: false
The parameter type’s encode function is never invoked during state transitions, so the parameter is not encoded correctly.
The reason
Because the parameter does not declare array: false its type is wrapped into an ArrayType during state declaration – that’s before the type’s definitionFn is invoked.
But ArrayType defines its encode function (and others) based on the wrapped type’s functions at the time when ArrayType is instantiated. ArrayType stores a reference to the old encode function (which was undefined, so it’s the identity function) instead of looking up the actual function when ArrayType.encode is called.
The problem
definitionFn
instead of thedefinition
objectarray: false
encode
function is never invoked during state transitions, so the parameter is not encoded correctly.The reason
Because the parameter does not declare
array: false
its type is wrapped into anArrayType
during state declaration – that’s before the type’sdefinitionFn
is invoked.But
ArrayType
defines itsencode
function (and others) based on the wrapped type’s functions at the time whenArrayType
is instantiated.ArrayType
stores a reference to the oldencode
function (which was undefined, so it’s theidentity
function) instead of looking up the actual function whenArrayType.encode
is called.Later, the type’s
definitionFn
is invoked and redefines theencode
function, but the array params still reference the identity function.The solution
ArrayType
until after alldefinitionFn
s were invoked (probably compilcated)ArrayType
’s functions based on the run-time value of the wrapped type’s functions instead of capturing them locally.The text was updated successfully, but these errors were encountered: