From 25beb7b3f438ef204fc40dbd90283eaa6aa686d5 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 30 Dec 2019 11:48:08 +0200 Subject: [PATCH] in errors, print array_ instead of [] in function names --- vlib/compiler/compile_errors.v | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/vlib/compiler/compile_errors.v b/vlib/compiler/compile_errors.v index e80154971e..0614a2c0cb 100644 --- a/vlib/compiler/compile_errors.v +++ b/vlib/compiler/compile_errors.v @@ -190,13 +190,20 @@ fn (p mut Parser) print_error_context() { } fn normalized_error(s string) string { - // Print `[]int` instead of `array_int` in errors - mut res := s.replace('array_', '[]').replace('__', '.') - .replace('Option_', '?').replace('main.', '').replace('ptr_', '&') - .replace('_dot_', '.') + mut res := s + if !res.contains('__') { + // `[]int` instead of `array_int` + res = res.replace('array_', '[]') + } + res = res.replace('__', '.') + res = res.replace('Option_', '?') + res = res.replace('main.', '') + res = res.replace('ptr_', '&') + res = res.replace('_dot_', '.') if res.contains('_V_MulRet_') { - res = res.replace('_V_MulRet_', '(').replace('_V_', ', ') - res = res[..res.len - 1] + ')"' + res = res.replace('_V_MulRet_', '(') + res = res.replace('_V_', ', ') + res = res[..res.len - 1] + ')"' //"// quote balance comment. do not remove } return res }