Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006677OCamltypingpublic2014-11-26 05:402017-02-24 16:13
Reporterfuruse 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.02.1 
Target VersionFixed in Version4.03.0 
Summary0006677: Toplevel let should take attributes.
DescriptionIn 4.02.1, the toplevel let does not accept attributes but only extensions, while the local let accepts the both. Is this asymmetry required?

This is problematic when ppx code generators produce toplevel bindings possibly recursive but not necessarily.

At the local lets we can use [@ocaml.warning "-39"] to stop the warning:

    let [@ocaml.warning "-39"] rec x = 1 in x (* nice! *)

But it seems the same technique is not usable against the toplevel let:

    let [@ocaml.warning "-39"] rec x = 1;;

TagsNo tags attached.
Attached Files

- Relationships
related to 0006714resolvedwhitequark Also recognize [@@ocaml.warning] 
related to 0006586closed Short-hand version of attributes on structure items and class fields 

-  Notes
(0012579)
furuse (reporter)
2014-11-26 05:43
edited on: 2015-01-06 22:03

Oh 0006586 is technically the same issue.

The motivation here is to control the warning 39 at the toplevel let recs by attributes.

(0012581)
furuse (reporter)
2014-11-26 05:55

[@@@ocaml.warning "-39"]
let rec x = 1

works but it changes the setting globally...
(0013766)
doligez (administrator)
2015-04-29 20:36

This is not exactly the same as 0006586: what you need is not a shorthand notation but any way at all of placing an attribute on the whole let.
(0014869)
frisch (developer)
2015-11-27 18:13

Toplevel lets accept attributes. As for any other structure/signature item, the syntax is [@@...] following the item:

  let rec x = 1 in x
    [@@ocaml.warning "-39"]

Now I don't think that ocaml.warning is interpreted in such context, but this is another story. If this is about generated code, a workaround is to generate:

  include struct
    [@@@ocaml.warning "-39"]
    let rec x = 1 in x
  end
(0015473)
whitequark (developer)
2016-03-12 05:43

I think this was fixed in 4.03.
(0015497)
frisch (developer)
2016-03-14 17:21

> let [@ocaml.warnings "-39"] rec x = 1;;

This is now allowed syntactically; the attribute is attached to the "value_binding".

But the ocaml.warning attribute is not interpreted on value bindings.
I've pushed a fix ( https://github.com/ocaml/ocaml/commit/ddb2826029dbef11c6950e44118508c696d3f0ad [^] ) to the specific problem reported here; warning 39 requires a specific treatment anyway since it is a global property of the "let rec" declaration, not local to one of the (potentially) multiple value bindings in it.

It could make sense to control warnings while type-checking each binding, but this would require a different fix anyway. I suggest to keep this ticket open for this part.
(0017455)
frisch (developer)
2017-02-24 16:13

The original issue (being able to add attributes on toplevel lets) has been fixed. Marking as fixed for now. I don't know how critical is the remaining part (interpreting the ocaml.warning attribute). Feel free to open another ticket for this part.

- Issue History
Date Modified Username Field Change
2014-11-26 05:40 furuse New Issue
2014-11-26 05:43 furuse Note Added: 0012579
2014-11-26 05:49 furuse Note Added: 0012580
2014-11-26 05:53 furuse Note Deleted: 0012580
2014-11-26 05:55 furuse Note Added: 0012581
2014-12-21 19:38 whitequark Relationship added related to 0006714
2015-01-06 22:02 doligez Relationship added related to 0006586
2015-01-06 22:03 doligez Note Edited: 0012579 View Revisions
2015-01-06 22:03 doligez Status new => acknowledged
2015-01-13 22:14 doligez Target Version => 4.02.2+dev / +rc1
2015-04-29 20:36 doligez Note Added: 0013766
2015-04-29 20:36 doligez Target Version 4.02.2+dev / +rc1 => 4.02.3+dev
2015-04-29 20:36 doligez Target Version 4.02.3+dev => 4.03.0+dev / +beta1
2015-11-27 18:13 frisch Note Added: 0014869
2015-11-27 18:13 frisch Severity major => minor
2015-11-27 18:13 frisch Target Version 4.03.0+dev / +beta1 => later
2016-03-12 05:43 whitequark Note Added: 0015473
2016-03-14 17:21 frisch Note Added: 0015497
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-02-24 13:33 doligez Assigned To => frisch
2017-02-24 13:33 doligez Status acknowledged => assigned
2017-02-24 13:33 doligez Category -OCaml general => typing
2017-02-24 13:33 doligez Target Version later =>
2017-02-24 16:13 frisch Note Added: 0017455
2017-02-24 16:13 frisch Status assigned => resolved
2017-02-24 16:13 frisch Resolution open => fixed
2017-02-24 16:13 frisch Fixed in Version => 4.03.0


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker