mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Drop an unused Result
This commit is contained in:
parent
6fbafad3ff
commit
f11b2d21cb
2 changed files with 13 additions and 20 deletions
|
@ -11,7 +11,6 @@ use roc_load::{EntryPoint, MonomorphizedModule};
|
|||
use roc_mono::ir::OptLevel;
|
||||
use roc_mono::layout::Layout;
|
||||
use roc_parse::ast::Expr;
|
||||
use roc_parse::parser::SyntaxError;
|
||||
use roc_repl_eval::eval::jit_to_ast;
|
||||
use roc_repl_eval::gen::{compile_to_mono, format_answer, ReplOutput};
|
||||
use roc_repl_eval::{ReplApp, ReplAppMemory};
|
||||
|
@ -27,14 +26,14 @@ pub fn gen_and_eval_llvm<'a>(
|
|||
target: Triple,
|
||||
opt_level: OptLevel,
|
||||
val_name: String,
|
||||
) -> Result<ReplOutput, SyntaxError<'a>> {
|
||||
) -> ReplOutput {
|
||||
let arena = Bump::new();
|
||||
let target_info = TargetInfo::from(&target);
|
||||
|
||||
let mut loaded = match compile_to_mono(&arena, src, target_info, DEFAULT_PALETTE) {
|
||||
Ok(x) => x,
|
||||
Err(prob_strings) => {
|
||||
return Ok(ReplOutput::Problems(prob_strings));
|
||||
return ReplOutput::Problems(prob_strings);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -55,11 +54,11 @@ pub fn gen_and_eval_llvm<'a>(
|
|||
let (_, main_fn_layout) = match loaded.procedures.keys().find(|(s, _)| *s == main_fn_symbol) {
|
||||
Some(layout) => *layout,
|
||||
None => {
|
||||
return Ok(ReplOutput::NoProblems {
|
||||
return ReplOutput::NoProblems {
|
||||
expr: "<function>".to_string(),
|
||||
expr_type: expr_type_str,
|
||||
val_name,
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -82,7 +81,7 @@ pub fn gen_and_eval_llvm<'a>(
|
|||
target_info,
|
||||
);
|
||||
|
||||
Ok(format_answer(&arena, res_answer, expr_type_str, val_name))
|
||||
format_answer(&arena, res_answer, expr_type_str, val_name)
|
||||
}
|
||||
|
||||
struct CliApp {
|
||||
|
|
|
@ -5,8 +5,8 @@ use const_format::concatcp;
|
|||
use roc_mono::ir::OptLevel;
|
||||
use roc_parse::ast::{Expr, TypeDef, ValueDef};
|
||||
use roc_parse::expr::{parse_single_def, ExprParseOptions, SingleDef};
|
||||
use roc_parse::parser::Either;
|
||||
use roc_parse::parser::{EClosure, EExpr};
|
||||
use roc_parse::parser::{Either, SyntaxError};
|
||||
use roc_parse::state::State;
|
||||
use roc_repl_eval::gen::ReplOutput;
|
||||
use rustyline::highlight::{Highlighter, PromptInfo};
|
||||
|
@ -81,10 +81,7 @@ impl ReplState {
|
|||
|
||||
self.pending_src.clear();
|
||||
|
||||
self.eval_and_format(&src).map_err(|_| {
|
||||
// This seems to be unreachable in practice.
|
||||
unreachable!();
|
||||
})
|
||||
Ok(self.eval_and_format(&src))
|
||||
} else {
|
||||
// The previous line wasn't blank, but there's some pending source.
|
||||
// This could mean that, for example, you're writing a multiline `when`
|
||||
|
@ -101,9 +98,7 @@ impl ReplState {
|
|||
ParseOutcome::Expr(_)
|
||||
| ParseOutcome::ValueDef(_)
|
||||
| ParseOutcome::TypeDef(_)
|
||||
| ParseOutcome::Incomplete => self.eval_and_format(trim_line).map_err(|fail| {
|
||||
todo!("gracefully report parse error in repl: {:?}", fail);
|
||||
}),
|
||||
| ParseOutcome::Incomplete => Ok(self.eval_and_format(trim_line)),
|
||||
ParseOutcome::Help => {
|
||||
// TODO add link to repl tutorial(does not yet exist).
|
||||
Ok(format!("\n{}\n", TIPS))
|
||||
|
@ -112,7 +107,7 @@ impl ReplState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn eval_and_format<'a>(&mut self, src: &str) -> Result<String, SyntaxError<'a>> {
|
||||
pub fn eval_and_format<'a>(&mut self, src: &str) -> String {
|
||||
let src = if self.pending_src.is_empty() {
|
||||
src
|
||||
} else {
|
||||
|
@ -142,7 +137,7 @@ impl ReplState {
|
|||
self.pending_src.push('\n');
|
||||
|
||||
// Return without running eval or clearing pending_src.
|
||||
return Ok(String::new());
|
||||
return String::new();
|
||||
}
|
||||
ValueDef::Body(_loc_pattern, _loc_expr)
|
||||
| ValueDef::AnnotatedBody {
|
||||
|
@ -166,17 +161,16 @@ impl ReplState {
|
|||
ParseOutcome::Empty | ParseOutcome::Help | ParseOutcome::Exit => unreachable!(),
|
||||
};
|
||||
|
||||
let answer = gen_and_eval_llvm(
|
||||
let output = format_output(gen_and_eval_llvm(
|
||||
src,
|
||||
Triple::host(),
|
||||
OptLevel::Normal,
|
||||
"TODOval1".to_string(),
|
||||
)
|
||||
.map(format_output);
|
||||
));
|
||||
|
||||
self.pending_src.clear();
|
||||
|
||||
answer
|
||||
output
|
||||
}
|
||||
|
||||
/// Wrap the given expresssion in the appropriate past defs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue