mirror of
https://github.com/tweag/nickel.git
synced 2024-10-06 08:07:37 +03:00
717db391c6
Nickel's `$record` contract was previously implemented as a series of nested calls to `$record_extend` which, for each field in the record type, would: 1. check that the field was present in the value, and if so 2. insert an `%assume%` which applied the contract for that field to the value into the final accumulated record, and 3. call the contract for the record's tail on any remaining fields. This commit "flattens" this out so that, rather than a series of nested `$record_extend` contracts, `$record` is provided a record which maps expected field names to their associated contracts. These expected fields are then compared with the record value directly in the contract, with blame being raised where appropriate. This makes it possible to, for example, report every missing field name at once, as opposed to just the first one we find. (Though that has not been done in this PR to minimise the diff.) |
||
---|---|---|
.. | ||
array.ncl | ||
builtin.ncl | ||
contract.ncl | ||
function.ncl | ||
internals.ncl | ||
num.ncl | ||
record.ncl | ||
string.ncl |