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

enforce that we don't add vars twice to env Gamma #10

Open
womeier opened this issue Dec 2, 2023 · 3 comments
Open

enforce that we don't add vars twice to env Gamma #10

womeier opened this issue Dec 2, 2023 · 3 comments

Comments

@womeier
Copy link
Collaborator

womeier commented Dec 2, 2023

Currently, we don't check if a var is already in Gamma before adding it. We could check and throw an error if it is already present.

@mkarup
Copy link
Collaborator

mkarup commented Dec 3, 2023

Isn't it okay for the same variable name to be in there more than once, since we pick the first one we encounter, if it's there? Is it in correlation with the constructors, where you can "overwrite" the definition of one of the constructors?

@womeier
Copy link
Collaborator Author

womeier commented Dec 3, 2023

this was in reaction to

Since constructors and data types are part of the "global environment", I "inject" the constructors into the environment as a preprocessing step. I did this to avoid changing typechecking too much, e.g. adding an extra environment for data types/ constructors and passing that around. Do you think this preprocessing should be more incorporated into the typechecking, e.g. so checking that the definition of the constructors/ data types is reasonable, and that there are no name clashes, is part of typechecking?

Thought, if we just raised an exception for duplicate entries, this would be a simple solution for name clashes.
In case we decide, we want to prevent that, just opened it since you brought it up there.

@mkarup
Copy link
Collaborator

mkarup commented Dec 4, 2023

this was in reaction to

Since constructors and data types are part of the "global environment", I "inject" the constructors into the environment as a preprocessing step. I did this to avoid changing typechecking too much, e.g. adding an extra environment for data types/ constructors and passing that around. Do you think this preprocessing should be more incorporated into the typechecking, e.g. so checking that the definition of the constructors/ data types is reasonable, and that there are no name clashes, is part of typechecking?

Thought, if we just raised an exception for duplicate entries, this would be a simple solution for name clashes. In case we decide, we want to prevent that, just opened it since you brought it up there.

I think it's fine for regular variables that can be let bound. I've updated the data type PR to try to account for the issue. This should prevent 'overriding' constructor names

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

No branches or pull requests

2 participants