-
Notifications
You must be signed in to change notification settings - Fork 124
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
Map representation for record types #706
Comments
I think we should treat field name ordering in the same way that the MacOS filesystem treats case: It should be order-insensitive, yet order-preserving. For example, if I ask for the type of So we might want to switch to using a To avoid the kind of programming errors we've been seeing, perhaps we should introduce a new type for order-preserving, order-insensitive maps; it could be implemented as a newtype wrapper around |
We're currently being pretty inconsistent about this, so some sort of system for handling it would be good. Perhaps a map structure together with a list indicating the "display order" of the fields would accomplish what we want. |
Yes, that would be another way to implement it. We should wrap it up in a new abstract datatype so that we don't have to care how it's implemented. |
In a comment on #703, I mentioned that I would like for |
@brianhuffman, are you still planning to work on this soon? |
It kind of fell off my radar; my top priority right now is the remaining soundness issues in saw-script. If you want to work on it now, you won't be stepping on my toes. |
Here is an exciting interaction I discovered. Apparently we haven't been checking for duplicate fields. I'm going to declare that this is a Bad Thing and remove this behavior as part of fixing this ticket.
|
This type stores records as a finite map from field names to values, while also remembering the original order of the fields from when the record was generated (usually, from the program source). For all "semantic" purposes, the fields are treated as appearing in a canoical order (in sorted order of the field names). However, for user display purposes, records are presented in the order in which the fields were originally stated. In the course of implementing this, I discovered that we were not previously checking for repeated fields in the parser or typechecker, which would result in some rather strange situations and could probably be used to break the type safety. This is now fixed and repeated fields will result in either a parse error or a panic (for records generated internally). Fixes #706
This type stores records as a finite map from field names to values, while also remembering the original order of the fields from when the record was generated (usually, from the program source). For all "semantic" purposes, the fields are treated as appearing in a canoical order (in sorted order of the field names). However, for user display purposes, records are presented in the order in which the fields were originally stated. In the course of implementing this, I discovered that we were not previously checking for repeated fields in the parser or typechecker, which would result in some rather strange situations and could probably be used to break the type safety. This is now fixed and repeated fields will result in either a parse error or a panic (for records generated internally). Fixes #706
This type stores records as a finite map from field names to values, while also remembering the original order of the fields from when the record was generated (usually, from the program source). For all "semantic" purposes, the fields are treated as appearing in a canoical order (in sorted order of the field names). However, for user display purposes, records are presented in the order in which the fields were originally stated. In the course of implementing this, I discovered that we were not previously checking for repeated fields in the parser or typechecker, which would result in some rather strange situations and could probably be used to break the type safety. This is now fixed and repeated fields will result in either a parse error or a panic (for records generated internally). Fixes #706
We've had several bugs relating to non-normalized field order for record types (#702, #667); I'm pretty sure this isn't a comprehensive list.
We should probably fix this problem once-and-for-all by making sure all the intermediate type and value datatypes from typechecking onward use a
Map
or some other datastructure that enforces canonical ordering.The text was updated successfully, but these errors were encountered: