1.7.0
Version 1.7 (2024-06-11)
Note: the previous 1.7 released pointed to the wrong revision and was deleted. Although the attached artifacts and the tarball would still include all the actual 1.7 features, the nickel and nls binary would identify as 1.6 when using nickel --version
. This release is identical to the previous one but points to the right revision with the version numbers up to date.
Nickel 1.7 ships with several extensions to pattern matching which was introduced in Nickel 1.5 but had a number of limitations. See below for further details. Releases on other platforms that GitHub (such as crates.io) are unaffected.
Additionally, the publication of Topiary to the crates registry makes it so that all versions of Nickel from 1.7 and onward, however they are built, ship with nickel format
and the language server formatting command working out of the box without needing a separate installation of Topiary (which was previously required when installing from crates.io using cargo install nickel-lang-cli
or cargo install nickel-lang-lsp
).
Breaking changes
-
Although primitive operators are internal and aren't officially part of any stability guarantee, some libraries sometimes need to resort to using them, when there's no equivalent in the stdlib. Nickel 1.7 had a big primop refactoring, amounting mostly to renaming. If you're using primops, please look at the corresponding pull request
-
The behavior of destructuring has been changed to match exactly the behavior of pattern matching. While there should be no difference on well-behaving programs, this change makes destructuring stricter and can lead to some programs that were running fine before 1.7 to now fail with
unmatched pattern
. The typical example is when destructuring a record with a field that is not present:let {x,y, ..} = import "lib.ncl" in
. Ifx
is absent from thelib.ncl
but is never used anywhere, this used to work fine before 1.7 (the error would only trigger upon usage ofx
) but will now fail eagerly.If you need to fix a large codebase with long import destructuring chains and you don't know which fields are the offending ones, one possible technique is to open the importing file in an editor and use the
goto definition
command of the NLS on each field of a faulty pattern. If it works, the field is present, but if it doesn't, the field might be faulty. You can also apply a record contract mimicking the structure of the pattern to theimport "..."
expression to get better error reporting.
Core language
- Patterns now support constant values (
1
,null
,"a"
, etc.), array
patterns ([fst, snd, ..tail]
), pattern guards ('Foo x if std.is_number x
), wildcard patterns (_
placeholder) and or-patterns (('Foo x) or ('Bar x) or ('Baz x)
): (see the syntax section of the manual for more details) - Uniformize destruct and pattern matching logic by @yannham in #1907
- Opaque values by @jneem in #1913
Stdlib
- Add
record.get_or
to get value from record supplying default value by @olorin37 in #1920 - [Fix] Avoid
record.get_or
failing on field without definition by @yannham in #1946 - Add stdlib function
array.at_or
by @olorin37 in #1927 - Add
std.enum.(from/to)_tag_and_arg
andstd.enum.map
to dynamically decompose and recompose an enum by @yannham in #1939 - Add
std.test
module withAssert
andassert_all
function to testing by @ajbt200128 in #1914
Documentation
- Fix typo in BlameError documentation by @ErinvanderVeen in #1899
- Update README.md for nix profile install by @cloudyluna in #1918
LSP
- Tell NLS about variable bindings in match statements by @jneem in #1926
- Add --version support to NLS and fix feature unification issues by @yannham in #1936
- Fix NLS crash and better refresh diagnostics by @jneem in #1944
Tooling
- Include field path in non serializable error by @yannham in #1905
- Allow single input to
nickel xxx
command to be JSON, YAML or TOML as well by @olorin37 in #1902 - Use Topiary's published crates over git to always enable formatting by @ErinvanderVeen in #1919
New Contributors
- @olorin37 made their first contribution in #1902
- @cloudyluna made their first contribution in #1918
- @ajbt200128 made their first contribution in #1914
Full Changelog: 1.6.0...1.7.0