Skip to content

Commit

Permalink
Merge pull request #1262 from rtfeldman/basile/defs-in-repl
Browse files Browse the repository at this point in the history
Accept defs in REPL
  • Loading branch information
rtfeldman committed May 2, 2021
2 parents 9748aa0 + b2e0314 commit 1e1c3f4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cli/src/repl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use const_format::concatcp;
use gen::{gen_and_eval, ReplOutput};
use roc_gen::llvm::build::OptLevel;
use roc_parse::parser::SyntaxError;
use roc_parse::parser::{EExpr, SyntaxError};
use rustyline::error::ReadlineError;
use rustyline::validate::{self, ValidationContext, ValidationResult, Validator};
use rustyline::Editor;
Expand Down Expand Up @@ -71,7 +71,15 @@ impl Validator for InputValidator {
if ctx.input().is_empty() {
Ok(ValidationResult::Incomplete)
} else {
Ok(ValidationResult::Valid(None))
let arena = bumpalo::Bump::new();
match roc_parse::test_helpers::parse_expr_with(&arena, ctx.input()) {
// Special case some syntax errors to allow for multi-line inputs
Err(SyntaxError::Expr(EExpr::DefMissingFinalExpr(_, _)))
| Err(SyntaxError::Expr(EExpr::DefMissingFinalExpr2(_, _, _))) => {
Ok(ValidationResult::Incomplete)
}
_ => Ok(ValidationResult::Valid(None)),
}
}
}
}
Expand Down

0 comments on commit 1e1c3f4

Please sign in to comment.