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

checker: do not allow copying any map lvalue (#8662)

This commit is contained in:
Nick Treleaven
2021-02-16 11:46:12 +00:00
committed by GitHub
parent 51c286df5a
commit 01aa09d515
6 changed files with 20 additions and 23 deletions

View File

@@ -256,7 +256,7 @@ fn (mut context Context) run() {
summary[k] = s
}
// merge current raw results to the previous ones
old_oms := context.results[icmd].oms
old_oms := context.results[icmd].oms.move()
mut new_oms := map[string][]int{}
for k, v in m {
if old_oms[k].len == 0 {
@@ -266,7 +266,7 @@ fn (mut context Context) run() {
new_oms[k] << v
}
}
context.results[icmd].oms = new_oms
context.results[icmd].oms = new_oms.move()
// println('')
}
}
@@ -276,7 +276,7 @@ fn (mut context Context) run() {
for k, v in context.results[icmd].oms {
new_full_summary[k] = new_aints(v, context.nmins, context.nmaxs)
}
context.results[icmd].summary = new_full_summary
context.results[icmd].summary = new_full_summary.move()
}
}

View File

@@ -35,13 +35,12 @@ fn (mut a App) collect_info() {
})
}
if os_kind == 'linux' {
info := a.cpu_info()
mut cpu_details := ''
if cpu_details == '' {
cpu_details = info['model name']
cpu_details = a.cpu_info('model name')
}
if cpu_details == '' {
cpu_details = info['hardware']
cpu_details = a.cpu_info('hardware')
}
if cpu_details == '' {
cpu_details = os.uname().machine
@@ -61,8 +60,7 @@ fn (mut a App) collect_info() {
})
if os_kind == 'linux' {
os_details = a.get_linux_os_name()
info := a.cpu_info()
if 'hypervisor' in info['flags'] {
if 'hypervisor' in a.cpu_info('flags') {
if 'microsoft' in wsl_check {
// WSL 2 is a Managed VM and Full Linux Kernel
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
@@ -233,16 +231,15 @@ fn (mut a App) get_linux_os_name() string {
return os_details
}
fn (mut a App) cpu_info() map[string]string {
fn (mut a App) cpu_info(key string) string {
if a.cached_cpuinfo.len > 0 {
return a.cached_cpuinfo
return a.cached_cpuinfo[key]
}
info := os.exec('cat /proc/cpuinfo') or {
return a.cached_cpuinfo
return a.cached_cpuinfo[key]
}
vals := a.parse(info.output, ':')
a.cached_cpuinfo = vals
return vals
a.cached_cpuinfo = a.parse(info.output, ':')
return a.cached_cpuinfo[key]
}
fn (mut a App) git_info() string {