You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6737 Reporter: oleg Assigned to:@alainfrisch Status: closed (set by @xavierleroy on 2016-12-07T10:47:02Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.1 Fixed in version: 4.03.0+dev / +beta1 Category: typing Monitored by:@gasche
Bug description
Consider the following lines from typing/typecore.ml
| 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).
The text was updated successfully, but these errors were encountered:
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?
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.)
Original bug ID: 6737
Reporter: oleg
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2016-12-07T10:47:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.1
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Monitored by: @gasche
Bug description
Consider the following lines from typing/typecore.ml
| 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).
The text was updated successfully, but these errors were encountered: