Remove syntax for inlined record types.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/constructors_with_record5@15525 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
88fd20f565
commit
bae09b365d
|
@ -2001,13 +2001,6 @@ constr_longident:
|
|||
| FALSE { Lident "false" }
|
||||
| TRUE { Lident "true" }
|
||||
;
|
||||
constr_qual_longident:
|
||||
mod_longident %prec below_DOT { $1 }
|
||||
| mod_longident DOT LIDENT DOT UIDENT %prec below_DOT
|
||||
{ Ldot(Ldot($1, $3), $5) }
|
||||
| LIDENT DOT UIDENT %prec below_DOT
|
||||
{ Ldot(Lident $1, $3) }
|
||||
;
|
||||
label_longident:
|
||||
LIDENT { Lident $1 }
|
||||
| mod_longident DOT LIDENT { Ldot($1, $3) }
|
||||
|
@ -2015,7 +2008,6 @@ label_longident:
|
|||
type_longident:
|
||||
LIDENT { Lident $1 }
|
||||
| mod_ext_longident DOT LIDENT { Ldot($1, $3) }
|
||||
| BANG constr_qual_longident { $2 }
|
||||
;
|
||||
mod_longident:
|
||||
UIDENT { Lident $1 }
|
||||
|
|
|
@ -41,7 +41,7 @@ let free_vars ty =
|
|||
|
||||
let newgenconstr path tyl = newgenty (Tconstr (path, tyl, ref Mnil))
|
||||
|
||||
let constructor_args cd_args cd_res loc path rep =
|
||||
let constructor_args cd_args cd_res path rep =
|
||||
let tyl =
|
||||
match cd_args with
|
||||
| Cstr_tuple l -> l
|
||||
|
@ -102,7 +102,6 @@ let constructor_descrs ty_path decl cstrs =
|
|||
let name = Ident.name cd_id in
|
||||
let existentials, cstr_args, cstr_inlined =
|
||||
constructor_args cd_args cd_res
|
||||
cd_loc
|
||||
(Path.Pdot (ty_path, name, Path.nopos))
|
||||
(Record_inlined idx_nonconst)
|
||||
in
|
||||
|
@ -133,7 +132,6 @@ let extension_descr path_ext ext =
|
|||
in
|
||||
let existentials, cstr_args, cstr_inlined =
|
||||
constructor_args ext.ext_args ext.ext_ret_type
|
||||
ext.ext_loc
|
||||
path_ext Record_extension
|
||||
in
|
||||
{ cstr_name = Path.last path_ext;
|
||||
|
|
|
@ -52,9 +52,6 @@ type error =
|
|||
| Ill_typed_functor_application of Longident.t
|
||||
| Illegal_reference_to_recursive_module
|
||||
| Access_functor_as_structure of Longident.t
|
||||
| Not_a_variant_type of Longident.t
|
||||
| Not_an_inlined_record of Longident.t
|
||||
| Unbound_constructor_in_type of string * Longident.t
|
||||
|
||||
exception Error of Location.t * Env.t * error
|
||||
exception Error_forward of Location.error
|
||||
|
@ -285,60 +282,6 @@ let unbound_label_error env lid =
|
|||
narrow_unbound_lid_error env lid.loc lid.txt
|
||||
(fun lid -> Unbound_label lid)
|
||||
|
||||
let find_constructor_in_type env loc ty_id cstr_id =
|
||||
let err e = raise (Error (loc, env, e)) in
|
||||
let (ty_path, ty_decl) = find_type env loc ty_id in
|
||||
match ty_decl.type_kind with
|
||||
| Type_variant _ ->
|
||||
let (cstrs, _) =
|
||||
try Env.find_type_descrs ty_path env
|
||||
with Not_found -> assert false
|
||||
in
|
||||
begin try List.find (fun c -> c.cstr_name = cstr_id) cstrs
|
||||
with Not_found -> err (Unbound_constructor_in_type (cstr_id, ty_id))
|
||||
end
|
||||
| _ ->
|
||||
err (Not_a_variant_type ty_id)
|
||||
|
||||
let is_typ_lid lid =
|
||||
match (Longident.last lid).[0] with
|
||||
| 'a'..'z' | '_' -> true
|
||||
| _ -> false
|
||||
|
||||
let find_qual_constructor env loc lid =
|
||||
match lid with
|
||||
| Longident.Ldot (ty_id, cstr_id) when is_typ_lid ty_id ->
|
||||
find_constructor_in_type env loc ty_id cstr_id
|
||||
| _ -> find_constructor env loc lid
|
||||
|
||||
let find_type env loc lid =
|
||||
if is_typ_lid lid then
|
||||
find_type env loc lid
|
||||
else
|
||||
let cstr = find_qual_constructor env loc lid in
|
||||
if cstr.cstr_inlined = None then begin
|
||||
let full_name =
|
||||
match cstr with
|
||||
| {cstr_name;
|
||||
cstr_tag = Cstr_constant _ | Cstr_block _;
|
||||
cstr_res = {desc = Tconstr(p, _, _)} } ->
|
||||
Longident.Ldot (Ctype.lid_of_path p, cstr_name)
|
||||
| _ -> lid
|
||||
in
|
||||
raise (Error (loc, env, Not_an_inlined_record full_name));
|
||||
end;
|
||||
begin match cstr.cstr_args with
|
||||
| [{desc=Tconstr(path, _, _)}] ->
|
||||
let decl =
|
||||
try Env.find_type path env
|
||||
with Not_found ->
|
||||
assert false
|
||||
in
|
||||
(path, decl)
|
||||
| _ -> assert false
|
||||
end
|
||||
|
||||
|
||||
(* Support for first-class modules. *)
|
||||
|
||||
let transl_modtype_longident = ref (fun _ -> assert false)
|
||||
|
@ -1060,17 +1003,6 @@ let report_error env ppf = function
|
|||
fprintf ppf "Illegal recursive module reference"
|
||||
| Access_functor_as_structure lid ->
|
||||
fprintf ppf "The module %a is a functor, not a structure" longident lid
|
||||
| Not_a_variant_type lid ->
|
||||
fprintf ppf
|
||||
"The type %a is not a regular variant type"
|
||||
longident lid
|
||||
| Not_an_inlined_record lid ->
|
||||
fprintf ppf
|
||||
"The constructor %a does not have an inline record argument"
|
||||
longident lid
|
||||
| Unbound_constructor_in_type (c_lid, t_lid) ->
|
||||
fprintf ppf "Unbound constructor %s in type %a" c_lid
|
||||
longident t_lid
|
||||
|
||||
let () =
|
||||
Location.register_error_of_exn
|
||||
|
|
|
@ -64,9 +64,6 @@ type error =
|
|||
| Ill_typed_functor_application of Longident.t
|
||||
| Illegal_reference_to_recursive_module
|
||||
| Access_functor_as_structure of Longident.t
|
||||
| Not_a_variant_type of Longident.t
|
||||
| Not_an_inlined_record of Longident.t
|
||||
| Unbound_constructor_in_type of string * Longident.t
|
||||
|
||||
exception Error of Location.t * Env.t * error
|
||||
|
||||
|
|
Loading…
Reference in New Issue