Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006737OCamltypingpublic2014-12-29 11:382016-12-07 11:47
Assigned Tofrisch 
PlatformOSOS Version
Product Version4.02.1 
Target VersionFixed in Version4.03.0+dev / +beta1 
Summary0006737: The fun x -> body expression in Typedtree receives the attrbitutes of the body
DescriptionConsider the following lines from typing/

  | Pexp_fun (l, None, spat, sexp) ->
      type_function ?in_function loc sexp.pexp_attributes env ty_expected
        l [{pc_lhs=spat; pc_guard=None; pc_rhs=sexp}]
  | Pexp_function caselist ->
      type_function ?in_function
        loc sexp.pexp_attributes env ty_expected "" caselist

When type-checking the Pexp_function, the resulting Texp_function node will receive
sexp.pexp_attributes, which are the attributes of the whole function expression.
On the other hand, in case of Pexp_fun, the resulting Text_function node will receive sexp.pexp_attributes -- which now refers to the attributes of the body
of the function rather than the attributes of the entire fun x -> body expression. Note that the identifier sexp is shadowed in the Pexp_fun clause.
This is an inconsistent, and seemingly wrong behavior (and yes, it affects me directly).
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
frisch (developer)
2015-01-06 12:04

Thanks Oleg. This is now fixed in trunk, commit 15763. There is some more work to do to keep proper attributes in presence of optional arguments with default values.

Out of curiosity, what is your use for attributes on Typedtree?
frisch (developer)
2015-01-06 12:18

Commit 15764 fixes the issue with default value on optional arguments. (The Typedtree representation of such default values remains a little bit ugly. I would prefer a more direct type-checking of that construction, without encoding, and a proper representation in the Typedtree.)

- Issue History
Date Modified Username Field Change
2014-12-29 11:38 oleg New Issue
2015-01-06 11:58 frisch Assigned To => frisch
2015-01-06 11:58 frisch Status new => assigned
2015-01-06 12:04 frisch Note Added: 0013014
2015-01-06 12:18 frisch Note Added: 0013015
2015-01-06 12:26 frisch Status assigned => resolved
2015-01-06 12:26 frisch Fixed in Version => 4.03.0+dev / +beta1
2015-01-06 12:26 frisch Resolution open => fixed
2016-12-07 11:47 xleroy Status resolved => closed
2017-02-23 16:45 doligez Category OCaml typing => typing

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker