1
1
mirror of https://github.com/tweag/nickel.git synced 2024-09-11 11:47:03 +03:00
Commit Graph

122 Commits

Author SHA1 Message Date
Yann Hamdaoui
6015c8c0cb
Backport 1.4 release to master (#1755)
* Only update relevant deps in Cargo.lock

The release script needs to update Cargo.lock after having updated
Cargo.toml with the new version of various Nickel crates.

Indeed, we are running some checks via Nix, and Nix builds are sandboxed
without network access. This requires the Nix build to use `cargo
--frozen --offline`, which in turns require the Cargo.lock file to be
up-to-date or it will fail.

The previous version of the release script would do a simple `cargo
update`, which has the default of updating all dependencies. This commit
changes that to only udpate dependencies which we might have bumped.

* Add pause to commit release notes in release script

* Fix release script for LSP

The release script was missing a part: the removal of `lsp-harness` (a
local, unpublished util crates) from the nickel-lang-lsp package priori
to publication to crates.io.

Passing by, other small improvements and fixes are included as well.

* [release.sh] update to 1.4.0

* Specify 'do not commit' when updating release notes

* release guide: add missing step for lsp-harness removal
2024-01-11 09:15:16 +00:00
Yann Hamdaoui
f6227ce18c
Update Topiary to handle (.) curried op (#1753)
The curried version of the field access operator `(.)` wasn't handled
properly by the Nickel tree-sitter grammar, and thus Topiary, and thus
`nickel format`.

This commit simply updates to the latest version of Topiary. We also
switch from using tree-sitter-nickel from crates.io to using the same
version as Topiary (from the repository).
2024-01-09 12:44:17 +00:00
Yann Hamdaoui
d35baaee1c
Add --error-format flag to serialize err diagnostics (#1740)
* Add --error-format flag to serialize err diagnostics

* Make other CLI errors follow --error-format as well
2023-12-19 15:36:57 +00:00
Yann Hamdaoui
22e94cff46
1.3.0 release (#1714)
* Bump version numbers for 1.3 release

* Add release notes (part 1)

* Bump latest version mentioned in READMEs to 1.3

* Bump latest version mentioned in manual to 1.3

* Update RELEASING guide
2023-11-16 17:52:59 +00:00
Yann Hamdaoui
28672ee45b
Update malachite 3.x -> 4.x (and other crates) (#1705) 2023-10-30 09:03:50 +00:00
Taeer Bar-Yam
91d63ed611
add %eval_nix% primop (#1465)
* add importing nix files behind a nix-experimental feature flag

* add %eval_nix% builtin to evaluate a nix string

* basic error reporting from nix

* error messages

* use pkg-config to find nix dependency

* nice error message when feature disabled

* better errors

* resolve XXX

* put appropriate dependencies in nativeBuildInputs

* explain -sys crate option

* no %% around builtins in error messages

* clippy needs nativeBuildInputs

* clippy

* fix cargo doc

* use nix master

* c++17 -> c++20

* cargo fmt

* review comments

* fixup after merge

* fix after rebase

* revert to (hopefully) known good nix commit

* try using nix's own nixpkgs

* this worked on build02

* debug for mac CI

* debug doesn't work

* cargo fmt

* debug

* don't fail everything if we can't debug

* debug take N

* nix-version

* remove debug

* disable checks for nix on x86_64-darwin
2023-10-09 15:08:55 +00:00
Viktor Kleen
924959742d
Version bumps for 1.2.2 (#1655)
* Update to 1.2.2

* Update Cargo.lock
2023-09-29 13:36:02 +00:00
Viktor Kleen
19bed669f9
Track more metrics (#1635)
* Track thunk allocation

* Track `Program::new_from_files` as `Program::new`

* Track environment inserts and gets

* Implement tracking histograms

* Track environment layer size on `get`

* Track number of environment layers traversed on `get`

* Update core/src/environment.rs

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>

* Formatting

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-09-28 16:31:16 +00:00
Viktor Kleen
c4b7e0dd5c
Implement a first solution for collecting metrics during a Nickel evaluation (#1633)
* Implement prototype metrics collection and reporting

* Add a few sample metrics

* Document some of the rationale

* Remove unused `metrics-utils`

* Don't enable metrics by default

* Report metrics to stderr
2023-09-27 10:55:03 +00:00
Erin van der Veen
83d189c0c1
Pin and update Topiary (#1624) 2023-09-22 13:44:47 +00:00
Yann Hamdaoui
fcde9ba0ad
[REVIEW & CI] 1.2.1 release (#1606)
* Tentative fix for 1.2.0 not installing

* Update to 1.2.1 (fix cargo install)

* Update Cargo.lock
2023-09-14 19:53:55 +00:00
Yann Hamdaoui
27b8c0ede5
Backport 1.2.0 release to master (#1603)
* Bump versions for 1.2.0 release

* Update Cargo.lock

* Update RELEASING guide

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>

* Add 1.2.0 release notes

* Depend from published tree-sitter-nickel

* Add warning about crates.io and format feature in READMEs

* Fix formatting_external borrowing issue

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-09-14 18:14:32 +00:00
Viktor Kleen
fca5046c43
Put embedded topiary formatting behind a feature flag for NLS (#1604)
* Prevent unused import warnings when building without `doc`

* Put embedded topiary formatting behind a feature flag for NLS, as well

* Stop sending a formatting edit if nothing changed
2023-09-14 12:59:53 +00:00
Viktor Kleen
305d1a4488
Normalize line endings in string literals during parsing (#1562)
* Remove unused `strip_indent_doc`

* Replace `\r\n` by `\n` in the string literal parser

* `mk_strchunk_literal` -> `StrChunk::normalized_literal`

* Move string normalizing into the lexer

* Remove leftover debug print
2023-09-04 15:11:32 +00:00
Viktor Kleen
28a5e10592
Use std:io::IsTerminal instead of atty (#1540)
The `atty` crate appears to be unmaintained and `std::io::IsTerminal`
provides the same functionality since rust 1.70.
2023-08-23 15:20:19 +00:00
Yann Hamdaoui
8b4d2d4d80
Update strip-ansi-escape deps, remove corresponding temporary fix (#1521) 2023-08-10 11:06:48 +00:00
Yann Hamdaoui
618b56595d
Temporary fix for strip-ansi-escape breakage (#1515) 2023-08-09 08:57:45 +00:00
Viktor Kleen
84da9e78af
Refactor the Nickel CLI (#1502)
* Refactor the Nickel CLI structure

* Add an `Error` enum for the CLI

* Restore the previous user-facing interface

* Make clippy happy

* Restore `nickel format` CLI behaviour

* Change command options naming

* Properly respect feature flags

* WithProgram -> ReportWithProgram

* Remove the unecessary `Files` struct for now

* ReportWithProgram -> ResultErrorExt

* Suggestions from code review
2023-08-08 11:55:03 +00:00
Théophane Hufschmitt
5572b444b0
Disable the colors when stdout isn't a tty (#1508)
Fix https://github.com/tweag/nickel/issues/1500
2023-08-08 08:55:46 +00:00
Yann Hamdaoui
e934796dc6
Restore --version for CLI, include git revision (#1486)
* Restore --version for CLI, include git revision

* Use git revision from nix during the build

* Update flake.nix

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-08-07 11:55:13 +00:00
Jeremy Parker
aa4bb20b3e
Add linker directive for *-darwin to fix PyO3 (#1454)
* Add linker directive for *-darwin to fix PyO3

Without these flags I get linking errors like this when building from
nixpkgs:

  = note: Undefined symbols for architecture arm64:
            "_PyExc_ConnectionResetError", referenced from:
                pyo3::type_object::PyTypeInfo::type_object::hd73bc9c256c52717 in libpyo3-c59aeb8b74bb57e0.rlib(pyo3-c59aeb8b74bb57e0.pyo3.e60578ba-cgu.0.rcgu.o)

See: https://pyo3.rs/main/building_and_distribution#macos

* Move from cargo `config.toml` options to a build script for pyckel

* Use the same revision of tree-sitter-nickel as topiary does

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-31 16:16:42 +00:00
Viktor Kleen
997e344f4f
Topiary integration as nickel format (#1371)
* Implement `nickel format` PoC as a topiary wrapper

Improve error reporting for `nickel format`

nix build with topiary

Use upstream topiary query export

* Pin wasm-bindgen version

* Disable `format` feature in nickelStatic for now

* Remove thiserror dependency and make tempfile optional

* Update Cargo.lock

* Disable `nickel format` by default
2023-07-13 10:43:51 +00:00
Yann Hamdaoui
7a01d60270
Backport 1.1.1 (#1439)
* Version bump: 1.0.0 -> 1.1.0

* Add release notes for 1.1

* Bump version - part 2, reset to 0.1 for new crates

* Add missing README to nickel-lang-cli

* Update Cargo.lock, make nickel-wasm-repl's version consistent

* Update releasing instructions for new crate layout

* Fix typo in RELEASES.md

* Update Cargo.lock
2023-07-10 15:31:28 +00:00
Viktor Kleen
78e7a8814b
Rename and move workspace crates (#1399)
* Rename and move workspace crates

nickel-lang -> nickel-lang-cli in cli/
nickel-lang-lib -> nickel-lang-core in core/
nickel-lang-utilities -> nickel-lang-utils in utils/
nickel-repl -> nickel-repl in wasm-repl/

* Finish renaming in rust sources

* Update RELEASING.md

* Move to workspace dependencies

* Rename nickel-repl -> nickel-wasm-repl

* Update RELEASING.md

Co-authored-by: Taeer Bar-Yam <Radvendii@users.noreply.github.com>

* Address suggestions from code review

* Update HACKING.md

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>

* Elaborate on the versioning scheme in RELEASING.md

---------

Co-authored-by: Taeer Bar-Yam <Radvendii@users.noreply.github.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-06-26 16:58:40 +00:00
Viktor Kleen
3e03cc7909
Move the CLI into its own crate (#1351)
* Fetch the wasm-bindgen-cli version from Cargo.lock instead of Cargo.toml

* Move the Nickel CLI to a separate crate

* Fix snapshot tests

* Rename the nickel flake output to nickel-lang-cli for consistency

* Move the nickel-lang crate into a subdirectory

* Update documentation for the new crate split

* Tweak snapshot test instructions

* Use project_root instead of ad-hoc environment variables

* Remove the library from nickel-lang-cli for now

* Rename nickel-lang to nickel-lang-lib and nickel-lang-cli to nickel-lang

* Apply suggestions from code review

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>

* Tweak documentation for nickel_lang_utilities::project_root

* Use MacOS 13 github runner because of https://github.com/cachix/install-nix-action/issues/183

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-06-16 16:34:13 +00:00
jneem
1676d22a2b
LSP test harness (#1360)
* First working hacky lsp harness

* Refactor

* Add some pretty-printing

* Snapshot tests for the lsp

* clippy

* Update lsp/lsp-harness/src/jsonrpc.rs

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>

* Review comments

* ci

* Update lsp/lsp-harness/README.md

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-06-15 11:55:42 +00:00
Kevin K
01bc906b67
Migrate to clap (#1309)
* migrate nls from structopt to clap

* migrate nickel from structopt to clap

* qualify traits coming from clap

* use clap::ColorChoice with ColorOpt as a newtype

* remove explicit default() for value enums

[clap
Documentation](https://docs.rs/clap/latest/clap/_derive/index.html#arg-attributes)
states it will use `Default::default()` so there is no need to
explicitly call it.

* remove manual FromStr implementations and rely on ValueEnum

deriving `clap::ValueEnum` implements `FromStr` for the type, so doing
so manually isn't required any longer.

* Persuade `clap` to use default values

---------

Co-authored-by: Viktor Kleen <vkleen+github@17220103.de>
2023-05-22 09:02:21 +00:00
Yann Hamdaoui
c4da6975b3
Bump version to 1.0 (#1302)
* Bump version number to 1.0

* Add text for 1.0 release
2023-05-17 12:50:43 +00:00
Yann Hamdaoui
6a69e076c1
Fix escaping of contracts' custom error message (#1274)
Custom contract errors were escaped too agressively (such as turning
`"` into `\"`), while we only want to escape ANSI escape sequences to
avoid messing up Nickel's error reporting. This commits use a
specialized crate to do that, instead of Rust's std `escape`.
2023-04-21 13:52:08 +00:00
Yann Hamdaoui
d723a3721c
Use indexmap for deterministic behavior (#1235)
This commits use a drop-in replacement for std::collections::HashMap.
The std hashmap has a non-deterministic iteration order, which makes for
a non-deterministic error reporting (when typechecking a file with
multiple errors for example, running Nickel several time on the same
file gives a different output, which is quite bad for the user, who
might think they solved an issue while they didn't).

IndexMap uses the same algorithm and is on par performance-wise, but has
a deterministic iteration order (which is insertion order). Stuff not
related to records or types (other hasmaps used for example in the cache
to map file ids to parsed terms) are left unchanged.
2023-04-07 18:56:45 +02:00
Yann Hamdaoui
53dcc80b1f
Update Nickel dependencies (#1234)
The original motivation is to fix the rustc warning coming from LALRPOP
by updating to 0.19.9. While we're at it, we `cargo update`d.
2023-04-07 17:25:44 +02:00
dependabot[bot]
52511ec5fa
chore(deps): bump comrak from 0.16.0 to 0.17.0 (#1208)
Bumps [comrak](https://github.com/kivikakk/comrak) from 0.16.0 to 0.17.0.
- [Release notes](https://github.com/kivikakk/comrak/releases)
- [Changelog](https://github.com/kivikakk/comrak/blob/main/changelog.txt)
- [Commits](https://github.com/kivikakk/comrak/compare/0.16.0...0.17.0)

---
updated-dependencies:
- dependency-name: comrak
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-03-30 17:03:24 +00:00
matthew healy
828d972fa9
Update stdlib string functions to work on Unicode extended grapheme clusters (#1200)
* Delete dead code from strings.ncl

* Split stdlib_string.ncl into multiple test files

This commit splits the monolithic stdlib string test file into
multiple smaller files, roughly split according to "domain" behaviour.

It also adds some new test cases in places where the coverage seemed
a little thin.

* Maintain extended grapheme cluster abstraction in `string.split`

This commit re-implements `string.split` so that extended grapheme
clusters are never broken up, even if the separator is included
within.

* Return extended grapheme clusters from `string.characters`

* Remove `string.codepoint` and `string.from_codepoint`

These functions break the extended grapheme cluster abstraction,
and don't have equivalents in the Nix language, so we've decided
to remove them.

* Use grapheme cluster indices in string.substring

* Ensure `string.replace` doesn't separate extended grapheme clusters

* `string.contains` should check entire grapheme clusters

This updates the implementation of `string.contains` to avoid returning
true if the string we're searching for only exists as part of a larger
extended grapheme cluster.

* Refactor Nickel string implementation to `term::string` module

* Update stdlib documentation
2023-03-29 10:30:05 +02:00
Yann Hamdaoui
44a97f56d4
Fix serialization/to_string error on rationals 2023-03-14 18:50:42 +01:00
Yann Hamdaoui
61396bb7f7
Use arbitrary precision rationals for numbers
First draft of implementing Nickel numbers using arbitrary precision
rationals instead of 64-bits float. The rationale is to provide exact
precision for common arithmetic operations (understand addition,
division, subtraction, raising to an integer power, modulo), as opposed
to floats, that can incur rounding error on sometimes common decimal
values.

Some operations do need rounding: raising to a non-integer power, as
well as representation as a string (to_string/serialization).
2023-03-14 18:48:01 +01:00
Yann Hamdaoui
b65eb3d72e
Bump rust dependencies, fix breaking changes 2023-03-10 19:18:26 +01:00
Guillaume Desforges
0c68c8e69f Update Cargo.toml
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>
2023-01-16 16:38:24 +01:00
Guillaume Desforges
768656d75a Move Python bindings to its own crate pyckel 2023-01-16 16:38:24 +01:00
Guillaume Desforges
27a8d30ef7 Generating Python module is optional 2023-01-16 16:38:24 +01:00
Guillaume Desforges
6e122939ad init Python bindings 2023-01-16 16:38:24 +01:00
matthew healy
bff8451f7e
Add snapshot testing infrastructure (#1034)
* Update regex crate to 1.7

We want to use the regex filtering feature of the insta snapshot testing
library. That has a dependency on a newer version of the regex crate
than Nickel currently does, so this commit updates the Nickel version to
a more recent compatible version.

* Add insta dependency

* Add cargo-insta to dev shells

* Add snapshot testing infrastructure

This uses the insta crate to implement snapshot testing.

Each snapshot test invokes the debug nickel binary with some set of
arguments, then captures the output & compares it to a file in the
snapshots directory

* Add nixpkgs-fmt to dev shell

This makes it possible to easily reformat flake.nix from within a dev
shell.

* Update HACKING.md

* Add snapshot testing README
2023-01-09 11:32:40 +01:00
matthew healy
14aa2e05e9
Return grapheme cluster count from %str_length% primitive (#1005)
Previously `%str_length%` was returning the number of bytes in the Rust
`String` storage, which lead to unexpected results.

This commit uses the `unicode-segmentation` crate to instead count the
number of extended grapheme clusters in the string. This means that even
complex emoji comprised of multiple characters, but visually rendering
as one, get counted as just one character.

One potential downside to this is that this isn't consistent with how
other standard library functions (such as splitting a string) currently
work, however it also wasn't consistent before, and this change at least
moves things in the right direction
2022-12-16 15:45:19 +01:00
Matthew Healy
89823b1662 Bump versions to 0.3.1 2022-12-15 17:08:50 +01:00
matthew healy
b10b27fe61
Automate adding .ncl file test cases (#992)
* Add test-generator dependency

* Use test-generator to simplify pass test file

This commit uses the test-generator library to automatically generate a
set of integration tests from any `.ncl` file in the
`tests/integration/pass` directory.

As a consequence, simply adding a new file to that directory is
sufficient to add a new test case.

This also meant that the non-test files, like the assertion library and
files that are used to test importing, were moved to a '/lib' directory
so test-generator doesn't pick them up.
2022-12-15 12:06:10 +01:00
Yann Hamdaoui
fd37904c4d
Bump Nickel version to 0.3 2022-12-08 10:44:11 +01:00
Yann Hamdaoui
1ddf52bdeb
[CI] Add clippy check (#793)
* Print logs when running `nix flake check` in CI
* Add clippy to the flake checks and git hooks
* Clippy auto fix
  `cargo clippy --fix --workspace --no-deps --frozen --offline -- --deny warnings --allow "clippy::new-without-default" --allow "clippy::match_like_matches_macro"`
* Manually fix remaining Clippy warnings

Co-authored-by: Julien Debon <julien.debon@tweag.io>
2022-11-17 18:18:49 +01:00
Julien Debon
bb66cb0266 Update wasm-bindgen from 0.2.74 to 0.2.83
Version 0.2.74 no longer builds with recent `nixpkgs` because of openssl.

* Update wasm-bindgen from 0.2.74 to 0.2.83
* Refactor `wasm-bindgen-cli` overlay to override Nixpkgs' definition, rather
than build the package from Github
* Remove the no longer used `wasm-bindgen-api-Cargo.lock` file
* Add comments about the hidden coupling between `wasm-bindgen` in `Cargo.toml`
and `wasm-bindgen-cli` in `flake.nix`
2022-11-03 11:36:34 +01:00
Anthony Caccia
a22f840495 rewrite the Identifier Interner to store strings in an arena and Ident to have symbols 2022-09-20 13:43:09 +02:00
Anthony Caccia
a24edc8535 WIP: add a naive string interner for identifiers 2022-09-16 15:40:31 +02:00
Yann Hamdaoui
50e373f181 Bump version to 0.2.1 2022-08-08 15:31:44 +02:00