-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(compiler)!: Prohibit mutating options [LNG-277] #960
Conversation
LNG-277 Prohibit mutating options
Right now it is possible to define options just like streams and mutate them:
It is documented in docs and used a lot in aqua code. But option implicitly canonicalized on return, making them immutable:
Also if a function accepts an option, it is prohibited to mutate it:
Moreover, there is no guarantee that option will actually contain at most one element (bc under the hood it is an array or a stream), except that for immutable options compiler will reject non-zero index access:
Also, streams are implicitly convertable (canonicalized) to options, so popular usage pattern is supported by them:
Everything described above makes options inconsistent data type, complicating compiler and aqua code. This is why it seems better to:
|
Also fixes LNG-270 |
Description
Forbid declaring options like streams and mutating them.
Proposed Changes / Implementation Details
DataType
as elements of streamsChecklist
Reviewer Checklist