Skip to content
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

Adding update and extend type support for data types #1255

Open
wants to merge 3 commits into
base: horizon
Choose a base branch
from

Conversation

mkolosick
Copy link
Contributor

Allows extend and update syntax to be used on data types.
Errors if the fields do not occur in the data type, e.g.

data Foo:
  | bar(a :: Number)
end

bar(1).{b: 3}

| bar(a :: Number, ref b :: String)
end

bar(1, "a").{a: "a"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops I flipped two of the test files for both update and extend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks almost right...but you forgot to fix this specific file. After that, I'm good to merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed it now.

@blerner
Copy link
Member

blerner commented Dec 17, 2017

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...

@mkolosick
Copy link
Contributor Author

That is correct.

@jpolitz
Copy link
Member

jpolitz commented Mar 20, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants