-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: disallow result callbacks functions like map/filter/all/any
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
vlib/v/checker/tests/map_result_callback_fn_err.vv:14:53: error: cannot use Result type in `map` calls without unwrapping or using an or block | ||
12 | | ||
13 | fn execsync(cmd cli.Command) ! { | ||
14 | dens := os.read_lines('/etc/fox/dens')!.map(urllib.parse(it)!) | ||
| ~~~~~~~~~ | ||
15 | mut threads := []thread !{} | ||
16 | for den in dens { | ||
vlib/v/checker/tests/map_result_callback_fn_err.vv:19:17: error: cannot use Result type in `map` | ||
17 | threads << spawn update(den) | ||
18 | } | ||
19 | threads.map(it.wait()!) | ||
| ~~~~~~~ | ||
20 | } | ||
21 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
import cli | ||
import net.urllib | ||
|
||
pub fn sync() cli.Command { | ||
return cli.Command{ | ||
name: 'sync' | ||
description: 'sync local dens from remote' | ||
execute: execsync | ||
} | ||
} | ||
|
||
fn execsync(cmd cli.Command) ! { | ||
dens := os.read_lines('/etc/fox/dens')!.map(urllib.parse(it)!) | ||
mut threads := []thread !{} | ||
for den in dens { | ||
threads << spawn update(den) | ||
} | ||
threads.map(it.wait()!) | ||
} | ||
|
||
fn update(den urllib.URL) ! { | ||
println(den.str()) | ||
return | ||
} |