camlspotter avatar camlspotter committed 8cd6965

first trial of warning for confusing indents

Comments (0)

Files changed (18)

 
 CAMLC=boot/ocamlrun boot/ocamlc -nostdlib -I boot
 CAMLOPT=boot/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink
-COMPFLAGS=-warn-error A $(INCLUDES) -annot
+COMPFLAGS=-warn-error Ai $(INCLUDES) -annot
 LINKFLAGS=
 
 CAMLYACC=boot/ocamlyacc

Binary file modified.

Binary file modified.

Binary file modified.

Binary file modified.

debugger/Makefile.shared

 include ../config/Makefile
 
 CAMLC=../ocamlcomp.sh
-COMPFLAGS=-warn-error A $(INCLUDES)
+COMPFLAGS=-warn-error Ai $(INCLUDES)
 LINKFLAGS=-linkall -I $(UNIXDIR)
 CAMLYACC=../boot/ocamlyacc
 YACCFLAGS=
 # The lexer generator
 CAMLC=../boot/ocamlrun ../boot/ocamlc -nostdlib -I ../boot
 CAMLOPT=../boot/ocamlrun ../ocamlopt -nostdlib -I ../stdlib
-COMPFLAGS=-warn-error A
+COMPFLAGS=-warn-error Ai
 CAMLYACC=../boot/ocamlyacc
 YACCFLAGS=-v
 CAMLLEX=../boot/ocamlrun ../boot/ocamllex
 
 flag ["ocaml"; "ocamlyacc"] (A"-v");;
 
-flag ["ocaml"; "compile"; "warn_Ale"] (S[A"-w";A"Ale"; A"-warn-error";A"Ale"]);;
-flag ["ocaml"; "compile"; "warn_Alezv"] (S[A"-w";A"Alezv"; A"-warn-error";A"Alezv"]);;
+flag ["ocaml"; "compile"; "warn_Alei"] (S[A"-w";A"Ale"; A"-warn-error";A"Ale"]);;
+flag ["ocaml"; "compile"; "warn_Alezvi"] (S[A"-w";A"Alezv"; A"-warn-error";A"Alezv"]);;
 
 non_dependency "otherlibs/threads/pervasives.ml" "Unix";;
 non_dependency "otherlibs/threads/pervasives.ml" "String";;
 # OCamlbuild tags file
 true: debug
-<*.ml> or <*.mli>: warn_A, warn_error_A, warn_e, annot
+<*.ml> or <*.mli>: warn_A, warn_error_Ai, warn_e, annot
 "discard_printf.ml": rectypes
 "ocamlbuildlib.cma" or "ocamlbuildlightlib.cma": linkall
 <*.byte> or <*.native> or <*.top>: use_unix

ocamlbuild/ocaml_specific.ml

   flag ["ocaml"; "compile"; sprintf "warn_error_%c" (Char.lowercase c)]
        (S[A"-warn-error"; A (sprintf "%c" (Char.lowercase c))]);;
 
-List.iter ocaml_warn_flag ['A'; 'C'; 'D'; 'E'; 'F'; 'L'; 'M'; 'P'; 'S'; 'U'; 'V'; 'Y'; 'Z'; 'X'];;
+List.iter ocaml_warn_flag ['A'; 'C'; 'D'; 'E'; 'F'; 'L'; 'M'; 'P'; 'S'; 'U'; 'V'; 'Y'; 'Z'; 'X'; 'I'];;
 
 flag ["ocaml"; "doc"; "docdir"; "extension:html"] (A"-html");;
 flag ["ocaml"; "doc"; "docdir"; "manpage"] (A"-man");;

ocamldoc/Makefile

 
 INCLUDES=$(INCLUDES_DEP) $(INCLUDES_NODEP)
 
-COMPFLAGS=$(INCLUDES) -warn-error A
+COMPFLAGS=$(INCLUDES) -warn-error Ai
 LINKFLAGS=$(INCLUDES) -nostdlib
 
 CMOFILES= odoc_config.cmo \

ocamlspot/tests/Makefile.targets

 exception.cmo \
 external.cmo \
 external_include.cmo \
-fstclassmodule.cmo \
 functor.cmo \
 functor_parameter.cmo \
 immediate_include.cmo \
 module_use.cmo \
 multiple_definition.cmo \
 object.cmo \
-ocaml312.cmo \
 open.cmo \
 open_in_mli.cmi \
 open_pack.cmo \

otherlibs/Makefile.shared

 # Compilation options
 CC=$(BYTECC)
 CAMLRUN=$(ROOTDIR)/boot/ocamlrun
-COMPFLAGS=-warn-error A -g $(EXTRACAMLFLAGS)
+COMPFLAGS=-warn-error Ai -g $(EXTRACAMLFLAGS)
 MKLIB=$(CAMLRUN) $(ROOTDIR)/tools/ocamlmklib
 
 # Variables to be defined by individual libraries:

stdlib/Makefile.shared

 RUNTIME=../boot/ocamlrun
 COMPILER=../ocamlc
 CAMLC=$(RUNTIME) $(COMPILER)
-COMPFLAGS=-g -warn-error A -nostdlib -annot
+COMPFLAGS=-g -warn-error Ai -nostdlib -annot
 OPTCOMPILER=../ocamlopt
 CAMLOPT=$(RUNTIME) $(OPTCOMPILER)
-OPTCOMPFLAGS=-warn-error A -nostdlib -g
+OPTCOMPFLAGS=-warn-error Ai -nostdlib -g
 CAMLDEP=../boot/ocamlrun ../tools/ocamldep
 
 OBJS=pervasives.cmo $(OTHERS)

tools/Makefile.shared

 CAMLLEX=$(CAMLRUN) ../boot/ocamllex
 INCLUDES=-I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp \
          -I ../driver
-COMPFLAGS= -warn-error A $(INCLUDES)
+COMPFLAGS= -warn-error Ai $(INCLUDES)
 LINKFLAGS=$(INCLUDES)
 
 all: ocamldep ocamlprof ocamlcp ocamlmktop ocamlmklib scrapelabels addlabels \

typing/typecore.ml

   node
 ;;
 
+(* Quick hack for confusing indents *)
+let check_pattern_indents pexp (pat_a_list : (Parsetree.pattern * 'a) list) =
+  match pat_a_list with
+  | [] -> ()
+  | (pat,_) :: pat_a_list ->
+      let bol_of_loc loc = 
+	let (_, _, pos) = Location.get_pos_info loc.Location.loc_start in
+	pos
+      in
+      let bol_start = bol_of_loc pat.ppat_loc in
+      List.iter (fun (pat,_) ->
+	(* CR jfuruse: TAB count failure *)
+	if bol_of_loc pat.ppat_loc < bol_start 
+	  && bol_of_loc pat.ppat_loc < bol_of_loc pexp.pexp_loc
+	then
+	  Location.prerr_warning pat.ppat_loc Warnings.Confusing_indent)
+	pat_a_list
+
+let check_if_indent pexp1 pexp2 =
+  match pexp1.pexp_desc with
+  | Pexp_ifthenelse (_, _, None) ->
+      let bol_of_loc loc = 
+	let (_, _, pos) = Location.get_pos_info loc.Location.loc_start in
+	pos
+      in
+      let bol_start = bol_of_loc pexp1.pexp_loc in
+      if bol_of_loc pexp2.pexp_loc > bol_start then
+	Location.prerr_warning pexp2.pexp_loc Warnings.Confusing_indent
+  | _ -> ()
 
 (* Typing of constants *)
 
         exp_type = ty_res;
         exp_env = env }
   | Pexp_match(sarg, caselist) ->
+      check_pattern_indents sexp caselist;
       let arg = type_exp env sarg in
       let ty_res = newvar() in
       let cases, partial =
             exp_env = env }
       end
   | Pexp_sequence(sexp1, sexp2) ->
+      check_if_indent sexp1 sexp2;
       let exp1 = type_statement env sexp1 in
       let exp2 = type_exp env sexp2 in
       re {
         exp_type = body.exp_type;
         exp_env = env }
   | Pexp_sequence(sexp1, sexp2) ->
+      check_if_indent sexp1 sexp2;
       let exp1 = type_statement env sexp1 in
       let exp2 = type_expect env sexp2 ty_expected in
       re {
       in
       type_expect ?in_function env sfun ty_expected
   | Pexp_function (l, _, caselist) ->
+      check_pattern_indents sexp caselist;
       let (loc, ty_fun) =
         match in_function with Some p -> p
         | None -> (sexp.pexp_loc, ty_expected)

utils/warnings.ml

   | Bad_module_name of string
   | Unused_var of string             (* Y *)
   | Unused_var_strict of string      (* Z *)
+  | Confusing_indent                 (* I *)
 ;;
 
 let letter = function        (* 'a' is all *)
   | All_clauses_guarded ->      'x'
   | Unused_var _ ->             'y'
   | Unused_var_strict _ ->      'z'
+  | Confusing_indent ->         'i'
 ;;
 
 let active = Array.create 27 true;;
        but no fields are borrowed from the original."
   | Bad_module_name (modname) ->
       "bad source file name: \"" ^ modname ^ "\" is not a valid module name."
+  | Confusing_indent ->
+      "confusing indent."
 ;;
 
 let nerrors = ref 0;;

utils/warnings.mli

   | Bad_module_name of string
   | Unused_var of string             (* Y *)
   | Unused_var_strict of string      (* Z *)
+  | Confusing_indent                 (* I *)
 ;;
 
 val parse_options : bool -> string -> unit;;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.