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

v.checker: use more concise error messages (remove please)

This commit is contained in:
Delyan Angelov 2021-05-08 21:25:39 +03:00
parent a9eb8931ed
commit 21f207e781
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 7 additions and 7 deletions

View File

@ -4261,7 +4261,7 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
node.pos)
}
if c.mod == 'main' {
c.error('hash statements are not allowed in the main module. Please place them in a separate module.',
c.error('hash statements are not allowed in the main module. Place them in a separate module.',
node.pos)
}
return
@ -4757,10 +4757,10 @@ pub fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
expr_is_ptr := node.expr_type.is_ptr() || n_e_t_idx in ast.pointer_type_idxs
if expr_is_ptr && to_type_sym.kind == .string && !node.in_prexpr {
if node.has_arg {
c.warn('to convert a C string buffer pointer to a V string, please use x.vstring_with_len(len) instead of string(x,len)',
c.warn('to convert a C string buffer pointer to a V string, use x.vstring_with_len(len) instead of string(x,len)',
node.pos)
} else {
c.warn('to convert a C string buffer pointer to a V string, please use x.vstring() instead of string(x)',
c.warn('to convert a C string buffer pointer to a V string, use x.vstring() instead of string(x)',
node.pos)
}
}
@ -6035,7 +6035,7 @@ fn (mut c Checker) comp_if_branch(cond ast.Expr, pos token.Position) bool {
}
} else if cond.name !in c.pref.compile_defines_all {
if cond.name == 'linux_or_macos' {
c.error('linux_or_macos is deprecated, please use `\$if linux || macos {` instead',
c.error('linux_or_macos is deprecated, use `\$if linux || macos {` instead',
cond.pos)
return false
}

View File

@ -1,11 +1,11 @@
vlib/v/checker/tests/warnings_for_string_c2v_calls.vv:8:7: error: to convert a C string buffer pointer to a V string, please use x.vstring() instead of string(x)
vlib/v/checker/tests/warnings_for_string_c2v_calls.vv:8:7: error: to convert a C string buffer pointer to a V string, use x.vstring() instead of string(x)
6 | p[2] = `z`
7 | }
8 | x := string(p)
| ~~~~~~~~~
9 | y := string(p, 10)
10 | eprintln('x: $x | y: $y')
vlib/v/checker/tests/warnings_for_string_c2v_calls.vv:9:7: error: to convert a C string buffer pointer to a V string, please use x.vstring_with_len(len) instead of string(x,len)
vlib/v/checker/tests/warnings_for_string_c2v_calls.vv:9:7: error: to convert a C string buffer pointer to a V string, use x.vstring_with_len(len) instead of string(x,len)
7 | }
8 | x := string(p)
9 | y := string(p, 10)