Skip to content

"fun (type t) when cond -> ..." should be rejected, maybe also "fun p when cond -> ..." #5939

@vicuna

Description

@vicuna

Original bug ID: 5939
Reporter: @alainfrisch
Assigned to: @damiendoligez
Status: closed (set by @xavierleroy on 2016-12-07T10:34:20Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.02.0+dev
Fixed in version: 4.02.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #5936

Bug description

I 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions