From 330d2ab35190ebfc7db3c1ee321f7abe9d574628 Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Wed, 8 Jan 2020 23:47:37 +0100 Subject: [PATCH] Forgot to commit this. --- src/passes/1-parser/pascaligo.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/passes/1-parser/pascaligo.ml b/src/passes/1-parser/pascaligo.ml index 7218acfa4..5431c00a5 100644 --- a/src/passes/1-parser/pascaligo.ml +++ b/src/passes/1-parser/pascaligo.ml @@ -28,6 +28,15 @@ module Errors = struct ] in error ~data title message + let non_linear_pattern Region.{value; region} = + let title () = Printf.sprintf "repeated variable \"%s\" in this pattern" value in + let message () = "" in + let data = [ + ("location", + fun () -> Format.asprintf "%a" Location.pp_lift @@ region) + ] in + error ~data title message + let duplicate_parameter Region.{value; region} = let title () = Printf.sprintf "duplicate parameter \"%s\"" value in let message () = "" in @@ -111,7 +120,9 @@ let parse (parser: 'a parser) source lexbuf = try ok (parser read lexbuf) with - SyntaxError.Error (Duplicate_parameter name) -> + SyntaxError.Error (Non_linear_pattern var) -> + fail @@ (non_linear_pattern var) + | SyntaxError.Error (Duplicate_parameter name) -> fail @@ (duplicate_parameter name) | SyntaxError.Error (Duplicate_variant name) -> fail @@ (duplicate_variant name)