Skip to content

Commit 12e407f

Browse files
committed
fix functions and stuff inside packages or shi
1 parent 0dfb287 commit 12e407f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
import "test" as test
2+
import "basic_loops" as loops
23

3-
print(test.new_feature("abc"))
4+
print(test.new_feature("abc"))
5+
6+
loops.loop(print, 0, 5);

lang/examples/using_packages/project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[dependencies]
2+
basic_loops = "1.0.1"
23
test = "2.0.7"
34

45
[package]

lang/src/eval.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub fn eval(expr: AST, context: &mut HashMap<String, AST>) -> Result<AST, String
206206
}
207207

208208
AST::PropertyCall { object, property, args, line: _ } => {
209-
match object {
209+
match object.clone() {
210210
Some(name) => {
211211
match context.get(&name) {
212212
Some(value) => {
@@ -223,6 +223,12 @@ pub fn eval(expr: AST, context: &mut HashMap<String, AST>) -> Result<AST, String
223223
new_context.insert(arg.clone(), eval(args[i].clone(), &mut new_context.clone())?);
224224
}
225225

226+
new_context.remove(name);
227+
228+
for prop in properties {
229+
new_context.insert(prop.0.clone(), prop.1.clone());
230+
}
231+
226232
for expr in body {
227233
if let AST::Return { value, line: _ } = expr {
228234
return eval(*value.clone(), &mut new_context);

0 commit comments

Comments
 (0)