1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: change IError msg and code to methods + fix vlib, add a deprecation notice for the old usages (#13041)

This commit is contained in:
Tim Basel
2022-02-11 14:52:33 +01:00
committed by GitHub
parent 61024d4b75
commit 9d0a5942ac
80 changed files with 493 additions and 324 deletions

View File

@@ -477,14 +477,14 @@ fn (c Checker) check_quoted_escapes(q ast.Quoted) ? {
c.check_unicode_escape(s.text[pos..pos + 11]) or {
st := s.state()
return error(@MOD + '.' + @STRUCT + '.' + @FN +
' escaped Unicode is invalid. $err.msg.capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
' escaped Unicode is invalid. $err.msg().capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
}
} else {
pos := s.state().pos
c.check_unicode_escape(s.text[pos..]) or {
st := s.state()
return error(@MOD + '.' + @STRUCT + '.' + @FN +
' escaped Unicode is invalid. $err.msg.capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
' escaped Unicode is invalid. $err.msg().capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
}
}
}

View File

@@ -47,7 +47,7 @@ pub fn (c Config) read_input() ?string {
if os.is_file(c.file_path) {
text = os.read_file(c.file_path) or {
return error(@MOD + '.' + @STRUCT + '.' + @FN +
' Could not read "$c.file_path": "$err.msg"')
' Could not read "$c.file_path": "$err.msg()"')
}
}
return text

View File

@@ -55,7 +55,7 @@ pub fn new_scanner(config Config) ?&Scanner {
if os.is_file(file_path) {
text = os.read_file(file_path) or {
return error(@MOD + '.' + @STRUCT + '.' + @FN +
' Could not read "$file_path": "$err.msg"')
' Could not read "$file_path": "$err.msg()"')
}
}
mut s := &Scanner{

View File

@@ -155,12 +155,12 @@ fn test_alexcrichton_toml_rs() ? {
v_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', v_toml_json_path]) or {
contents := os.read_file(v_toml_json_path) ?
panic(err.msg + '\n$contents')
panic(err.msg() + '\n$contents')
}
alexcrichton_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"',
alexcrichton_toml_json_path]) or {
contents := os.read_file(v_toml_json_path) ?
panic(err.msg + '\n$contents')
panic(err.msg() + '\n$contents')
}
assert alexcrichton_normalized_json == v_normalized_json
@@ -199,7 +199,7 @@ fn test_alexcrichton_toml_rs() ? {
assert false
} else {
if !hide_oks {
println(' $err.msg')
println(' $err.msg()')
}
assert true
}

View File

@@ -141,11 +141,11 @@ fn test_burnt_sushi_tomltest() ? {
v_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', v_toml_json_path]) or {
contents := os.read_file(v_toml_json_path) ?
panic(err.msg + '\n$contents')
panic(err.msg() + '\n$contents')
}
bs_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', bs_toml_json_path]) or {
contents := os.read_file(v_toml_json_path) ?
panic(err.msg + '\n$contents')
panic(err.msg() + '\n$contents')
}
assert bs_normalized_json == v_normalized_json
@@ -182,7 +182,7 @@ fn test_burnt_sushi_tomltest() ? {
assert false
} else {
if !hide_oks {
println(' $err.msg')
println(' $err.msg()')
}
assert true
}

View File

@@ -181,7 +181,7 @@ fn test_iarna_toml_spec_tests() ? {
// NOTE there's known errors with the python convertion method.
// For now we just ignore them as it's a broken tool - not a wrong test-case.
// Uncomment this print to see/check them.
// eprintln(err.msg + '\n$contents')
// eprintln(err.msg() + '\n$contents')
e++
println('ERR [${i + 1}/$valid_test_files.len] "$valid_test_file" EXCEPTION [$e/$valid_value_exceptions.len]...')
continue
@@ -208,12 +208,12 @@ fn test_iarna_toml_spec_tests() ? {
v_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', v_toml_json_path]) or {
contents := os.read_file(v_toml_json_path) ?
panic(err.msg + '\n$contents')
panic(err.msg() + '\n$contents')
}
cmd := [jq, '-S', '-f "$jq_normalize_path"', iarna_toml_json_path]
iarna_normalized_json := run(cmd) or {
contents := os.read_file(v_toml_json_path) ?
panic(err.msg + '\n$contents\n\ncmd: ${cmd.join(' ')}')
panic(err.msg() + '\n$contents\n\ncmd: ${cmd.join(' ')}')
}
assert iarna_normalized_json == v_normalized_json
@@ -250,7 +250,7 @@ fn test_iarna_toml_spec_tests() ? {
assert false
} else {
if !hide_oks {
println(' $err.msg')
println(' $err.msg()')
}
assert true
}

View File

@@ -37,13 +37,13 @@ fn test_toml_with_bom() {
// Re-cycle bad_toml_doc
mut bad_toml_doc := empty_toml_document
bad_toml_doc = toml.parse(toml_text_with_utf16_bom) or {
println(' $err.msg')
println(' $err.msg()')
assert true
empty_toml_document
}
bad_toml_doc = toml.parse(toml_text_with_utf32_bom) or {
println(' $err.msg')
println(' $err.msg()')
assert true
empty_toml_document
}