fmt: fix using rand.seed() when import rand and rand.seed (#14511)
parent
a5b98cb267
commit
f35f7fe997
|
@ -41,6 +41,7 @@ pub mut:
|
||||||
used_imports []string // to remove unused imports
|
used_imports []string // to remove unused imports
|
||||||
import_syms_used map[string]bool // to remove unused import symbols.
|
import_syms_used map[string]bool // to remove unused import symbols.
|
||||||
mod2alias map[string]string // for `import time as t`, will contain: 'time'=>'t'
|
mod2alias map[string]string // for `import time as t`, will contain: 'time'=>'t'
|
||||||
|
mod2syms map[string]string // import time { now } 'time.now'=>'now'
|
||||||
use_short_fn_args bool
|
use_short_fn_args bool
|
||||||
single_line_fields bool // should struct fields be on a single line
|
single_line_fields bool // should struct fields be on a single line
|
||||||
it_name string // the name to replace `it` with
|
it_name string // the name to replace `it` with
|
||||||
|
@ -82,6 +83,9 @@ pub fn (mut f Fmt) process_file_imports(file &ast.File) {
|
||||||
f.mod2alias['${imp.mod}.$sym.name'] = sym.name
|
f.mod2alias['${imp.mod}.$sym.name'] = sym.name
|
||||||
f.mod2alias['${imp.mod.all_after_last('.')}.$sym.name'] = sym.name
|
f.mod2alias['${imp.mod.all_after_last('.')}.$sym.name'] = sym.name
|
||||||
f.mod2alias[sym.name] = sym.name
|
f.mod2alias[sym.name] = sym.name
|
||||||
|
f.mod2syms['${imp.mod}.$sym.name'] = sym.name
|
||||||
|
f.mod2syms['${imp.mod.all_after_last('.')}.$sym.name'] = sym.name
|
||||||
|
f.mod2syms[sym.name] = sym.name
|
||||||
f.import_syms_used[sym.name] = false
|
f.import_syms_used[sym.name] = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,8 +212,8 @@ pub fn (mut f Fmt) short_module(name string) string {
|
||||||
if !name.contains('.') || name.starts_with('JS.') {
|
if !name.contains('.') || name.starts_with('JS.') {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
if name in f.mod2alias {
|
if name in f.mod2syms {
|
||||||
return f.mod2alias[name]
|
return f.mod2syms[name]
|
||||||
}
|
}
|
||||||
if name.ends_with('>') {
|
if name.ends_with('>') {
|
||||||
generic_levels := name.trim_string_right('>').split('<')
|
generic_levels := name.trim_string_right('>').split('<')
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import rand
|
||||||
|
import rand.seed
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
rand.seed(seed.time_seed_array(2))
|
||||||
|
}
|
Loading…
Reference in New Issue