| Anonymous | Login | Signup for a new account | 2013-05-25 16:03 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0004886 | OCaml | Camlp4 | public | 2009-10-03 20:31 | 2012-09-18 04:29 | ||||||
| Reporter | yallop | ||||||||||
| Assigned To | garrigue | ||||||||||
| Priority | normal | Severity | minor | Reproducibility | always | ||||||
| Status | feedback | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | 3.11.1 | ||||||||||
| Target Version | 4.00.2+dev | Fixed in Version | |||||||||
| Summary | 0004886: Desugaring of camlp4 quotations of labeled patterns duplicates variables | ||||||||||
| Description | Here's a function that extracts the label from a typed labeled pattern: open Camlp4.PreCast let extract_label = function | <:expr< fun ~ ($lab$:$_$) -> $_$ >> -> lab Here's what happens when you try to compile it: $ ocamlc -I +camlp4 -pp camlp4of -c patt.ml File "patt.ml", line 4, characters 11-14: Error: Variable lab is bound several times in this matching This is surprising to the user because 'lab' only appears once in the pattern in the source file. Here's the camlp4 output, showing that the variable 'lab' has been duplicated: $ camlp4of patt.ml open Camlp4.PreCast let extract_label = function | Ast.ExFun (_, (Ast.McArr (_, (Ast.PaLab (_, lab, (Ast.PaTyc (_, (Ast.PaId (_, (Ast.IdLid (_, lab)))), _)))), (Ast.ExNil _), _))) -> lab Here's where I think the duplication occurs in the camlp4 source: | "~"; "("; i = a_LIDENT; ":"; t = ctyp; ")" -> <:patt< ~ $i$ : ($lid:i$ : $t$) >> (camlp4/Camlp4Parsers/Camlp4OCamlParser.ml) | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Notes |
|
|
(0008101) garrigue (manager) 2012-09-18 04:29 |
I think there is no bug here, but a misunderstanding about label syntax: fun ~(lab:typ) -> exp is an abbreviated syntax equivalent to fun ~lab:(lab:typ) -> exp and they share the same abstract syntax representation. For this reason, if you want to get the label, you should just write: <:expr< fun ~$lab$:$_$ -> $_$ >> (Not checked) |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2009-10-03 20:31 | yallop | New Issue | |
| 2009-10-03 20:31 | yallop | Status | new => assigned |
| 2009-10-03 20:31 | yallop | Assigned To | => ertai |
| 2012-07-11 13:34 | doligez | Target Version | => 4.01.0+dev |
| 2012-07-12 11:29 | doligez | Assigned To | ertai => |
| 2012-07-12 11:29 | doligez | Status | assigned => acknowledged |
| 2012-07-31 13:36 | doligez | Target Version | 4.01.0+dev => 4.00.1+dev |
| 2012-09-17 17:37 | doligez | Target Version | 4.00.1+dev => 4.00.2+dev |
| 2012-09-18 04:29 | garrigue | Note Added: 0008101 | |
| 2012-09-18 04:29 | garrigue | Assigned To | => garrigue |
| 2012-09-18 04:29 | garrigue | Status | acknowledged => feedback |
| Copyright © 2000 - 2011 MantisBT Group |