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

Rebindable syntax: unintentional? #568

Closed
brianhuffman opened this issue Feb 8, 2019 · 2 comments
Closed

Rebindable syntax: unintentional? #568

brianhuffman opened this issue Feb 8, 2019 · 2 comments

Comments

@brianhuffman
Copy link
Contributor

It turns out that you can change the meaning of _ # _ patterns by defining a function called splitAt in a where clause.

Cryptol> (\(x # y) -> (y, x)) (True, False) where splitAt a = a
[warning] at <interactive>:1:42--1:49
    This binding for splitAt shadows the existing binding from
    (at /var/folders/hf/g8kjlj3x4cz05819qsk684_c0000gp/T/Cryptol98291-0.cry:347:11--347:18, splitAt)
(False, True)

I don't think this is intentional. We should probably make it so that# patterns always mean the same thing.

This would probably be easier to fix if we do the NoPat pass after renaming, instead of before. (See #567.)

@yav
Copy link
Member

yav commented Feb 8, 2019

Agreed :)

@brianhuffman
Copy link
Contributor Author

It looks like the unary operators - and ~ are also rebindable:

Cryptol> - 0x4 where negate x = x
[warning] at <interactive>:1:13--1:19
    This binding for negate shadows the existing binding from
    (at /var/folders/hf/g8kjlj3x4cz05819qsk684_c0000gp/T/Cryptol99252-0.cry:103:11--103:17, negate)
0x4
Cryptol> ~ 0x4 where complement x = x
[warning] at <interactive>:1:13--1:23
    This binding for complement shadows the existing binding from
    (at /var/folders/hf/g8kjlj3x4cz05819qsk684_c0000gp/T/Cryptol99252-0.cry:109:11--109:21, complement)
0x4

We should probably fix these too.

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