aboutsummaryrefslogtreecommitdiff
path: root/lib/syntax/dead_end.ml
diff options
context:
space:
mode:
authorChimrod <>2024-02-03 17:42:16 +0100
committerChimrod <>2024-02-08 14:16:41 +0100
commitd7a13b0e5d6e746993e67a291376bd79766e0ed1 (patch)
tree80c621cbdb97ce69fd666a4e8f90f4952d237027 /lib/syntax/dead_end.ml
parent6fd720c07e3e361932e01bfbdbe4637c8f610649 (diff)
Added a new check to ensure that every call to another location points to an existing one
Diffstat (limited to 'lib/syntax/dead_end.ml')
-rw-r--r--lib/syntax/dead_end.ml20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/syntax/dead_end.ml b/lib/syntax/dead_end.ml
index ddf7edb..c0dbc58 100644
--- a/lib/syntax/dead_end.ml
+++ b/lib/syntax/dead_end.ml
@@ -2,11 +2,13 @@ open StdLabels
let identifier = "dead_end"
let description = "Check for dead end in the code"
+let is_global = false
let active = ref false
type context = unit
let initialize = Fun.id
+let finalize () = []
module Expression = struct
type t = unit
@@ -21,7 +23,6 @@ module Expression = struct
end
module Instruction = struct
- type expression = Expression.t'
type cause = Missing_else | Unchecked_path
type state = {
@@ -51,7 +52,7 @@ module Instruction = struct
}
(** Call for an instruction like [GT] or [*CLR] *)
- let call : S.pos -> T.keywords -> expression list -> t =
+ let call : S.pos -> T.keywords -> Expression.t' list -> t =
fun pos f _ ->
ignore pos;
match f with
@@ -67,7 +68,7 @@ module Instruction = struct
let comment : S.pos -> t = fun _ -> default
(** Raw expression *)
- let expression : expression -> t = fun _ -> default
+ let expression : Expression.t' -> t = fun _ -> default
(** The content of a block is very linear, I only need to check the last element *)
let check_block : S.pos -> t list -> t =
@@ -83,8 +84,8 @@ module Instruction = struct
let if_ :
S.pos ->
- (expression, t) S.clause ->
- elifs:(expression, t) S.clause list ->
+ (Expression.t', t) S.clause ->
+ elifs:(Expression.t', t) S.clause list ->
else_:(S.pos * t list) option ->
t =
fun pos clause ~elifs ~else_ ->
@@ -132,27 +133,26 @@ module Instruction = struct
{ default with block_pos = pos; pos = Some (cause, pos) })
| _, _ -> { default with block_pos = pos; has_gt; is_gt })
- let act : S.pos -> label:expression -> t list -> t =
+ let act : S.pos -> label:Expression.t' -> t list -> t =
fun pos ~label expressions ->
ignore label;
check_block pos expressions
let assign :
S.pos ->
- (S.pos, expression) S.variable ->
+ (S.pos, Expression.t') S.variable ->
T.assignation_operator ->
- expression ->
+ Expression.t' ->
t =
fun _ _ _ _ -> default
end
module Location = struct
type t = Report.t list
- type instruction = Instruction.t'
let v = Fun.id
- let location : unit -> S.pos -> instruction list -> t =
+ let location : unit -> S.pos -> Instruction.t' list -> t =
fun () _pos instructions ->
List.fold_left instructions ~init:[] ~f:(fun report t ->
match (t.Instruction.is_gt, t.Instruction.pos) with