Skip to content

Commit f0dc42d

Browse files
timfennisclaude
andcommitted
Give each REPL input a unique source name (<repl:1>, <repl:2>, ...)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2bae9fe commit f0dc42d

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

ndc_bin/src/repl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ pub fn run() -> anyhow::Result<()> {
3434

3535
let mut interpreter = Interpreter::new();
3636
interpreter.configure(ndc_stdlib::register);
37-
loop {
37+
for command_nr in 1.. {
3838
match rl.readline("λ ") {
3939
Ok(line) => {
4040
// If we can't append the history we just ignore this
4141
let _ = rl.add_history_entry(line.as_str());
4242

4343
// Run the line we just read through the interpreter
44-
match interpreter.eval_named("<repl>", line.as_str()) {
44+
match interpreter.eval_named(format!("<repl:{command_nr}>"), line.as_str()) {
4545
Ok(value) => {
4646
let output = value.to_string();
4747
if !output.is_empty() {

ndc_interpreter/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ impl Interpreter {
107107
}
108108

109109
/// Execute source code with a custom source name for diagnostics.
110-
pub fn eval_named(&mut self, name: &str, input: &str) -> Result<Value, InterpreterError> {
110+
pub fn eval_named(
111+
&mut self,
112+
name: impl Into<String>,
113+
input: &str,
114+
) -> Result<Value, InterpreterError> {
111115
let source_id = self.source_db.add(name, input);
112116
let expressions = self.parse_and_analyse(input, source_id)?;
113117
self.interpret_vm(input, expressions.into_iter())

ndc_parser/src/expression.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ pub enum ForIteration {
140140
}
141141

142142
#[derive(Debug, Eq, PartialEq, Clone)]
143+
#[allow(clippy::large_enum_variant)]
143144
pub enum ForBody {
144145
Block(ExpressionLocation),
145146
List {

0 commit comments

Comments
 (0)