-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add constructor functions for run-time types #1195
Conversation
…n the interpreter
Codecov Report
@@ Coverage Diff @@
## master #1195 +/- ##
==========================================
+ Coverage 77.03% 77.15% +0.12%
==========================================
Files 273 273
Lines 33962 34132 +170
==========================================
+ Hits 26163 26335 +172
+ Misses 6732 6728 -4
- Partials 1067 1069 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This feels little bloated to me to be honest. Do we really need this much options? What are the security and robustness concerns for |
This isn't any more bloated than directly parsing the string; if anything it provides a cleaner API. Consider an example where you have a As for security, whenever we parse strings directly into runtime values there is always the concern of users providing malicious input; one can imagine a scenario in which a developer might try to parse user input into a runtime type and make decisions based on that; using a limited API lowers the risk associated with this kind of thing. |
For me this is a bit strange example because honestly I can't imagine any practical use case. |
The issue linked in the summary contains a link to a discussion about NFT metadata. Users would like to be able to store type identifiers in the metadata of their NFTs, and construct types at runtime from those identifiers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 👏
This is almost done, just a few small things 👍
Co-authored-by: Bastian Müller <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👏
Co-authored-by: Supun Setunga <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one last request to rename the error, but should be good to merge after that. Nice work!
Closes #1137
Description
Users have requested the ability to produce run-time types from their identifiers. #1137 suggested using the string representation of the type, but this is not robust and has potential security concerns. Instead, this PR adds an API to allow users to dynamically construct run-time types.
In order to re-use the static typechecking we do to ensure the integrity of restricted types, this also refactors to decouple the functionality of checking the correctness of a restricted type from reporting any type errors associated with that type. This way the interpreter can re-use the logic to return
nil
in scenarios where the checker would have rejected a restricted type.master
branchFiles changed
in the Github PR explorer