Skip to content

Commit e9a9526

Browse files
authored
Merge pull request #2498 from nickel-lang/closurize-overrides
Recursively closurize the overrides
2 parents 7336aed + 02076ae commit e9a9526

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# capture = 'stderr'
2+
# command = ['export']
3+
# extra_args = [
4+
# '--',
5+
# 'inputs.user="me"',
6+
# ]
7+
{
8+
inputs = {
9+
user | String | default = "defaultuser",
10+
},
11+
result = inputs.user,
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: cli/tests/snapshot/main.rs
3+
expression: err
4+
---
5+

core/src/term/make/builder.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ where
230230
let fst = it.next().unwrap();
231231

232232
let content = it.rev().fold(content, |acc, id| {
233-
record::Field::from(NickelValue::record_posless(RecordData {
234-
fields: [(LocIdent::from(id), acc)].into(),
235-
..Default::default()
236-
}))
233+
record::Field::from(NickelValue::term_posless(Term::Closurize(
234+
NickelValue::record_posless(RecordData {
235+
fields: [(LocIdent::from(id), acc)].into(),
236+
..Default::default()
237+
}),
238+
)))
237239
});
238240

239241
(fst.into(), content)
@@ -349,9 +351,8 @@ impl Record {
349351
/// # Closurization
350352
///
351353
/// [Self::build] is intended to provide a ready-to-use value, so the built record is wrapped
352-
/// into a [crate::term::Term::Closurize] operation. Otherwise, since records are assumed to be
353-
/// closurized during evaluation, using a bare record at runtime would either panic or
354-
/// introduce subtle bugs.
354+
/// into a [crate::term::Term::Closurize] operation, as are any sub-records implicitly created
355+
/// by field paths. However, field values are not automatically closurized.
355356
pub fn build(self) -> NickelValue {
356357
let elaborated = self
357358
.fields

0 commit comments

Comments
 (0)