-
Notifications
You must be signed in to change notification settings - Fork 323
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
Use only Type instances as keys for State #7585
Conversation
@@ -158,23 +158,23 @@ optimize_fragments : Vector SQL_Fragment -> Vector SQL_Fragment | |||
optimize_fragments fragments = | |||
builder = Vector.new_builder | |||
go elem = | |||
last_part = State.get SQL_Fragment.Code_Part | |||
last_part = State.get SQL_Fragment |
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.
Code_Part
is an atom constructor - that's a singleton. We could allow atom constructors as keys, but then there is problem with argumentless constructors like Boolean.True
- they are immediately converted to Atom
during Enso execution and atoms in general aren't singletons.
Restricting keys to types is simpler.
@@ -12,7 +12,7 @@ from project.Errors.Common import Uninitialized_State | |||
|
|||
Arguments: | |||
- key: The key to associate your local_state with in the environment. | |||
It is recommended that types be used as keys. | |||
Use types as keys. |
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.
The signature of run : Any -> Any -> Any -> Any
remains unchanged, as we don't have any type for type Some_Type
.
Pull Request Description
Fixes #7572 by requiring keys to be Type instances.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.