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

F* wrongly allows non-linear patterns #1121

Closed
catalin-hritcu opened this issue Jul 11, 2017 · 4 comments
Closed

F* wrongly allows non-linear patterns #1121

catalin-hritcu opened this issue Jul 11, 2017 · 4 comments

Comments

@catalin-hritcu
Copy link
Member

Recently discovered with @kyoDralliam that F* allows non-linear patterns:

let foo() : Tot int =
  match (1,2) with
  | (x,x) -> x

This is hugely unintuitive for users. Is this match complete? Does it equate the two elements of the pair? If not is this returning 1 or 2?

@cpitclaudel
Copy link
Contributor

FTR "yes", "no", 2. I agree it's unintuitive.

Ocaml and F# complain:

# let foo : int =
  match (1,2) with
  | (x,x) -> x;;

    Characters 42-43:
    | (x,x) -> x;;
         ^
Error: Variable x is bound several times in this matching
> let foo : int =
  match (1,2) with
  | (x,x) -> x;;

    | (x,x) -> x;;
  -------^

stdin(3,8): error FS0038: 'x' is bound twice in this pattern

@nikswamy
Copy link
Collaborator

Probably an easy fix in FStar.ToSyntax.ToSyntax.fs, in desugar_data_pat. There's a check_linear_pattern_variables at the end of that function, which apparently does not do the right thing.

@mtzguido
Copy link
Member

A PR for this: #1309

@mtzguido mtzguido mentioned this issue Oct 24, 2017
@mtzguido
Copy link
Member

I merged it, fixed by 2554cc1

mtzguido added a commit that referenced this issue Mar 23, 2020
For issues #1121, #1903 and #1954. Issue #829 is also relevant.
The PatternMatch.fst file also constains some various examples. While at
it, also add a check for #1956 (even if it never manifested).
mtzguido added a commit that referenced this issue Mar 24, 2020
For issues #829, #1121, #1228, #1903 and #1954. The PatternMatch.fst
file also constains some various examples. While at it, also add a check
for #1956 (even if it never manifested).
tahina-pro added a commit that referenced this issue Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants