Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006454OCamlOCaml generalpublic2014-06-09 11:522014-07-07 17:05
Reporterlpw25 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.02.0+dev 
Target VersionFixed in Version 
Summary0006454: Item attributes are allowed on regular let bindings
DescriptionItem attributes are allowed on non-item let bindings. For example:

    # let x =
        let g x = x [@@foo] in g 5;;
      val x : int = 5

the attached patch fixes this:

    # let x =
        let g x = x [@@foo] in g 5;;
      Characters 24-27:
          let g x = x [@@foo] in g 5;;
                      ^^^
    Error: Syntax error
Tagspatch
Attached Filespatch file icon fix-let-attrs.patch [^] (2,824 bytes) 2014-06-09 11:52 [Show Content]
diff file icon 6454.diff [^] (1,406 bytes) 2014-06-10 16:05 [Show Content]

- Relationships

-  Notes
(0011719)
frisch (developer)
2014-06-10 11:51

Wouldn't it be simpler to reject item attributes with an explicit check in the semantic action, rather than tweaking the grammar?
(0011720)
lpw25 (developer)
2014-06-10 12:51
edited on: 2014-06-10 12:52

I considered that but, since the attributes don't carry location information, getting a good error message that way looked like more work than tweaking the grammar.

(0011722)
frisch (developer)
2014-06-10 16:05
edited on: 2014-06-10 16:05

With the attached patch:

# let x =
          let g x = x [@@foo] in g 5;;
              ^^^^^^^^^^^^^^^


Error: Syntax error: @@-attribute not expected.


I don't think that the less precise location is necessarily a bad thing. Do you agree?

(0011724)
lpw25 (developer)
2014-06-10 16:19

> I don't think that the less precise location is necessarily a bad thing. Do you agree?

In exchange for the simpler code it seems reasonable. I think it should be "item attribute" rather than "@@-attribute".
(0011726)
frisch (developer)
2014-06-10 16:24

Ok, I've adapted the wording and committed that to 4.02 (commit 14982).
(0011790)
clarus (reporter)
2014-07-07 14:44

I was actually using this bug/feature to add attributes on inner lets :).

What is the right syntax to do it now? By the way, this syntax still works with OCaml trunk, I do not know if it is expected.
(0011791)
frisch (developer)
2014-07-07 17:05

> What is the right syntax to do it now?

  let[@foo] x = ... in ...

or:

  (let x = ... in ...)[@foo]

> By the way, this syntax still works with OCaml trunk, I do not know if it is expected.

Yes, some recent changes on the 4.02 branch will be back-ported in batch on trunk when 4.02 is released.

- Issue History
Date Modified Username Field Change
2014-06-09 11:52 lpw25 New Issue
2014-06-09 11:52 lpw25 File Added: fix-let-attrs.patch
2014-06-09 15:05 lpw25 Tag Attached: patch
2014-06-10 11:51 frisch Note Added: 0011719
2014-06-10 12:51 lpw25 Note Added: 0011720
2014-06-10 12:52 lpw25 Note Edited: 0011720 View Revisions
2014-06-10 16:02 frisch File Added: 6454.diff
2014-06-10 16:05 frisch Note Added: 0011722
2014-06-10 16:05 frisch File Deleted: 6454.diff
2014-06-10 16:05 frisch File Added: 6454.diff
2014-06-10 16:05 frisch Note Edited: 0011722 View Revisions
2014-06-10 16:19 lpw25 Note Added: 0011724
2014-06-10 16:24 frisch Note Added: 0011726
2014-06-10 16:24 frisch Status new => resolved
2014-06-10 16:24 frisch Resolution open => fixed
2014-06-10 16:24 frisch Assigned To => frisch
2014-07-07 14:44 clarus Note Added: 0011790
2014-07-07 17:05 frisch Note Added: 0011791


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker