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

Bug in 'as' processing in pattern matching? 3.0.4 and 3.0.6 #8024

Closed
vicuna opened this issue Feb 21, 2003 · 2 comments
Closed

Bug in 'as' processing in pattern matching? 3.0.4 and 3.0.6 #8024

vicuna opened this issue Feb 21, 2003 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 21, 2003

Original bug ID: 1552
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hello, I was using 'as' patterns and found behavior that seemed strange.

--
let ((a,b) as x ,(c,d) as y) as z = ((1,2),(3,4))
in
((a,b,c,d),(x,y,z));;

I'd expect x == (a,b) and y == (c,d), but I don't get that, I get
y == ((a,b),(c,d))

Invoke this and see what I mean:

let ((a,b) as x ,(c,d) as y) as z = ((1,2),(3,4))
in
y;;

  • : (int * int) * (int * int) = (1, 2), (3, 4)
    --

Shouldn't it give me (3,4)?

However, if I insert an extra set of paremthesis, it works:

let ((a,b) as x ,((c,d) as y)) as z = ((1,2),(3,4))
in
y;;

  • : int * int = 3, 4
    --

So is this a bug?

Scott

@vicuna
Copy link
Author

vicuna commented Feb 23, 2003

Comment author: administrator

On Sun, 23 Feb 2003 15:29:14 +0100 (MET), Damien Doligez caml-bugs@pauillac.inria.fr writes:

Hello, I was using 'as' patterns and found behavior that seemed strange.

The answer to your question is found a bit further in your own mail...

Is SML-NJ the same? I don't remember it behaving the same way but
haven't used it in a while.

However, if I insert an extra set of paremthesis, it works:

So this is only a question of precedence. The "as" keyword has the lowest
precedence, so it binds everything to its left, unless you use parentheses.

Ah, I see. I had not realized that ',' is just another binary infix
operator. Now I see and understand. Thanks!

Scott

@vicuna
Copy link
Author

vicuna commented Feb 23, 2003

Comment author: administrator

Hello, I was using 'as' patterns and found behavior that seemed strange.

The answer to your question is found a bit further in your own mail...

However, if I insert an extra set of paremthesis, it works:

So this is only a question of precedence. The "as" keyword has the lowest
precedence, so it binds everything to its left, unless you use parentheses.

So is this a bug?

No, since it is properly documented. The worst you can call it is "an
unfortunate design decision".

-- Damien

@vicuna vicuna closed this as completed Feb 23, 2003
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant