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

Expand private type synonyms #485

Closed
yav opened this issue Nov 7, 2017 · 6 comments · Fixed by #903
Closed

Expand private type synonyms #485

yav opened this issue Nov 7, 2017 · 6 comments · Fixed by #903
Assignees
Labels
feature request Asking for new or improved functionality
Milestone

Comments

@yav
Copy link
Member

yav commented Nov 7, 2017

This is more of an improvement than a bug.
Consider the following example:

module A where

 f : [T]
 f = 10

 private type T = 8

In this case we are exporting f, but not the type synonym T. This is questionable practice, but I think that in this case, Cryptol should export f with type [8] rather than [A::T]. This type is equivalent, and the idea is that if the type synonym is not exported, then it should not be used when reporting types.

@yav yav added the feature request Asking for new or improved functionality label Nov 15, 2017
@brianhuffman
Copy link
Contributor

Instead, we could just report this situation as an error: You are not allowed to mention a private type synonym in the signature of an exported function.

@atomb atomb added this to the 3.0.0 milestone May 4, 2020
@brianhuffman
Copy link
Contributor

There are some other corner cases to consider: What if the type of a function f exported from module A mentions a type synonym that is defined in module B?

@brianhuffman
Copy link
Contributor

There are also two levels of strictness we could enforce:

  1. Require that types of exported functions must be expressible using only public types
  2. Require that types of exported functions must be able to have all type synonyms recursively expanded, without running into any private type synonyms

@brianhuffman
Copy link
Contributor

A desired property of the type pretty-printer is that if you print a type, you should be able to cut and paste the type and cryptol should be able to parse it back in.

@robdockins
Copy link
Contributor

I think the easiest thing to do here is to modify the pretty printer so that it will only print a type synonym if the name is currently in scope, and simply recurse into the body of the type definition otherwise. A quick look in the code leads me to believe all the necessary information is already available in the proper places.

@brianhuffman brianhuffman self-assigned this Sep 23, 2020
brianhuffman pushed a commit that referenced this issue Sep 23, 2020
@brianhuffman
Copy link
Contributor

I have a patch for this, which is just waiting in line behind some other PRs.

brianhuffman pushed a commit that referenced this issue Sep 23, 2020
This behavior was intentionally changed by the fix for #485.
brianhuffman pushed a commit that referenced this issue Sep 23, 2020
brianhuffman pushed a commit that referenced this issue Sep 23, 2020
This behavior was intentionally changed by the fix for #485.
@brianhuffman brianhuffman mentioned this issue Sep 23, 2020
brianhuffman pushed a commit that referenced this issue Sep 23, 2020
brianhuffman pushed a commit that referenced this issue Sep 23, 2020
This behavior was intentionally changed by the fix for #485.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Asking for new or improved functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants