Unify the representations of TupleTypeRepr
and StructRepr
#396
Labels
enhancement
symbolic-execution
Issues relating to macaw-symbolic and symbolic execution
tech-debt
Technical debt that would be nice to clean up
Currently,
macaw-base
definesTupleType
as:macaw/base/src/Data/Macaw/Types.hs
Lines 188 to 189 in a6ff58f
With a corresponding representation type,
TupleTypeRepr
, defined as:macaw/base/src/Data/Macaw/Types.hs
Line 229 in a6ff58f
This makes use of
Data.Parameterized.List
. When we convert Macaw tuples to Crucible values inmacaw-symbolic
, however, we convert the lists toCtx
s. For instance, here is howmacaw-symbolic
converts a list of MacawType
s to a struct of CrucibleType
s (which uses aCtx
under the hood):macaw/symbolic/src/Data/Macaw/Symbolic/PersistentState.hs
Lines 76 to 78 in a6ff58f
Similarly, here is how the conversion looks at the representation type level:
macaw/symbolic/src/Data/Macaw/Symbolic/PersistentState.hs
Lines 157 to 166 in a6ff58f
One peculiar thing about this conversion is that we reverse the order of fields when going from a list to a
Ctx
. This is rather surprising, and it has caused a handful of bugs in the past. See, for instance, #284 and #393. It would be nice if we can minimize the chances of similar bugs happening in the future.In light of this, here is one proposal: why not change
TupleType
to useCtx Type
instead of[Type]
as its field? If we did this, then we could to a Crucible struct without changing the order of fields at all, which would be much more straightforward. To be honest, I'm not sure why we don't do this already (aside from the breaking API changes it would introduce), given thatmacaw-base
already depends onparameterized-utils
.The text was updated successfully, but these errors were encountered: