aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/compiler.rs8
-rw-r--r--src/error.rs2
-rw-r--r--tests/simple.tdy25
3 files changed, 8 insertions, 27 deletions
diff --git a/src/compiler.rs b/src/compiler.rs
index 83dca4a..3c5498e 100644
--- a/src/compiler.rs
+++ b/src/compiler.rs
@@ -1,4 +1,4 @@
-use std::path::{Path, PathBuf};
+use std::{borrow::Cow, path::{Path, PathBuf}};
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;
@@ -560,14 +560,14 @@ impl Compiler {
let top = self.stack().len() - 1;
let name = if !self.stack()[top].active {
self.stack_mut()[top].active = true;
- &self.stack()[top].name
+ Cow::Borrowed(&self.stack()[top].name)
} else {
- "anonumus function"
+ Cow::Owned(format!("λ {}@{:03}", self.current_file.display(), self.line()))
};
let mut args = Vec::new();
let mut return_type = Type::Void;
- let mut function_block = Block::new(name, &self.current_file, self.line());
+ let mut function_block = Block::new(&name, &self.current_file, self.line());
let _ret = push_frame!(self, function_block, {
loop {
diff --git a/src/error.rs b/src/error.rs
index 60eea3b..d8d4664 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -67,7 +67,7 @@ impl fmt::Display for Error {
let line = if let Ok(file) = File::open(&self.file) {
io::BufReader::new(file).lines().enumerate()
- .filter(|(n, _)| self.line-2 <= *n + 1 && *n + 1 <= self.line)
+ .filter(|(n, _)| self.line <= *n + 3 && *n + 3 <= self.line + 2)
.fold(String::from("\n"), |a, (n, l)| format!("{} {:3} | {}\n", a, (n + 1).blue(), l.unwrap()))
} else {
String::new()
diff --git a/tests/simple.tdy b/tests/simple.tdy
index 7ecac8b..4a0b7d1 100644
--- a/tests/simple.tdy
+++ b/tests/simple.tdy
@@ -1,24 +1,5 @@
-blob B {
- a: int
+a := fn f: fn -> {
+ f()
}
-blob A {
- a: int
- b: B
- c: float
-}
-
-hello : fn A -> = fn a: A {
- print a.a
- print a.b
- print a.b.a
- print a.c
-}
-
-a := A()
-a.a = 1
-a.b = B()
-a.b.a = 2
-a.c = 3.
-
-hello(a)
+a(fn { print 2 })