Skip to content

Commit 7fb5cbc

Browse files
committed
fix out of order printing/expressions
1 parent 4ecdd93 commit 7fb5cbc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/repl/repl.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ func (s *Session) separateEvalStmt(in string) error {
432432

433433
for _, line := range inLines {
434434

435-
if bracketCount == 0 {
435+
if bracketCount == 0 && len(stmtLines) == 0 {
436436
if _, err := s.evalExpr(line); err != nil {
437437
if strings.LastIndex(line, "{") == len(line)-1 {
438438
bracketCount++
@@ -443,6 +443,17 @@ func (s *Session) separateEvalStmt(in string) error {
443443
continue
444444
}
445445

446+
if bracketCount == 0 && len(stmtLines) > 0 {
447+
var noPrint bool
448+
if exprCount > 0 {
449+
noPrint = true
450+
}
451+
if err := s.evalStmt(strings.Join(stmtLines, "\n"), noPrint); err != nil {
452+
return err
453+
}
454+
stmtLines = []string{}
455+
}
456+
446457
if strings.LastIndex(line, "}") == len(line)-1 {
447458
bracketCount--
448459
}

0 commit comments

Comments
 (0)