| Anonymous | Login | Signup for a new account | 2013-05-21 18:55 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 | ||||||
| 0004158 | OCaml | OCaml general | public | 2006-11-12 19:05 | 2006-11-15 12:26 | ||||||
| Reporter | acone | ||||||||||
| Assigned To | |||||||||||
| Priority | normal | Severity | feature | Reproducibility | always | ||||||
| Status | acknowledged | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | |||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0004158: Disable warnings on a per-line basis | ||||||||||
| Description | If I do this in ocaml, I get a warning: type t = Foo of int | Bar of string let list_of_all_foos = [Foo 1; Foo 2; Foo 3] let _ = List.map (fun (Foo x) -> x) list_of_all_foos The warning, of course, is that the pattern match is incomplete. But it happens all the time that I *know* which constructor some value has, and an exhaustive match would need to have a catch-all case like | _ -> failwith "shouldn't get here" So I have three options, none of them satisfying: 1) Write the concise version above, and accept that I'll get a crapload of warnings. 2) Write the concise version above, and disable incomplete-match warnings. This mutilates type safety, which sucks. 3) Do the more pedantic, complete match, which makes code suprisingly unreadable (and in reality, no safer). So I want to keep the warnings on in general, but disable them for lines where I know what I'm doing. I should be able to do this in code, something like this: let _ = List.map (fun (Foo x) -> x) {\nowarn P} list_of_all_foos or maybe for a whole block of code: DisableWarning p;; let _ = List.map (fun (Foo x) -> x) {\nowarn P} list_of_all_foos EnableWarning p;; I realize this is a weird thing to ask for, as it mixes a hackerish compiler directive into the language. But I can't think of any other way to do this. | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2006-11-12 19:05 | acone | New Issue | |
| 2006-11-15 12:26 | doligez | Status | new => acknowledged |
| Copyright © 2000 - 2011 MantisBT Group |