in errors, print array_ instead of [] in function names

pull/3271/head
Delyan Angelov 2019-12-30 11:48:08 +02:00 committed by Alexander Medvednikov
parent cba6a6fdea
commit 25beb7b3f4
1 changed files with 13 additions and 6 deletions

View File

@ -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
}