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

#{x : t} should error when x is not a variable #1299

Open
sorawee opened this issue Jan 1, 2023 · 2 comments
Open

#{x : t} should error when x is not a variable #1299

sorawee opened this issue Jan 1, 2023 · 2 comments

Comments

@sorawee
Copy link
Contributor

sorawee commented Jan 1, 2023

What version of Racket are you using?

8.7

What program did you run?

#{(cons 1 2) : Number}

What should have happened?

It should error, because the syntax for #{x : t} requires x to be a variable. The type appears to be discarded, making it confusing why it's not used. This compounds with the problem that many people mistook #{x : t} for #{e :: t}, so it appears that the annotation doesn't work.

If you got an error message, please include it here.

N/A

Note that this issue originally came up in https://stackoverflow.com/questions/74974840/applying-to-potentially-empty-lists-in-typed-racket

@sorawee
Copy link
Contributor Author

sorawee commented Jan 1, 2023

Is there a way to recognize that #{x : t} is not used in a binding position?

@samth
Copy link
Sponsor Member

samth commented Jan 2, 2023

No, the syntax is a reader macro so it doesn't know anything about binding. But making it only work on symbols as the first component is easy.

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