Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
5f32a36
refactor(wip): migrate term to NickelValue
yannham Jul 1, 2025
db35246
refactor(wip): migrate eval to NickelValue
yannham Jul 2, 2025
8505235
chore: rename Closure::body to value
yannham Jul 2, 2025
361cac0
chore: formatting
yannham Jul 3, 2025
e4c8e2f
refactor(wip): migrate eval to NickelValue (continued)
yannham Jul 8, 2025
079ab7c
refactor(wip): migrate to term to NickelValue (continued)
yannham Jul 8, 2025
a1aeb6c
feat: add lazy value lenses
yannham Jul 23, 2025
4f15708
refactor(wip): various migrations to NickelValue
yannham Jul 23, 2025
dc9b57b
feat: add lenses for term
yannham Jul 25, 2025
9089fee
refactor(wip): migrate transform to NickelValue (continued)
yannham Jul 25, 2025
6de2a63
refactor(wip): migrate misc modules to NickelValue
yannham Jul 25, 2025
1663f0b
refactor(wip): fix transform after migration
yannham Aug 26, 2025
e40f15d
refactor(wip): migrate cache to NickelValue
yannham Aug 26, 2025
33f94d4
chore: renamings and comment rewordings
yannham Aug 26, 2025
ff81900
refactor(wip): migrate closurize to NickelValue
yannham Aug 26, 2025
265bacc
refactor(wip): migrate eval::cache to NickelValue (continued)
yannham Aug 28, 2025
65acf28
chore: add (Partial)Eq impl for NickelValue
yannham Aug 28, 2025
b2d50f3
refactor(wip): migrate contract_eq to NickelValue
yannham Aug 28, 2025
07fde5b
refactor(wip): migrate eval::stack to NickelValue
yannham Aug 28, 2025
6d3b9d5
chore: update comment, code formatting
yannham Aug 28, 2025
eb524d1
chore: add missing constructors to NickelValue
yannham Aug 28, 2025
b060c7b
refactor(wip): migrate typ to NickelValue
yannham Aug 28, 2025
7ba9a78
refactor(wip): migrate pretty to NickelValue
yannham Aug 29, 2025
71309e5
chore: formatting
yannham Aug 29, 2025
8cf51f5
chore: partial fix of a bunch of compiler errors
yannham Sep 4, 2025
9f8badf
refactor(wip): serialization of NickelValue
yannham Sep 4, 2025
2b65391
refactor(wip): serialization of NickelValue (continued)
yannham Sep 4, 2025
60270bd
refactor: remove serde/deser concern from Term
yannham Sep 4, 2025
6c24c47
refactor(wip): upgrade deserialize to NickelValue
yannham Sep 4, 2025
10be0a0
chore: fix typo in function description
yannham Sep 8, 2025
9406cbb
chore: add Display impl for NickelValue
yannham Sep 8, 2025
627edc4
chore: derive (Partial)Eq for PosTable
yannham Sep 8, 2025
504f6a6
refactor(wip): migrate error to NickelValue
yannham Sep 8, 2025
163a31a
chore: switch to 2024 edition to get let-chains
yannham Sep 9, 2025
cb426d0
feat: add a few missing helpers to NickelValue
yannham Sep 9, 2025
8d7146b
refactor(wip): migrate callstack to NickelValue
yannham Sep 9, 2025
6dcd69b
refactor: add polarity <-> NickelValue conversion
yannham Sep 9, 2025
d63d044
chore: derive clone for PosTable
yannham Sep 9, 2025
aca3acd
refactor(wip): update error after other migrations
yannham Sep 9, 2025
af1e976
refactor(wip): adapt error types after migration
yannham Sep 9, 2025
81a4a92
feat: add helper to add context to eval errors
yannham Sep 9, 2025
8fc2e8c
refactor(wip): migrate primop eval to NickelValue
yannham Sep 9, 2025
0db031d
feat: add NickelValue::record_force_pos constructor
yannham Sep 10, 2025
bfc277b
chore: renamings in error to match eval::operation
yannham Sep 10, 2025
4b0a828
feat: helpers to convert pos indices to inherited
yannham Sep 10, 2025
daf3930
chore: into_iter_without_opts -> iter_without_opts
yannham Sep 10, 2025
027a8d8
refactor(wip): migrate primop eval to NickelValue (continued)
yannham Sep 10, 2025
da47bb6
feat: add missing mehods as_xxx() to NickelValue
yannham Sep 11, 2025
984ed9a
feat: add PosIdx::make_inline
yannham Sep 11, 2025
225425f
refactor(wip): migrate primop eval to NickelValue (continued)
yannham Sep 11, 2025
17c7b9b
refactor(wip): migrate primop eval to NickelValue (continued)
yannham Sep 12, 2025
55b89a4
refactor: don't include error context in Term
yannham Sep 15, 2025
f08eac4
feat: allow empty containers in an allocated block
yannham Sep 15, 2025
17fec4b
refactor(wip): migrate primop eval to NickelValue (continued)
yannham Sep 15, 2025
c36a093
refactor: remove leftover of callstack in error
yannham Sep 16, 2025
9fbbefb
feat: add mutating setters to Label
yannham Sep 16, 2025
d8b0f4a
refactor(wip): migrate primop eval to NickelValue (continued)
yannham Sep 16, 2025
f32cf91
refactor: migrate primop eval to NickelValue (end)
yannham Sep 17, 2025
9bd6e7a
chore: revert accidental copy-paste in comment
yannham Sep 17, 2025
9bf3383
fix: fix error type in RuntimeError term lens
yannham Sep 17, 2025
b50e2cf
refactor: use PosIdx in infinite recursion error
yannham Sep 17, 2025
a075fea
refactor(wip): migrate eval to NickelValue (continued)
yannham Sep 17, 2025
2f123f0
fix: EvalError/EvalErrorData change in typ
yannham Sep 18, 2025
1842b83
refactor(wip): migrate eval to NickelValue (continued)
yannham Sep 18, 2025
7db4719
feat: add take() to ValueContent
yannham Sep 18, 2025
98d5557
chore: derive Clone for EvalErrorData
yannham Sep 18, 2025
aabaae1
refactor: migrate eval to NickelValue (end)
yannham Sep 18, 2025
6199a55
feat: add NickelValue::typ constructor
yannham Sep 19, 2025
4f6f5e7
refactor: migrate fixpoint to NickelValue
yannham Sep 19, 2025
8d3397e
refactor: simplify EvalError flow in the VM
yannham Sep 19, 2025
395210e
chore: implement Traverse for NickelValue
yannham Sep 19, 2025
298d659
refactorm: migrate ast::compat to NickelValue
yannham Sep 22, 2025
012be9e
refactor: migrate merge to NickelValue
yannham Sep 23, 2025
0d4649f
chore: consistent order of parameters
yannham Sep 23, 2025
4911c30
refactor: use NickelValue::string
yannham Sep 23, 2025
35858d1
refactor(wip): thread pos table in repl & cache
yannham Sep 23, 2025
cb96fea
fix: post-rebase fixups
yannham Sep 24, 2025
6d04324
fix: misc compiler errors after rebasing
yannham Oct 3, 2025
7d4b80a
fix: fix more compile errors in eval::operation
yannham Oct 6, 2025
1f4db54
refactor(wip): migrate program to NickelValue
yannham Oct 6, 2025
18f563f
fix: misc compiler errors
yannham Oct 7, 2025
8fd89c6
fix: more compiler errors
yannham Oct 7, 2025
5f847b5
chore: post-rebase fixup (eval::mod, eval::ops)
yannham Oct 14, 2025
05a4f4e
chore: fix compilation errors in core
yannham Oct 14, 2025
050767d
[wip] migrate cli to NickelValue
yannham Oct 14, 2025
be807f1
refactor: migrate [tests, lsp, cli] to NickelValue
yannham Oct 15, 2025
05c8dbf
chore: implement missing todo!() in NickelValue
yannham Oct 17, 2025
5e6059b
fix: fix UB (double free) in lenses
yannham Oct 17, 2025
472391a
fix: implement missing todo!() in closurize
yannham Oct 17, 2025
c2236ae
fix: fix env_add_term for NickelValue, remove dead code
yannham Oct 17, 2025
507b62b
fix: fix closurization of recursive records
yannham Oct 17, 2025
cfaaf21
fix: fix broken to_nickel_string() after migration
yannham Oct 17, 2025
fc43d36
fix: broken type_of and type_tag after NickelValue migration
yannham Oct 17, 2025
d563c64
fixup! fix: fix closurization of recursive records
yannham Oct 20, 2025
74ae60f
fix: implement missing todo!() in eval::ops
yannham Oct 20, 2025
c640d13
fix: swap in %deserialize% arg type checking
yannham Oct 20, 2025
ed5493e
chore: more readable version of typeof
yannham Oct 20, 2025
345422f
fix: missing todo: ExportError with PosTable
yannham Oct 20, 2025
682da72
fix: relax closurization constraints (due to serialization)
yannham Oct 20, 2025
0872bbc
fix: restore full position of functions
yannham Oct 20, 2025
3e05641
fixup! fix: missing todo: ExportError with PosTable
yannham Oct 20, 2025
c92bcb6
fix: missing PartialEq instance on NickelValue
yannham Oct 20, 2025
e6b6541
[WIP] better empty container interface
yannham Oct 20, 2025
0908be5
chore: better Debug impl for NickelValue
yannham Oct 23, 2025
0ff289c
chore: fix using wrong position setter + fix warning
yannham Oct 23, 2025
6839614
chore: fix parser tests to match Ast->NickelValue conversion
yannham Oct 23, 2025
784e673
fix: fix serialize tests by propagating vm context
yannham Oct 23, 2025
6f2fd5d
fix: missing closurization in piecewise def elaboration
yannham Oct 23, 2025
f8835cb
chore[to_remove_finally]: debug print for unclosurized non-constant i…
yannham Oct 23, 2025
2325a47
fix: overstrict comparison of empty records
yannham Oct 24, 2025
4607689
fix: is_variant should return false on enum tags
yannham Oct 24, 2025
48687a9
refactor: no more inline/block pos idx distinction
yannham Oct 24, 2025
407d526
refactor: split wildcards in cache (AST-like vs Term-like)
yannham Oct 27, 2025
b8fefcd
chore: use enum_tag(_) instead of enum_variant(_, None)
yannham Oct 27, 2025
130bffb
fix: polymorphic tail contract now that == is stricter
yannham Oct 27, 2025
94fcb5e
fix: unclosurized record produced by pat compilation
yannham Oct 27, 2025
c52bcb8
chore: print more info in Debug impl for NickelValue
yannham Oct 27, 2025
f5e93a6
chore: do not copy whole record upon %force%
yannham Oct 27, 2025
10c9ebc
fix: outdated Rust test snippet in builder
yannham Oct 27, 2025
54008de
fix: missing %force% after deser in test
yannham Oct 27, 2025
6c2cd07
chore: commit legit changes in snapshot tests
yannham Oct 28, 2025
8c9f4e4
fix: set proper pos for result of %merge_contract% on empty record
yannham Oct 28, 2025
c8bfee0
chore: local variable renaming, less clutter
yannham Oct 28, 2025
47fc55d
fix: bad propagation of arg pos for num/str bin ops
yannham Oct 28, 2025
4fb28e2
fix: propagation of the wrong positions in main eval loop
yannham Oct 29, 2025
459f765
fix: properly closurize records in the term builder
yannham Oct 29, 2025
bd81307
chore: add helpers on Container, rename Container::get_field for cons…
yannham Oct 29, 2025
bfb36a3
[wip] migrate nickel/C API to NickelValue & cos
yannham Oct 29, 2025
ed350a1
WIP: no more body
yannham Oct 29, 2025
35f1165
refactor: get rid of XXXBody wrapper. Rename Body->Data
yannham Oct 30, 2025
dd9ef3c
fixup! [wip] migrate nickel/C API to NickelValue & cos
yannham Oct 30, 2025
6ab84fe
chore: apply clippy --fix, remove dead code
yannham Oct 30, 2025
e92906b
chore: fix remaining clippy warning manually
yannham Oct 30, 2025
8fb61d8
chore: fix rustdoc warnings
yannham Oct 30, 2025
001bc9d
refactor: move bytecode::value to eval::value
yannham Oct 30, 2025
6e7c6f8
fix: recession when deep-sequing empty containers
yannham Oct 30, 2025
e10dd14
fix: post-rebase fixup of cache & LSP
yannham Oct 31, 2025
2faa55c
chore: get rid of RichTerm mentions in comments
yannham Oct 31, 2025
a7ee4c3
chore: remove accidentally tracked files
yannham Oct 31, 2025
2fe2477
fix: compiler errors when enabling all features
yannham Oct 31, 2025
eb60377
chore: revert enabling C API by default (testing)
yannham Oct 31, 2025
2b185bd
fix: compiler error with all feats enabled
yannham Oct 31, 2025
56eab60
fix: LSP broken test, threading the wrong pos table
yannham Oct 31, 2025
7e35e2a
fix: missing closurization in some primop results
yannham Oct 31, 2025
5d767c0
chore: fix warning in stdlib tests, update doc of blame
yannham Oct 31, 2025
f89826f
fix: restore previous behavior of == on empty optionals
yannham Oct 31, 2025
70c0434
fix: update snapshot after stdlib additions
yannham Oct 31, 2025
1532422
chore: remove dead, commented out code
yannham Oct 31, 2025
d7ef48f
chore: improve NickelValue Debug impl (review suggestion)
yannham Nov 3, 2025
144c204
chore: remove redundant code (review suggestion)
yannham Nov 3, 2025
b93c840
chore: use Default instead of manual init
yannham Nov 3, 2025
fffc273
chore: update out-of-date description of method
yannham Nov 3, 2025
e5e4f1a
fix: truncated comment (review suggestion)
yannham Nov 3, 2025
d295065
refactor: is_empty_xxx -> is_inline_empty_xxx (review suggestion)
yannham Nov 3, 2025
a4a082c
fix: out-of-date comment (review suggestion)
yannham Nov 3, 2025
0370386
Update core/src/eval/value/mod.rs
yannham Nov 3, 2025
d4aa759
chore: fix typo in comment
yannham Nov 3, 2025
8733488
chore: fix typo in comment
yannham Nov 3, 2025
c4d37a8
chore: use unwrap_or_alloc instead of special case
yannham Nov 3, 2025
451e00e
fix: typo in comment
yannham Nov 4, 2025
4cbb544
fix: typo in comment
yannham Nov 4, 2025
c00d1fc
chore: use PosIdx instead of TermPos in import resolution
yannham Nov 4, 2025
186361c
chore: remove obsolete comment
yannham Nov 4, 2025
7a79e3c
fix: wrong catch-all case and other errors in should_share
yannham Nov 4, 2025
8577724
fix: typo in comment
yannham Nov 4, 2025
c1be918
chore: remove duplicated comment
yannham Nov 4, 2025
98edbf8
chore: remove obsolete comment
yannham Nov 4, 2025
7784939
chore: fix typo in comment
yannham Nov 4, 2025
df29371
chore: Str -> String in deserialize error messages
yannham Nov 4, 2025
fcf2d03
chore: remove commented out dead code
yannham Nov 4, 2025
2d09ae9
chore: move impls to the right module
yannham Nov 4, 2025
579b79f
fix: typo in comment
yannham Nov 4, 2025
f9629ed
chore: remove commented out dead code
yannham Nov 4, 2025
a4189ab
fix: typo in comment
yannham Nov 4, 2025
eac815d
chore: Context::to_xxx -> Context::expr_to_xxx
yannham Nov 4, 2025
e8ff3d0
chore: remove trailing spaces in comment
yannham Nov 4, 2025
a581867
fix: typo in comment
yannham Nov 4, 2025
265343e
fix: do not share environment between bench runs
yannham Nov 4, 2025
58f4bf9
chore: formatting (ed 2024)
yannham Nov 4, 2025
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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resolver = "2"
version = "1.14.0"
authors = ["The Nickel Team <[email protected]>"]
license = "MIT"
edition = "2021"
edition = "2024"
rust-version = "1.85"
keywords = ["configuration", "language", "nix", "nickel"]
repository = "https://github.com/tweag/nickel"
Expand Down Expand Up @@ -136,6 +136,8 @@ arbtest = "0.3"
rpds = "1.1.0"
imbl-sized-chunks = "0.1"

paste = "1.0"

[profile.dev.package.lalrpop]
opt-level = 3

Expand Down
55 changes: 29 additions & 26 deletions cli/src/customize/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
//! customize mode of the command-line.
use super::*;

use nickel_lang_core::eval::value::{Container, NickelValue};

/// The interface of a configuration (a Nickel program) which represents all nested field paths
/// that are accessible from the root term together with their associated metadata.
///
/// Interface is used to derive a command-line interface from a configuration when using the
/// `customize_mode` option.
#[derive(Debug, Clone, Default)]
pub(super) struct TermInterface {
pub(super) struct ValueInterface {
pub(super) fields: HashMap<LocIdent, FieldInterface>,
}

/// The interface of a specific field. This field can be itself a record and contain subfields.
#[derive(Debug, Clone, Default)]
pub(super) struct FieldInterface {
/// The interface of the subfields of this field, if it's a record itself.
pub(super) subfields: Option<TermInterface>,
pub(super) subfields: Option<ValueInterface>,
pub(super) field: Field,
}

impl Combine for TermInterface {
impl Combine for ValueInterface {
fn combine(first: Self, second: Self) -> Self {
let TermInterface { mut fields } = first;
let ValueInterface { mut fields } = first;

for (id, field) in second.fields.into_iter() {
if let Some(prev) = fields.remove(&id) {
Expand All @@ -32,7 +34,7 @@ impl Combine for TermInterface {
}
}

TermInterface { fields }
ValueInterface { fields }
}
}

Expand All @@ -52,9 +54,9 @@ impl Combine for FieldInterface {
}
}

impl From<&RecordData> for TermInterface {
impl From<&RecordData> for ValueInterface {
fn from(value: &RecordData) -> Self {
TermInterface {
ValueInterface {
fields: value
.fields
.iter()
Expand All @@ -64,36 +66,37 @@ impl From<&RecordData> for TermInterface {
}
}

impl From<&Term> for TermInterface {
fn from(term: &Term) -> Self {
term.extract_interface().unwrap_or_default()
impl From<&NickelValue> for ValueInterface {
fn from(value: &NickelValue) -> Self {
value.extract_interface().unwrap_or_default()
}
}

trait ExtractInterface {
fn extract_interface(&self) -> Option<TermInterface>;
fn extract_interface(&self) -> Option<ValueInterface>;
}

impl ExtractInterface for &Term {
fn extract_interface(&self) -> Option<TermInterface> {
if let Term::Record(rd) = self {
Some(TermInterface::from(rd))
} else {
None
}
impl ExtractInterface for NickelValue {
fn extract_interface(&self) -> Option<ValueInterface> {
self.as_record().map(|container| match container {
Container::Empty => ValueInterface {
fields: HashMap::new(),
},
Container::Alloc(record) => record.into(),
})
}
}

impl ExtractInterface for Field {
fn extract_interface(&self) -> Option<TermInterface> {
self.value.as_ref().map(|t| TermInterface::from(t.as_ref()))
fn extract_interface(&self) -> Option<ValueInterface> {
self.value.as_ref().map(ValueInterface::from)
}
}

impl ExtractInterface for Type {
fn extract_interface(&self) -> Option<TermInterface> {
fn extract_interface(&self) -> Option<ValueInterface> {
match &self.typ {
TypeF::Record(rrows) => Some(TermInterface {
TypeF::Record(rrows) => Some(ValueInterface {
fields: rrows
.iter()
.filter_map(|item| {
Expand All @@ -114,13 +117,13 @@ impl ExtractInterface for Type {
}

impl ExtractInterface for RuntimeContract {
fn extract_interface(&self) -> Option<TermInterface> {
self.contract.as_ref().extract_interface()
fn extract_interface(&self) -> Option<ValueInterface> {
self.contract.extract_interface()
}
}

impl ExtractInterface for LabeledType {
fn extract_interface(&self) -> Option<TermInterface> {
fn extract_interface(&self) -> Option<ValueInterface> {
self.typ.extract_interface()
}
}
Expand Down Expand Up @@ -198,7 +201,7 @@ impl FieldInterface {
}

pub(super) fn has_subfields(&self) -> bool {
matches!(&self.subfields, Some(ref intf) if !intf.fields.is_empty())
matches!(&self.subfields, Some(intf) if !intf.fields.is_empty())
}

/// Return the list of the type and contract annotations joined as a comma-separated string, if
Expand Down
12 changes: 6 additions & 6 deletions cli/src/customize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use nickel_lang_core::{
identifier::LocIdent,
program::{FieldPath, Program},
term::{
LabeledType, MergePriority, RuntimeContract,
record::{Field, RecordData},
LabeledType, MergePriority, RuntimeContract, Term,
},
typ::{RecordRowF, RecordRowsIteratorItem, Type, TypeF},
};
Expand All @@ -25,7 +25,7 @@ use crate::{

pub mod interface;

use interface::{FieldInterface, TermInterface};
use interface::{FieldInterface, ValueInterface};

/// The value name used through the CLI to indicate that an option accepts any Nickel expression as
/// a value.
Expand Down Expand Up @@ -178,7 +178,7 @@ struct CustomizableFields {

impl CustomizableFields {
/// Create data from a term interface.
fn new(term_iface: TermInterface) -> Self {
fn new(term_iface: ValueInterface) -> Self {
let mut this = Self::default();

for (id, field_iface) in term_iface.fields {
Expand Down Expand Up @@ -287,7 +287,7 @@ impl CustomizeOptions {
return CliResult::Err(Error::CliUsage {
error,
files: program.files(),
})
});
}
};

Expand Down Expand Up @@ -318,7 +318,7 @@ impl CustomizeOptions {
return CliResult::Err(Error::CliUsage {
error,
files: program.files(),
})
});
}
};

Expand All @@ -342,7 +342,7 @@ impl CustomizeMode {
files: program.files(),
})?;

let customizable_fields = CustomizableFields::new(TermInterface::from(evaled.as_ref()));
let customizable_fields = CustomizableFields::new(ValueInterface::from(&evaled));
let opts = CustomizeOptions::parse_from(self.customize_mode.iter());

match opts.command {
Expand Down
Loading
Loading