mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Don't shadow unnecessarily
This commit is contained in:
parent
560c984d30
commit
afa88bfd41
1 changed files with 7 additions and 1 deletions
|
@ -130,9 +130,11 @@ impl ReplState {
|
|||
|
||||
pub fn eval_and_format(&mut self, src: &str) -> String {
|
||||
let arena = Bump::new();
|
||||
let pending_past_def;
|
||||
let mut opt_var_name;
|
||||
let src = match parse_src(&arena, src) {
|
||||
ParseOutcome::Expr(_) | ParseOutcome::Incomplete | ParseOutcome::SyntaxErr => {
|
||||
pending_past_def = None;
|
||||
// If it's a SyntaxErr (or Incomplete at this point, meaning it will
|
||||
// become a SyntaxErr as soon as we evaluate it),
|
||||
// proceed as normal and let the error reporting happen during eval.
|
||||
|
@ -171,7 +173,7 @@ impl ReplState {
|
|||
},
|
||||
..
|
||||
} => {
|
||||
self.add_past_def(ident.to_string(), src.to_string());
|
||||
pending_past_def = Some((ident.to_string(), src.to_string()));
|
||||
opt_var_name = Some(ident.to_string());
|
||||
|
||||
// Recreate the body of the def and then evaluate it as a lookup.
|
||||
|
@ -275,6 +277,10 @@ impl ReplState {
|
|||
}
|
||||
};
|
||||
|
||||
if let Some((ident, src)) = pending_past_def {
|
||||
self.add_past_def(ident.to_string(), src.to_string());
|
||||
}
|
||||
|
||||
format_output(output, problems, opt_var_name)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue