feat: better builtins implementaion

get rid of circular references
This commit is contained in:
2025-05-17 18:31:36 +08:00
parent 8480e0891b
commit ff9afd0cc1
19 changed files with 191 additions and 244 deletions

View File

@@ -141,7 +141,7 @@ fn test_attrs() {
test_expr(
"{ a = 1; }",
attrs! {
symbol!("a") => thunk!()
symbol!("a") => int!(1)
},
);
test_expr("{ a = 1; }.a", int!(1));
@@ -149,18 +149,18 @@ fn test_attrs() {
test_expr(
"{ a = { a = 1; }; }.a",
attrs! {
symbol!("a") => thunk!()
symbol!("a") => int!(1)
},
);
test_expr("{ a.b = 1; }.a.b", int!(1));
test_expr(
"{ a.b = 1; a.c = 2; }",
attrs! { symbol!("a") => attrs!{ symbol!("b") => thunk!(), symbol!("c") => thunk!() } },
attrs! { symbol!("a") => attrs!{ symbol!("b") => int!(1), symbol!("c") => int!(2) } },
);
test_expr("{ a.b = 1; } ? a.b", boolean!(true));
test_expr(
"{ a.b = 1; } // { a.c = 2; }",
attrs! { symbol!("a") => attrs!{ symbol!("c") => thunk!() } },
attrs! { symbol!("a") => attrs!{ symbol!("c") => int!(2) } },
);
}
@@ -181,7 +181,7 @@ fn test_let() {
test_expr(r#"let a = { a = 1; }; b = "a"; in a.${b}"#, int!(1));
test_expr(
r#"let b = "c"; in { a.b = 1; } // { a."a${b}" = 2; }"#,
attrs! { symbol!("a") => attrs!{ symbol!("ac") => thunk!() } },
attrs! { symbol!("a") => attrs!{ symbol!("ac") => int!(2) } },
);
}