Skip to content

Commit 821aac7

Browse files
committedSep 20, 2016
errors from out of order var declarations
1 parent 7fb5cbc commit 821aac7

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed
 

‎internal/repl/repl.go

+12-14
Original file line numberDiff line numberDiff line change
@@ -433,36 +433,34 @@ func (s *Session) separateEvalStmt(in string) error {
433433
for _, line := range inLines {
434434

435435
if bracketCount == 0 && len(stmtLines) == 0 {
436-
if _, err := s.evalExpr(line); err != nil {
436+
_, err := s.evalExpr(line)
437+
if err != nil {
437438
if strings.LastIndex(line, "{") == len(line)-1 {
438439
bracketCount++
439440
}
440-
stmtLines = append(stmtLines, line)
441+
}
442+
if err == nil {
441443
continue
442444
}
443-
continue
444445
}
445446

447+
if strings.LastIndex(line, "}") == len(line)-1 {
448+
bracketCount--
449+
}
450+
stmtLines = append(stmtLines, line)
451+
446452
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 {
453+
if err := s.evalStmt(strings.Join(stmtLines, "\n"), true); err != nil {
452454
return err
453455
}
454456
stmtLines = []string{}
457+
continue
455458
}
456459

457-
if strings.LastIndex(line, "}") == len(line)-1 {
458-
bracketCount--
459-
}
460-
stmtLines = append(stmtLines, line)
461-
462460
exprCount++
463461
}
464462

465-
if len(stmtLines) != 0 {
463+
if len(stmtLines) > 0 {
466464
var noPrint bool
467465
if exprCount > 0 {
468466
noPrint = true

0 commit comments

Comments
 (0)
Please sign in to comment.