Skip to content

Commit

Permalink
vrepl: fix method call (fix vlang#21788) (vlang#21792)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 authored Jul 3, 2024
1 parent 62e2b7f commit 8188f65
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cmd/tools/vrepl.v
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ fn run_repl(workdir string, vrepl_prefix string) int {
filter_line := r.line.replace(r.line.find_between("'", "'"), '').replace(r.line.find_between('"',
'"'), '')
mut is_statement := false
if filter_line.count('=') % 2 == 1
if func_call {
is_statement = true
} else if filter_line.count('=') % 2 == 1
&& (filter_line.count('!=') + filter_line.count('>=') + filter_line.count('<=')) == 0 {
is_statement = true
} else {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/slow_tests/repl/comptime_tmpl.repl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$tmpl('./tmpl/hello.txt')
print($tmpl('./tmpl/hello.txt'))
===output===
hello
2 changes: 1 addition & 1 deletion vlib/v/slow_tests/repl/fn_calls.repl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
math.sinf(50.0)
println(math.sinf(50.0))
println(1+math.sinf(50.0))
fn test() { println('foo') } fn test2(a int) { println(a) }
test()
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/slow_tests/repl/import_alias.repl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import encoding.hex as z
z.decode('AB09CD')!.hex()
print(z.decode('AB09CD')!.hex())
===output===
ab09cd
7 changes: 7 additions & 0 deletions vlib/v/slow_tests/repl/method_call.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mut values := [1, 2, 3]
values
values.pop()
values
===output===
[1, 2, 3]
[1, 2]

0 comments on commit 8188f65

Please sign in to comment.