8000 fix: Reverse the printed/parsed order of env bindings internally by wwared · Pull Request #425 · lurk-lab/lurk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Reverse the printed/parsed order of env bindings internally #425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/core/parser/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,12 @@ fn parse_env<F: Field>(
move |from: Span<'_>| {
let (i, _) = tag("{")(from)?;
let (i, _) = parse_space(i)?;
let (i, pairs) = separated_list0(
let (i, mut pairs) = separated_list0(
tag(","),
parse_env_pair(state.clone(), create_unknown_packages),
)(i)?;
// We want the last entry to be the most significant one, so reverse the internal representation
pairs.reverse();
let (upto, _) = tag("}")(i)?;
let pos = Pos::from_upto(from, upto);
Ok((upto, Syntax::Env(pos, pairs)))
Expand Down
9 changes: 7 additions & 2 deletions src/core/tests/eval_direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ test!(test_env_builtin3, "(env (list 'a 1 2))", |z| {
let val = z.intern_list([one, two]);
z.intern_env(a, val, empty_env)
});
test!(test_env_literal, "{ a: 1, b: 2 }", |z| {
test!(test_env_literal, "{ b: 2, a: 1 }", |z| {
let empty_env = z.intern_empty_env();
let b = z.intern_symbol_no_lang(&user_sym("b"));
let two = z.intern_u64(2);
Expand All @@ -377,7 +377,7 @@ test!(test_env_literal, "{ a: 1, b: 2 }", |z| {
z.intern_env(a, one, b_2)
});
test!(test_env_literal_empty, "{ }", |z| { z.intern_empty_env() });
test!(test_env_literal_add, "{ a: (+ 1 0), b: 2 }", |z| {
test!(test_env_literal_add, "{ b: 2, a: (+ 1 0) }", |z| {
let empty_env = z.intern_empty_env();
let b = z.intern_symbol_no_lang(&user_sym("b"));
let two = z.intern_u64(2);
Expand All @@ -399,6 +399,11 @@ test!(
test!(test_env_literal_err, "{ a: (1 1), b: 2 }", |_| {
ZPtr::err(EvalErr::ApplyNonFunc)
});
test!(
test_env_literal_ordering,
"(eval 'a { a: 1, b: 2, a: 3 })",
|z| z.intern_u64(3)
);
test!(
test_bind_builtin,
"(bind 'a (- 2 1) (current-env))",
Expand Down
1 change: 1 addition & 0 deletions src/core/zstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ impl<F: Field, C: Chipset<F>> ZStore<F, C> {
let pairs_str = self
.fetch_env(zptr)
.iter()
.rev()
.map(|(sym, val)| {
format!(
"{}: {}",
Expand Down
Loading
0