[RFC007] Extract runtime contract equality out of typecheck #2130
+528
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR continues the preparation work to migrate the typechecker to the new AST. One current blocker is that
typecheck::eq
is used both by the typechecker and at runtime for contract deduplication. We need to get rid of this module when switching the typechecker implementation, while still needing to perform contract deduplication at runtime (until the landing of the bytecode virtual machine).This PR extracts the code from
typecheck::eq
for contract deduplication in a new module, so that the runtime isn't dependent ontypecheck
anymore. The code is specialized (as it doesn't need to handle static contract equality), and in order to eliminate the dependence onUnifType
, we drop the ability to compare polymorphic types. The latter is the only reasontypecheck::eq
operated onUnifType
instead ofType
(which makes it dependent on the old typechecker), but the motivation is not very convincing: how many times do we encounter a type annotation, itself inside a contract annotation, such that annotation is a polymorphic type AND it happens to be a candidate for deduplication? Our intuition would be: zero.This hypothesis has been validated on our working benchmarks, as
--metrics
show detailed data on contract deduplication - including the total count of deduplicated contracts - which doesn't change between this PR and master.