vrepl: fix array_filter (#9104)
parent
2b9ffbda42
commit
2870a5a63a
|
@ -29,6 +29,7 @@ mut:
|
||||||
const is_stdin_a_pipe = (is_atty(0) == 0)
|
const is_stdin_a_pipe = (is_atty(0) == 0)
|
||||||
|
|
||||||
const vexe = os.getenv('VEXE')
|
const vexe = os.getenv('VEXE')
|
||||||
|
|
||||||
const vstartup = os.getenv('VSTARTUP')
|
const vstartup = os.getenv('VSTARTUP')
|
||||||
|
|
||||||
fn new_repl() Repl {
|
fn new_repl() Repl {
|
||||||
|
@ -118,7 +119,11 @@ fn run_repl(workdir string, vrepl_prefix string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if vstartup != '' {
|
if vstartup != '' {
|
||||||
result := repl_run_vfile(vstartup) or { os.Result{output: '$vstartup file not found'} }
|
result := repl_run_vfile(vstartup) or {
|
||||||
|
os.Result{
|
||||||
|
output: '$vstartup file not found'
|
||||||
|
}
|
||||||
|
}
|
||||||
print('\n')
|
print('\n')
|
||||||
print_output(result)
|
print_output(result)
|
||||||
}
|
}
|
||||||
|
@ -214,7 +219,6 @@ fn run_repl(workdir string, vrepl_prefix string) {
|
||||||
filter_line := r.line.replace(r.line.find_between("'", "'"), '').replace(r.line.find_between('"',
|
filter_line := r.line.replace(r.line.find_between("'", "'"), '').replace(r.line.find_between('"',
|
||||||
'"'), '')
|
'"'), '')
|
||||||
possible_statement_patterns := [
|
possible_statement_patterns := [
|
||||||
'=',
|
|
||||||
'++',
|
'++',
|
||||||
'--',
|
'--',
|
||||||
'<<',
|
'<<',
|
||||||
|
@ -229,7 +233,6 @@ fn run_repl(workdir string, vrepl_prefix string) {
|
||||||
'interface ',
|
'interface ',
|
||||||
'import ',
|
'import ',
|
||||||
'#include ',
|
'#include ',
|
||||||
':=',
|
|
||||||
'for ',
|
'for ',
|
||||||
'or ',
|
'or ',
|
||||||
'insert',
|
'insert',
|
||||||
|
@ -240,12 +243,16 @@ fn run_repl(workdir string, vrepl_prefix string) {
|
||||||
'trim',
|
'trim',
|
||||||
]
|
]
|
||||||
mut is_statement := false
|
mut is_statement := false
|
||||||
|
if filter_line.count('=') % 2 == 1 {
|
||||||
|
is_statement = true
|
||||||
|
} else {
|
||||||
for pattern in possible_statement_patterns {
|
for pattern in possible_statement_patterns {
|
||||||
if filter_line.contains(pattern) {
|
if filter_line.contains(pattern) {
|
||||||
is_statement = true
|
is_statement = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// NB: starting a line with 2 spaces escapes the println heuristic
|
// NB: starting a line with 2 spaces escapes the println heuristic
|
||||||
if oline.starts_with(' ') {
|
if oline.starts_with(' ') {
|
||||||
is_statement = true
|
is_statement = true
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
[1, 2, 3, 4].filter(it%2 == 0).map(it * 2)
|
||||||
|
===output===
|
||||||
|
[4, 8]
|
Loading…
Reference in New Issue