[#698] Handle view ordering properly and some refactoring
This should mostly be okay, but I want to give it another look when I don't have a headache, hence marking as wip.
Description
Problem: parser doesn't remember ordering of view blocks
Solution: change EntriesOrder
to be a newtype over Map Entry Word
,
where Entry
is unique block identifier (for views that includes view
name, otherwise just block type), and Word
is the sort key for
ordering.
Remove entriesOrderToInt (afaict not used downstream, we can deprecate it if we have to, but its behaviour will be wonky).
Modify orderContractBlock
to check for duplicated views. Add error
handling for duplicated views in ensureNotDuplicate
.
Contracts with duplicated views now fail to parse, so move and adjust relevant tests.
Furthermore, use Map ViewName a
to represent typed and untyped views (mostly to optimize view lookups and enforce "no duplicates" invariant).
Finally, I noticed some not great code in Morley.Michelson.Macro
, so polished it a bit.
Related issue(s)
Resolves #698 (closed)
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.