| Attached Files | diff.diff [^] (11,455 bytes) 2010-06-15 12:44 [Show Content] [Hide Content]Index: tools/depend.ml
===================================================================
--- tools/depend.ml (revision 10565)
+++ tools/depend.ml (working copy)
@@ -111,7 +111,7 @@
| Ppat_tuple pl -> List.iter (add_pattern bv) pl
| Ppat_construct(c, op, _) -> add bv c; add_opt add_pattern bv op
| Ppat_record(pl, _) ->
- List.iter (fun (lbl, p) -> add bv lbl; add_pattern bv p) pl
+ List.iter (fun (lbl, p) -> add bv lbl.li_desc; add_pattern bv p) pl
| Ppat_array pl -> List.iter (add_pattern bv) pl
| Ppat_or(p1, p2) -> add_pattern bv p1; add_pattern bv p2
| Ppat_constraint(p, ty) -> add_pattern bv p; add_type bv ty
@@ -134,10 +134,10 @@
| Pexp_construct(c, opte, _) -> add bv c; add_opt add_expr bv opte
| Pexp_variant(_, opte) -> add_opt add_expr bv opte
| Pexp_record(lblel, opte) ->
- List.iter (fun (lbl, e) -> add bv lbl; add_expr bv e) lblel;
+ List.iter (fun (lbl, e) -> add bv lbl.li_desc; add_expr bv e) lblel;
add_opt add_expr bv opte
- | Pexp_field(e, fld) -> add_expr bv e; add bv fld
- | Pexp_setfield(e1, fld, e2) -> add_expr bv e1; add bv fld; add_expr bv e2
+ | Pexp_field(e, fld) -> add_expr bv e; add bv fld.li_desc
+ | Pexp_setfield(e1, fld, e2) -> add_expr bv e1; add bv fld.li_desc; add_expr bv e2
| Pexp_array el -> List.iter (add_expr bv) el
| Pexp_ifthenelse(e1, e2, opte3) ->
add_expr bv e1; add_expr bv e2; add_opt add_expr bv opte3
Index: typing/typetexp.ml
===================================================================
--- typing/typetexp.ml (revision 10565)
+++ typing/typetexp.ml (working copy)
@@ -84,7 +84,7 @@
let find_constructor = find_component Env.lookup_constructor (fun lid -> Unbound_constructor lid)
-let find_label = find_component Env.lookup_label (fun lid -> Unbound_label lid)
+let find_label env li = find_component Env.lookup_label (fun lid -> Unbound_label lid) env li.li_loc li.li_desc
let find_class = find_component Env.lookup_class (fun lid -> Unbound_class lid)
Index: typing/typecore.ml
===================================================================
--- typing/typecore.ml (revision 10565)
+++ typing/typecore.ml (working copy)
@@ -347,7 +347,7 @@
let rec find_record_qual = function
| [] -> None
- | (Longident.Ldot (modname, _), _) :: _ -> Some modname
+ | ({li_desc = Longident.Ldot (modname, _)}, _) :: _ -> Some modname
| _ :: rest -> find_record_qual rest
let type_label_a_list type_lid_a lid_a_list =
@@ -356,8 +356,8 @@
| Some modname ->
List.map
(function
- | (Longident.Lident id), sarg ->
- type_lid_a (Longident.Ldot (modname, id), sarg)
+ | {li_desc = Longident.Lident id} as li, sarg ->
+ type_lid_a ({li with li_desc = Longident.Ldot (modname, id)}, sarg)
| lid_a -> type_lid_a lid_a)
lid_a_list
@@ -493,14 +493,14 @@
| Ppat_record(lid_sp_list, closed) ->
let ty = newvar() in
let type_label_pat (lid, sarg) =
- let label = Typetexp.find_label env loc lid in
+ let label = Typetexp.find_label env lid in
begin_def ();
let (vars, ty_arg, ty_res) = instance_label false label in
if vars = [] then end_def ();
begin try
unify env ty_res ty
with Unify trace ->
- raise(Error(loc, Label_mismatch(lid, trace)))
+ raise(Error(lid.li_loc, Label_mismatch(lid.li_desc, trace)))
end;
let arg = type_pat env sarg in
unify_pat env arg ty_arg;
@@ -512,7 +512,7 @@
let tv = expand_head env tv in
tv.desc <> Tvar || tv.level <> generic_level in
if List.exists instantiated vars then
- raise (Error(loc, Polymorphic_label lid))
+ raise (Error(lid.li_loc, Polymorphic_label lid.li_desc))
end;
(label, arg)
in
@@ -1142,7 +1142,7 @@
match (lid_sexp, lbl_exp) with
((lid, _) :: rem1, (lbl, _) :: rem2) ->
if List.mem lbl.lbl_pos seen_pos
- then raise(Error(loc, Label_multiply_defined lid))
+ then raise(Error(lid.li_loc, Label_multiply_defined lid.li_desc))
else check_duplicates (lbl.lbl_pos :: seen_pos) rem1 rem2
| (_, _) -> () in
check_duplicates [] lid_sexp_list lbl_exp_list;
@@ -1190,7 +1190,7 @@
exp_env = env }
| Pexp_field(sarg, lid) ->
let arg = type_exp env sarg in
- let label = Typetexp.find_label env loc lid in
+ let label = Typetexp.find_label env lid in
let (_, ty_arg, ty_res) = instance_label false label in
unify_exp env arg ty_res;
re {
@@ -1203,7 +1203,7 @@
let (label, newval) =
type_label_exp false env loc record.exp_type (lid, snewval) in
if label.lbl_mut = Immutable then
- raise(Error(loc, Label_not_mutable lid));
+ raise(Error(loc, Label_not_mutable lid.li_desc));
re {
exp_desc = Texp_setfield(record, label, newval);
exp_loc = loc;
@@ -1618,7 +1618,7 @@
type_exp (!type_open env sexp.pexp_loc lid) e
and type_label_exp create env loc ty (lid, sarg) =
- let label = Typetexp.find_label env sarg.pexp_loc lid in
+ let label = Typetexp.find_label env lid in
begin_def ();
if !Clflags.principal then begin_def ();
let (vars, ty_arg, ty_res) = instance_label true label in
@@ -1630,10 +1630,10 @@
begin try
unify env (instance ty_res) ty
with Unify trace ->
- raise(Error(loc , Label_mismatch(lid, trace)))
+ raise(Error(lid.li_loc , Label_mismatch(lid.li_desc, trace)))
end;
if label.lbl_private = Private then
- raise(Error(loc, if create then Private_type ty else Private_label (lid, ty)));
+ raise(Error(lid.li_loc, if create then Private_type ty else Private_label (lid.li_desc, ty)));
let arg =
let snap = if vars = [] then None else Some (Btype.snapshot ()) in
let arg = type_argument env sarg ty_arg in
Index: typing/typetexp.mli
===================================================================
--- typing/typetexp.mli (revision 10565)
+++ typing/typetexp.mli (working copy)
@@ -75,7 +75,7 @@
val find_type: Env.t -> Location.t -> Longident.t -> Path.t * Types.type_declaration
val find_constructor: Env.t -> Location.t -> Longident.t -> Types.constructor_description
-val find_label: Env.t -> Location.t -> Longident.t -> Types.label_description
+val find_label: Env.t -> Parsetree.longident -> Types.label_description
val find_value: Env.t -> Location.t -> Longident.t -> Path.t * Types.value_description
val find_class: Env.t -> Location.t -> Longident.t -> Path.t * Types.class_declaration
val find_module: Env.t -> Location.t -> Longident.t -> Path.t * Types.module_type
Index: parsing/parser.mly
===================================================================
--- parsing/parser.mly (revision 10565)
+++ parsing/parser.mly (working copy)
@@ -40,6 +40,8 @@
{ pcl_desc = d; pcl_loc = symbol_rloc() }
let mkcty d =
{ pcty_desc = d; pcty_loc = symbol_rloc() }
+let mkli d =
+ { li_desc = d; li_loc = symbol_rloc() }
let reloc_pat x = { x with ppat_loc = symbol_rloc () };;
let reloc_exp x = { x with pexp_loc = symbol_rloc () };;
@@ -202,10 +204,10 @@
then Lapply(p1, p2)
else raise (Syntaxerr.Error(Syntaxerr.Applicative_path (symbol_rloc())))
-let exp_of_label lbl =
+let exp_of_label {li_desc = lbl} =
mkexp (Pexp_ident(Lident(Longident.last lbl)))
-let pat_of_label lbl =
+let pat_of_label {li_desc = lbl} =
mkpat (Ppat_var(Longident.last lbl))
%}
@@ -1307,7 +1309,7 @@
with_constraint:
TYPE type_parameters label_longident with_type_binder core_type constraints
{ let params, variance = List.split $2 in
- ($3, Pwith_type {ptype_params = params;
+ ($3.li_desc, Pwith_type {ptype_params = params;
ptype_cstrs = List.rev $6;
ptype_kind = Ptype_abstract;
ptype_manifest = Some $5;
@@ -1318,7 +1320,7 @@
functor applications in type path */
| TYPE type_parameters label_longident COLONEQUAL core_type
{ let params, variance = List.split $2 in
- ($3, Pwith_typesubst {ptype_params = params;
+ ($3.li_desc, Pwith_typesubst {ptype_params = params;
ptype_cstrs = [];
ptype_kind = Ptype_abstract;
ptype_manifest = Some $5;
@@ -1566,8 +1568,8 @@
| TRUE { Lident "true" }
;
label_longident:
- LIDENT { Lident $1 }
- | mod_longident DOT LIDENT { Ldot($1, $3) }
+ LIDENT { mkli (Lident $1) }
+ | mod_longident DOT LIDENT { mkli (Ldot($1, $3)) }
;
type_longident:
LIDENT { Lident $1 }
Index: parsing/parsetree.mli
===================================================================
--- parsing/parsetree.mli (revision 10565)
+++ parsing/parsetree.mli (working copy)
@@ -18,6 +18,10 @@
(* Type expressions for the core language *)
+type longident =
+ { li_desc: Longident.t;
+ li_loc: Location.t }
+
type core_type =
{ ptyp_desc: core_type_desc;
ptyp_loc: Location.t }
@@ -73,7 +77,7 @@
| Ppat_tuple of pattern list
| Ppat_construct of Longident.t * pattern option * bool
| Ppat_variant of label * pattern option
- | Ppat_record of (Longident.t * pattern) list * closed_flag
+ | Ppat_record of (longident * pattern) list * closed_flag
| Ppat_array of pattern list
| Ppat_or of pattern * pattern
| Ppat_constraint of pattern * core_type
@@ -95,9 +99,9 @@
| Pexp_tuple of expression list
| Pexp_construct of Longident.t * expression option * bool
| Pexp_variant of label * expression option
- | Pexp_record of (Longident.t * expression) list * expression option
- | Pexp_field of expression * Longident.t
- | Pexp_setfield of expression * Longident.t * expression
+ | Pexp_record of (longident * expression) list * expression option
+ | Pexp_field of expression * longident
+ | Pexp_setfield of expression * longident * expression
| Pexp_array of expression list
| Pexp_ifthenelse of expression * expression * expression option
| Pexp_sequence of expression * expression
Index: parsing/printast.ml
===================================================================
--- parsing/printast.ml (revision 10565)
+++ parsing/printast.ml (working copy)
@@ -253,11 +253,11 @@
| Pexp_field (e, li) ->
line i ppf "Pexp_field\n";
expression i ppf e;
- longident i ppf li;
+ longident i ppf li.li_desc;
| Pexp_setfield (e1, li, e2) ->
line i ppf "Pexp_setfield\n";
expression i ppf e1;
- longident i ppf li;
+ longident i ppf li.li_desc;
expression i ppf e2;
| Pexp_array (l) ->
line i ppf "Pexp_array\n";
@@ -676,7 +676,7 @@
list (i+1) string ppf l;
and longident_x_pattern i ppf (li, p) =
- line i ppf "%a\n" fmt_longident li;
+ line i ppf "%a\n" fmt_longident li.li_desc;
pattern (i+1) ppf p;
and pattern_x_expression_case i ppf (p, e) =
@@ -694,7 +694,7 @@
expression (i+1) ppf e;
and longident_x_expression i ppf (li, e) =
- line i ppf "%a\n" fmt_longident li;
+ line i ppf "%a\n" fmt_longident li.li_desc;
expression (i+1) ppf e;
and label_x_expression i ppf (l,e) =
|