From d7a13b0e5d6e746993e67a291376bd79766e0ed1 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Sat, 3 Feb 2024 17:42:16 +0100 Subject: Added a new check to ensure that every call to another location points to an existing one --- lib/syntax/dead_end.ml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/syntax/dead_end.ml') 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 -- cgit v1.2.3