-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve and fix static types and their ID and string functions #2756
Improve and fix static types and their ID and string functions #2756
Conversation
…s/accesses, and intersection type
…nd reference type, so it matches sema
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## feature/stable-cadence #2756 +/- ##
==========================================================
+ Coverage 79.60% 79.63% +0.02%
==========================================================
Files 337 337
Lines 80575 80462 -113
==========================================================
- Hits 64145 64077 -68
+ Misses 14125 14086 -39
+ Partials 2305 2299 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:feature/stable-cadence commit 978dc9d Collapsed results for better readability
|
Depends on #2648
Description
So far, both
sema.Type
andcadence.Type
hadID
functions, which returned the type ID. With #2750, alsointerpreter.StaticType
got anID
function.Most of these functions re-implemented the ID generation, which is hard to maintain and error prone (inconsistencies). In some cases the ID generation was mixed with the string (human-readable) representation, and the string formatting was re-implemented as both metered and unmetered variants.
Reduce the potential for inconsistencies by implementing the ID generation in a central place, as
sema.Format*TypeID
functions, and use them in theID
functions of all three Go types representing types.#2754 had previously already started to sort entitlement sets.
We also need to sort type IDs in intersection type IDs.
Avoid code duplication in string formatting functions, by delegating unmetered functions (
String
) to metered ones (MeteredString
). Also fix memory metering along the way (in some cases memory was allocated before it was metered).Ensure that the type ID generation for entitlement sets in entitlement set authorizations and for intersection types sorts the type IDs. Keep the user-defined order in string formatting functions (e.g.
String
andQualifiedString
). Avoid allocating multiple ordered maps when generating the sorted type IDs.Add tests for the ID and string functions of authorizations, reference types, and intersection types, on all three levels (
sema
,interpreter
, andcadence
).Also:
interpreter.StaticType
s to be pointer types, as they might get nested and could potentially lead to lots of data being copied. This wasn't really necessary, but noticed a bit late, but maybe still a good improvement.assert
where it makes sense, fix argument order (expected, actual), avoid repeated casts, etc.master
branchFiles changed
in the Github PR explorer