Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix PR#5865

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13161 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
commit c0b989faff1708f421bef21373eefe9d44a3099c 1 parent 8e00f7b
garrigue authored
View
1  Changes
@@ -72,6 +72,7 @@ Bug fixes:
- PR#5806: ensure that backtrace tests are always run (testsuite)
- PR#5810: error in switch printing when using -dclambda
- PR#5858: Assert failure during typing of class
+- PR#5865: assert failure when reporting undefined field label
OCaml 4.00.1:
-------------
View
3  testsuite/tests/typing-misc/records.ml
@@ -33,3 +33,6 @@ type foo = { x: int };;
let r : foo = { ZZZ.x = 2 };;
(ZZZ.X : int option);;
+
+(* PR#5865 *)
+let f (x : Complex.t) = x.Complex.z;;
View
4 testsuite/tests/typing-misc/records.ml.principal.reference
@@ -47,4 +47,8 @@ Error: Unbound module ZZZ
(ZZZ.X : int option);;
^^^^^
Error: Unbound module ZZZ
+# Characters 41-50:
+ let f (x : Complex.t) = x.Complex.z;;
+ ^^^^^^^^^
+Error: Unbound record field Complex.z
#
View
4 testsuite/tests/typing-misc/records.ml.reference
@@ -47,4 +47,8 @@ Error: Unbound module ZZZ
(ZZZ.X : int option);;
^^^^^
Error: Unbound module ZZZ
+# Characters 41-50:
+ let f (x : Complex.t) = x.Complex.z;;
+ ^^^^^^^^^
+Error: Unbound record field Complex.z
#
View
5 typing/typecore.ml
@@ -549,7 +549,7 @@ module NameChoice(Name : sig
val get_type: t -> type_expr
val get_descrs: Env.type_descriptions -> t list
val fold: (t -> 'a -> 'a) -> Longident.t option -> Env.t -> 'a -> 'a
- val unbound_name_error: Env.t -> Longident.t loc -> unit
+ val unbound_name_error: Env.t -> Longident.t loc -> 'a
end) = struct
open Name
@@ -599,7 +599,7 @@ end) = struct
match opath with
None ->
begin match lbls with
- [] -> unbound_name_error env lid; assert false
+ [] -> unbound_name_error env lid
| (lbl, use) :: rest ->
use ();
if is_ambiguous env lbl rest then
@@ -638,6 +638,7 @@ end) = struct
if not pr then warn_pr ();
lbl
with Not_found ->
+ if lbls = [] then unbound_name_error env lid else
let tp = (tpath0, expand_path env tpath) in
let tpl =
List.map
View
10 typing/typetexp.ml
@@ -61,13 +61,13 @@ let instance_list = Ctype.instance_list Env.empty
(* Narrowing unbound identifier errors. *)
-let rec narrow_unbound_lid_error env loc lid make_error =
+let rec narrow_unbound_lid_error : 'a. _ -> _ -> _ -> _ -> 'a =
+ fun env loc lid make_error ->
let check_module mlid =
try ignore (Env.lookup_module mlid env)
with Not_found ->
narrow_unbound_lid_error env loc mlid
- (fun env lid -> Unbound_module (env, lid));
- assert false
+ (fun env lid -> Unbound_module (env, lid))
in
begin match lid with
| Longident.Lident _ -> ()
@@ -86,9 +86,7 @@ let find_component lookup make_error env loc lid =
lookup (Longident.Lident s) Env.initial
| _ -> lookup lid env
with Not_found ->
- (narrow_unbound_lid_error env loc lid make_error
- : unit (* to avoid a warning *));
- assert false
+ narrow_unbound_lid_error env loc lid make_error
let find_type =
find_component Env.lookup_type
View
4 typing/typetexp.mli
@@ -99,8 +99,8 @@ val find_modtype:
val find_class_type:
Env.t -> Location.t -> Longident.t -> Path.t * Types.class_type_declaration
-val unbound_constructor_error: Env.t -> Longident.t Location.loc -> unit
-val unbound_label_error: Env.t -> Longident.t Location.loc -> unit
+val unbound_constructor_error: Env.t -> Longident.t Location.loc -> 'a
+val unbound_label_error: Env.t -> Longident.t Location.loc -> 'a
type cd
val spellcheck_simple:
Please sign in to comment.
Something went wrong with that request. Please try again.