all: s.contains(s2) instead of `in`
parent
b5c286256c
commit
0c055a1ce9
|
@ -882,7 +882,7 @@ pub fn (s string) contains(substr string) bool {
|
||||||
// contains_any returns `true` if the string contains any chars in `chars`.
|
// contains_any returns `true` if the string contains any chars in `chars`.
|
||||||
pub fn (s string) contains_any(chars string) bool {
|
pub fn (s string) contains_any(chars string) bool {
|
||||||
for c in chars {
|
for c in chars {
|
||||||
if c.ascii_str() in s {
|
if s.contains(c.ascii_str()) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -780,6 +780,7 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type {
|
||||||
infix_expr.left_type = map_info.key_type
|
infix_expr.left_type = map_info.key_type
|
||||||
}
|
}
|
||||||
.string {
|
.string {
|
||||||
|
c.warn('use `str.contains(substr)` instead of `substr in str`', left_right_pos)
|
||||||
c.check_expected(left_type, right_type) or {
|
c.check_expected(left_type, right_type) or {
|
||||||
c.error('left operand to `$infix_expr.op` does not match: $err.msg',
|
c.error('left operand to `$infix_expr.op` does not match: $err.msg',
|
||||||
left_right_pos)
|
left_right_pos)
|
||||||
|
@ -4509,7 +4510,8 @@ pub fn (mut c Checker) ident(mut ident ast.Ident) table.Type {
|
||||||
}
|
}
|
||||||
if typ == table.error_type && c.expected_type == table.string_type
|
if typ == table.error_type && c.expected_type == table.string_type
|
||||||
&& !c.using_new_err_struct && !c.inside_selector_expr
|
&& !c.using_new_err_struct && !c.inside_selector_expr
|
||||||
&& !c.inside_println_arg && 'v.' !in c.file.mod.name && !c.is_builtin_mod {
|
&& !c.inside_println_arg && !c.file.mod.name.contains('v.')
|
||||||
|
&& !c.is_builtin_mod {
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <- TODO: remove; this prevents a failure in the `performance-regressions` CI job
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <- TODO: remove; this prevents a failure in the `performance-regressions` CI job
|
||||||
c.warn('string errors are deprecated; use `err.msg` instead',
|
c.warn('string errors are deprecated; use `err.msg` instead',
|
||||||
ident.pos)
|
ident.pos)
|
||||||
|
|
|
@ -162,7 +162,7 @@ pub fn gen(files []ast.File, table &table.Table, pref &pref.Preferences) string
|
||||||
mut module_built := ''
|
mut module_built := ''
|
||||||
if pref.build_mode == .build_module {
|
if pref.build_mode == .build_module {
|
||||||
for file in files {
|
for file in files {
|
||||||
if pref.path in file.path
|
if file.path.contains(pref.path)
|
||||||
&& file.mod.short_name == pref.path.all_after_last(os.path_separator).trim_right(os.path_separator) {
|
&& file.mod.short_name == pref.path.all_after_last(os.path_separator).trim_right(os.path_separator) {
|
||||||
module_built = file.mod.name
|
module_built = file.mod.name
|
||||||
break
|
break
|
||||||
|
|
|
@ -634,22 +634,19 @@ pub fn cc_from_string(cc_str string) CompilerType {
|
||||||
normalized_cc_array := normalized_cc.split('/')
|
normalized_cc_array := normalized_cc.split('/')
|
||||||
last_elem := normalized_cc_array.last()
|
last_elem := normalized_cc_array.last()
|
||||||
cc := last_elem.all_before('.')
|
cc := last_elem.all_before('.')
|
||||||
if '++' in cc {
|
if cc.contains('++') {
|
||||||
return .cplusplus
|
return .cplusplus
|
||||||
}
|
}
|
||||||
if 'tcc' in cc {
|
if cc.contains('tcc') || cc.contains('tinyc') {
|
||||||
return .tinyc
|
return .tinyc
|
||||||
}
|
}
|
||||||
if 'tinyc' in cc {
|
if cc.contains('clang') {
|
||||||
return .tinyc
|
|
||||||
}
|
|
||||||
if 'clang' in cc {
|
|
||||||
return .clang
|
return .clang
|
||||||
}
|
}
|
||||||
if 'mingw' in cc {
|
if cc.contains('mingw') {
|
||||||
return .mingw
|
return .mingw
|
||||||
}
|
}
|
||||||
if 'msvc' in cc {
|
if cc.contains('msvc') {
|
||||||
return .msvc
|
return .msvc
|
||||||
}
|
}
|
||||||
return .gcc
|
return .gcc
|
||||||
|
|
|
@ -972,7 +972,7 @@ pub fn (t &TypeSymbol) embed_name() string {
|
||||||
mut embed_name := t.name.split('.').last()
|
mut embed_name := t.name.split('.').last()
|
||||||
// remove generic part from name
|
// remove generic part from name
|
||||||
// Abc<int> => Abc
|
// Abc<int> => Abc
|
||||||
if '<' in embed_name {
|
if embed_name.contains('<') {
|
||||||
embed_name = embed_name.split('<')[0]
|
embed_name = embed_name.split('<')[0]
|
||||||
}
|
}
|
||||||
return embed_name
|
return embed_name
|
||||||
|
|
|
@ -61,7 +61,7 @@ pub fn mod_path_to_full_name(mod string, path string) ?string {
|
||||||
vmod_folders := ['vlib', '.vmodules', 'modules']
|
vmod_folders := ['vlib', '.vmodules', 'modules']
|
||||||
mut in_vmod_path := false
|
mut in_vmod_path := false
|
||||||
for vmod_folder in vmod_folders {
|
for vmod_folder in vmod_folders {
|
||||||
if vmod_folder + os.path_separator in path {
|
if path.contains(vmod_folder + os.path_separator) {
|
||||||
in_vmod_path = true
|
in_vmod_path = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn parse_request_line(s string) ?(http.Method, urllib.URL, http.Version) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_header(s string) ?(string, string) {
|
fn parse_header(s string) ?(string, string) {
|
||||||
if ':' !in s {
|
if !s.contains(':') {
|
||||||
return error('missing colon in header')
|
return error('missing colon in header')
|
||||||
}
|
}
|
||||||
words := s.split_nth(':', 2)
|
words := s.split_nth(':', 2)
|
||||||
|
|
Loading…
Reference in New Issue