Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005939OCamlOCaml generalpublic2013-03-06 18:562014-07-18 13:37
Reporterfrisch 
Assigned Todoligez 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version4.02.0+devFixed in Version4.02.0+dev 
Summary0005939: "fun (type t) when cond -> ..." should be rejected, maybe also "fun p when cond -> ..."
DescriptionI found the following when trying to clean up the Parsetree by putting Pexp_when clauses where they belong in the AST:

# fun (type t) when false -> 0;;
>> Fatal error: exit(0) outside appropriated catch
Fatal error: exception Misc.Fatal_error

The fix is not difficult (either in the parser or in the type-checker). But I'm wondering whether it make sense to keep the syntax:

 fun pat when cond -> ...

which necessarily triggers warning 25 (bad style, all clauses in this pattern-matching are guarded).

The Parsetree cleanup would be a little bit simpler if we got rid of this form as well. I doubt anyone uses it. I propose to get rid of it, after (i) asking on the caml-list if anyone objects; (ii) using OPAM to check that the construction is indeed not used in any of the packaged software.
TagsNo tags attached.
Attached Files

- Relationships
related to 0005936confirmed Weird syntax accepted by OCaml 

-  Notes
(0009085)
frisch (developer)
2013-04-12 13:51

0005936 seems to confirm that "fun pat when cond -> expr" can be removed with no harm.
(0009113)
frisch (developer)
2013-04-15 18:24

Commit 13528 on branch extension_points introduces an explicit representation of "cases" with an optional guard in order to get rid of the ugly Pexp_when. It also remove support for the construction "fun pat when cond -> expr". So, please don't remove it from the trunk, this will be part of the merge of extension_points.
(0009226)
frisch (developer)
2013-04-29 16:34

Setting Target Version = 4.02 (already fixed in extension_points, which will hopefully be merged in time for 4.02).
(0011883)
yallop (developer)
2014-07-18 13:36
edited on: 2014-07-18 13:36

This is fixed in 4.02.

In 4.01:

   # fun (type t) when true -> ();;
   >> Fatal error: exit(0) outside appropriated catch
   Fatal error: exception Misc.Fatal_error

   # fun _ when true -> ();;
   Characters 0-21:
     fun _ when true -> ();;
     ^^^^^^^^^^^^^^^^^^^^^
   Warning 25: bad style, all clauses in this pattern-matching are guarded.

In 4.02:

   # fun (type t) when true -> ();;
   Characters 13-17:
     fun (type t) when true -> ();;
                  ^^^^
   Error: Syntax error: operator expected.

   # fun _ when true -> ();;
   Characters 6-10:
     fun _ when true -> ();;
           ^^^^

There's a pull request open that updates the documentation:

   https://github.com/ocaml/ocaml-manual/pull/2 [^]


- Issue History
Date Modified Username Field Change
2013-03-06 18:56 frisch New Issue
2013-03-07 15:50 doligez Status new => confirmed
2013-04-12 13:49 frisch Relationship added related to 0005936
2013-04-12 13:51 frisch Note Added: 0009085
2013-04-15 18:24 frisch Note Added: 0009113
2013-04-25 17:05 doligez Assigned To => doligez
2013-04-25 17:05 doligez Status confirmed => assigned
2013-04-25 17:06 doligez Status assigned => confirmed
2013-04-29 16:34 frisch Note Added: 0009226
2013-04-29 16:34 frisch Target Version => 4.02.0+dev
2013-07-12 18:15 doligez Target Version 4.02.0+dev => 4.01.1+dev
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-18 13:36 yallop Note Added: 0011883
2014-07-18 13:36 yallop Note Edited: 0011883 View Revisions
2014-07-18 13:37 yallop Status confirmed => resolved
2014-07-18 13:37 yallop Fixed in Version => 4.02.0+dev
2014-07-18 13:37 yallop Resolution open => fixed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker