Adding update and extend type support for data types#1255
Adding update and extend type support for data types#1255
Conversation
| | bar(a :: Number, ref b :: String) | ||
| end | ||
|
|
||
| bar(1, "a").{a: "a"} No newline at end of file |
There was a problem hiding this comment.
Are these test cases named correctly? This doesn't seem to be a missing field, it's a wrong type. In general, could you add a comment to each bad test, above the failing expression, explaining what the error should be?
There was a problem hiding this comment.
Oops I flipped two of the test files for both update and extend.
There was a problem hiding this comment.
This looks almost right...but you forgot to fix this specific file. After that, I'm good to merge this.
There was a problem hiding this comment.
I have fixed it now.
|
Thanks -- just to confirm: it is a design goal of the type checker to disallow adding fields to data values, right? If so, I'm good to merge... |
|
That is correct. |
|
Wow, we got static support for this feature before dynamic support is fully baked. Currently, update of existing fields does weird things dynamically, as does adding new fields. #835 is currently an error. See: https://github.com/orgs/brownplt/teams/pyret/discussions/8 I think we need a decision on the desired dynamic semantics of this before we can start blessing programs as typed. |
Allows extend and update syntax to be used on data types.
Errors if the fields do not occur in the data type, e.g.