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

3840 Commits

Author SHA1 Message Date
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
Taeer Bar-Yam
9780a3fea7
implement pretty printing for Match::Assign (#1503) 2023-08-04 22:20:33 +00:00
Viktor Kleen
ebfa2a6f3d
Import YAML files containing multiple documents as arrays (#1497)
For example, in Kubernetes deployments it is common practice to package
multiple YAML documents into a single file. For processing such files
with Nickel we need to support importing multiple YAML documents from
a single file. The concern with this is: how does such a file fit into
Nickel's data model? Importing it as an array of Nickel values felt most
reasonable to me. At the same time, a YAML file containing a single
document should still be transparently serialized as that document, not
as a single element array.
2023-08-03 21:57:08 +00:00
jneem
39caa5dc23
Cleanup: use normalize_path instead of canonicalize (#1496) 2023-08-03 19:12:38 +00:00
Viktor Kleen
88ede26e98
Rename the typ field in JSON documentation to type (#1495)
There is no reason to restrict ourselves to the Rust field names.
2023-08-03 17:34:15 +00:00
jneem
67e570651c
Traversal by reference (#1492)
* Add traverse_ref.

* Make less generic, and use it for find_flat

* Clippy
2023-08-03 17:11:23 +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
Yann Hamdaoui
b809581771
flake.lock: Update (#1437)
* flake.lock: Update

Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/4d350bb94fdf8ec9d2e22d68bb13e136d73aa9d8' (2023-06-29)
  → 'github:ipetkov/crane/8b08e96c9af8c6e3a2b69af5a7fa168750fcf88e' (2023-07-07)
• Updated input 'crane/flake-utils':
    'github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef' (2023-05-31)
  → 'github:numtide/flake-utils/dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7' (2023-06-25)
• Updated input 'crane/rust-overlay':
    'github:oxalica/rust-overlay/c535b4f3327910c96dcf21851bbdd074d0760290' (2023-06-03)
  → 'github:oxalica/rust-overlay/f9b92316727af9e6c7fee4a761242f7f46880329' (2023-07-03)
• Updated input 'flake-utils':
    'github:numtide/flake-utils/dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7' (2023-06-25)
  → 'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/4bc72cae107788bf3f24f30db2e2f685c9298dc9' (2023-06-29)
  → 'github:NixOS/nixpkgs/e6ab46982debeab9831236869539a507f670a129' (2023-07-29)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/522fd47af79b66cdd04b92618e65c7a11504650a' (2023-06-30)
  → 'github:cachix/pre-commit-hooks.nix/fcbf4705d98398d084e6cb1c826a0b90a91d22d7' (2023-07-30)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/ef95001485c25edb43ea236bdb03640b9073abef' (2023-07-01)
  → 'github:oxalica/rust-overlay/05d480a7aef1aae1bfb67a39134dcf48c5322528' (2023-07-30)
• Updated input 'topiary':
    'github:tweag/topiary/b4b3aa9f6fb6f8d220bcae033514327a32557786' (2023-06-30)
  → 'github:tweag/topiary/e30432a29b6d3bb606cbb09b022a5ad0598810dc' (2023-07-31)
• Updated input 'topiary/advisory-db':
    'github:rustsec/advisory-db/0e97e6e71f0dd52b4b4e0ab3fa6e5e5dd72f852a' (2023-05-17)
  → 'github:rustsec/advisory-db/5ceeefcbbabf4b510ef8ede121d6dc57d1a1f7f8' (2023-07-08)
• Updated input 'topiary/crane':
    'github:ipetkov/crane/99de890b6ef4b4aab031582125b6056b792a4a30' (2023-05-19)
  → 'github:ipetkov/crane/8b08e96c9af8c6e3a2b69af5a7fa168750fcf88e' (2023-07-07)
• Updated input 'topiary/crane/flake-utils':
    'github:numtide/flake-utils/cfacdce06f30d2b68473a46042957675eebb3401' (2023-04-11)
  → 'github:numtide/flake-utils/dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7' (2023-06-25)
• Updated input 'topiary/crane/rust-overlay':
    'github:oxalica/rust-overlay/d59c3fa0cba8336e115b376c2d9e91053aa59e56' (2023-05-03)
  → 'github:oxalica/rust-overlay/f9b92316727af9e6c7fee4a761242f7f46880329' (2023-07-03)
• Updated input 'topiary/flake-utils':
    'github:numtide/flake-utils/cfacdce06f30d2b68473a46042957675eebb3401' (2023-04-11)
  → 'github:numtide/flake-utils/dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7' (2023-06-25)
• Updated input 'topiary/nix-filter':
    'github:numtide/nix-filter/f529f42792ade8e32c4be274af6b6d60857fbee7' (2023-04-10)
  → 'github:numtide/nix-filter/d90c75e8319d0dd9be67d933d8eb9d0894ec9174' (2023-06-19)
• Updated input 'topiary/rust-overlay':
    'github:oxalica/rust-overlay/a227d4571dd1f948138a40ea8b0d0c413eefb44b' (2023-05-23)
  → 'github:oxalica/rust-overlay/d7181bb2237035df17cab9295c95f987f5c527e6' (2023-07-11)

* Fix new clippy warning

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-31 14:46:57 +00:00
Viktor Kleen
a51b8ce08e
Change rev().next() to next_back() to please clippy (#1490) 2023-07-31 12:52:42 +00:00
jneem
dc76b14556
Convert paths to absolute before normalization (#1489)
* Add test

* Fix test

* Convert paths to absolute before normalization

The path normalization function doesn't work on paths starting with '..'.
One fix is to make paths absolute.

* Add comment
2023-07-31 12:52:20 +00:00
jneem
c4ac9c368a
Linearize imports in dependents-first (#1488)
Fixes #1480
2023-07-31 12:49:51 +00:00
jneem
74f1a355d8
Language server semantics (#1477)
* Add LSP semantics notes

* Add a test verifying current goto def behavior

* Some improvements based on comments
2023-07-28 17:42:46 +00:00
Taeer Bar-Yam
30132d8dfe
Fix REPL panic on transitive imports (#1474)
* report errors on transtive imports

as it was before, we would crash

* slight refactor of resolve_imports

* clippy
2023-07-28 14:33:48 +00:00
Viktor Kleen
edc7394f0b
Actually persist output files for formatting (#1483)
* Actually persist output files for formatting

All the code for properly formatting files in-place was there, but
in the original PR I forgot to persist the output file. As a result,
formatting works for as a pipeline from stdin to stdout but when
an output file is specified, the formatted Nickel code is silently
discarded.

With this change we actually persist the formatted result.

* Add a rudimentary CLI integration test to make sure output files are created
2023-07-28 10:47:13 +00:00
jneem
de3d87d05d
Issue diagnostics, even if empty. (#1478) 2023-07-27 11:58:12 +00:00
Viktor Kleen
b6646a8a8c
Ignore missing field definition errors during documentation extraction (#1476)
* Ignore missing field definition errors during documentation extraction

My first implementation of a shallow evaluation mode for extracting
documentation tried to evaluate to WHNF every record field that
has a value. Then it reports any error that it encounters. But we
actually expect to hit `EvalError::MissingFieldDef` in normal partial
configurations because presumably an undefined field is intended to
be used recursively somewhere. With this change, we report all errors
except for `MissingFieldDef`.

* Add a comment describing the error recovery rationale
2023-07-26 16:13:25 +00:00
Yann Hamdaoui
0f02aa14b7
Proper type instantiation discipline (#1473)
* Proper type instantiation discipline

This commit is the last missing piece (at least for the time being)
toward a reasonable bidirectional typechecking algorithm that properly
handle higher-rank types.

Instantiation of polymorphic types has been ad-hoc and full of issues.
Simple programs such as:

```nickel
let r : { id : forall a. a -> a } = { id = fun r => r } in
r.id "x"
```

or

```nickel
let eval : forall a. (forall b. b -> b) -> a -> a = fun f x => f x in
(eval (fun x => x) 1) : Number
```

wouldn't typecheck. Previously introduced variable levels were required
before we could change that.

This commit is building on the variable level to use a proper
instantiation discipline from the specification of the Nickel type
system located in this repository, and the original inspiration, [A
Quick Look at Impredicativity]() (although type instantiation is
currently predicative, the general structure of the bidirectional
type system is similar). Doing so, we also move code between `check` and
`infer` to better reflect the specification: `infer` is not
wrapper around check + unification anymore, but it actually implements
infer rules (function application, primop application, variable and annotation).

Instantiation is taken care of when switching from infer mode to check
mode within `subsumption` and at function application.

* Add test for unsound generalization

And fix the error expectation for `TypecheckError::VarLevelMismatch`
that still had the old longer name `VariableLevelMismatch`.

* Update core/tests/integration/main.rs

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

* Update core/src/typecheck/mod.rs

* Update core/src/typecheck/mod.rs

* Post-rebase fixup + clippy warnings

* Formatting of Nickel test files

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-25 14:07:46 +00:00
Yann Hamdaoui
498e91d06b
[Refactor] Types -> Type, types -> typ (#1472)
* Types -> Type, types -> typ

`type` is a reserved keyword in Rust, which is why we've been adding an
`s` to uppercase `Type` and lowercase as in `crate::types::Types`.
However:
1. uppercase `Type` is actually valid, only lowercase `type` clashes
   with the Rust keyword.
2. Adding an `s` has caused confusion, because there's no easy way to
   tell if a struct field `types` means there are several types, or if
   it's just a work-around to avoid the keyword.

In consequence, this commits rename lowercase `types` to `typ` (and in
particular the module `types` is now `typ`), and the uppercase `Types`
to `Type` (so, previously `types::Types` is now `type::Type`).

* Formatting
2023-07-25 12:47:28 +00:00
Viktor Kleen
835f15cbfb
Evaluate terms before extracting documentation (#1463)
* Extract documentation before touching the filesystem

* Draft evaluation mechanism for documentation extraction

* Properly collect evaluation errors

* eval_for_docs -> eval_for_doc

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

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-07-25 11:43:02 +00:00
Yann Hamdaoui
8f4c5103ff
[Refactor] Introduce RemoveRow trait (#1471)
* Put unify::(e,r)rows_add in dedicated trait

The free-standing functions `erows_add` and `rrows_add` are very
similar. The name and documentation was also misleading: what those
methods do is rather to remove a row than adding a new one.

This refactoring put them in their own trait, `RemoveRow`, and update
the documentation accordingly. Doing so, we also get rid of an optional
for the `UnsatConstr` error, which as unwrapped at some point anyway.

* Reword comment
2023-07-25 09:22:07 +00:00
Taeer Bar-Yam
15b2cdcdcf
Trees that grow notes (#1419)
* trees that grow notes

* fix rendering

* More precise / accurate wording

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

* Update notes/trees-that-grow-proc-macro.md

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

* Update notes/trees-that-grow-proc-macro.md

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

* address review comments

* Update notes/trees-that-grow-proc-macro.md

Co-authored-by: jneem <joeneeman@gmail.com>

* Exp -> Exp<Ext>

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
Co-authored-by: jneem <joeneeman@gmail.com>
2023-07-24 20:12:41 +00:00
dependabot[bot]
c42509ca21
chore(deps): bump word-wrap from 1.2.3 to 1.2.4 in /lsp/vscode-extension (#1468)
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-24 08:38:56 +00:00
Yann Hamdaoui
77ec9a0d82
[Refactor] Move unify and variants into their own trait (#1469)
* Structure `unify` and variants into Unify trait

* Fix comment documenting Unify/unify
2023-07-21 14:08:34 +00:00
Viktor Kleen
aff367df7e
Error on serializing very large numbers (#1470)
* Error on serializing very large numbers

Instead of blindly using the nearest `f64` for all Nickel `Number`s when
serializing, with this change we only use nearest rounding when a number
is in the range `[f64::MIN, f64::MAX]`. Otherwise we trigger a newly
introduced serialization error.

This stops the previous, arguably surprising, result that for example
`e400` gets serialized as `1.7976931348623157e308`. While techincally
this is the nearest `f64` to `1e400`, one wouldn't expect serialization
to incur an absolute error of about `1e92`.

Fixes #1457

* Add tests
2023-07-21 12:36:11 +00:00
Yann Hamdaoui
dc1865dc09
Move parts of typecheck main module into new module typecheck::unif (#1467)
* Move parts of typecheck into new typecheck::unif

The typecheck module is several kLoC. This PR creates a new submodule
`typecheck::unif`, which focus on unification internals, as to make those modules
more digestible.

* Fix broken link in doc
2023-07-21 10:45:16 +00:00
Yann Hamdaoui
0fa4d2de1b
Introduce unification variable levels and fix unsound generalization (#1372)
* Introduce variable levels

Typechecking higher-rank polymorphic types involves an additional
discipline on unification variables, to avoid something similar to
unsound generalization in ML. Morally, unification variables should keep
track of all the rigid type variables introduced before them, and refuse
to unify with rigid type variables that are not in this list.

In practice, it's sufficient and more efficient to just keep track of a
variable level, which is incremented each time a polymorphic type is
instantiated by the check rule with rigid type variables. Each
unification variable remembers its level, and can only unify with rigid
type variables of level smaller or equals.

This commit introduces the machinery for tracking and threading those
variable levels throughout typechecking, but doesn't put them to use
yet. In particular there is currently no additional check performed when
unifying type variables.

* Add cached var levels data to GenericUnifType

This commit continues the implementation of variable levels. This adds
level-related metadata to unification types to avoid eager traversal to
update variable levels, following Didier Remy's "Efficient and
insightful generalization" algorithm.

This commit doesn't update the new variable levels of types correctly
yet, but merely add the infrastructure to store them and updates the
code to use the new types.

* Fix NLS after adding cached variable levels

* Add trait to compute var levels upper bound

* Correctly propagate variable levels through type constructors

* Formatting

* Add levels to record rows unification variables

* Add init_level to erows unif var

* Add var_levels_data to enum erows

* Implement missing var_level_max

* SubstXXX -> one subst trait

Get rid of three variations on a `Subst` trait, to keep only one with a
template parameter. Introduce a substitution method to be implemented
which, in addition to substitution variables with something, also bubble
up new variable levels data, as they might have been updated by
substitution.

This commit doesn't actually implement the new substitution method yet,
leaving a trail of `todo!()` to be filled in follow-up commits.

* Implement new subst trait method

* Fix typo introducing infinite type bug

* Implement level update for type unification variables

* Improve/fix implementation of (forcing) variable level update

* Fix panic indexing in the wrong table

* Add simple test for variable levels

* Fix bound checking missing some unsound generalization

* Add test to guard against unsound generalization

* Implement var level updates for enum and record rows

* Introduce a proper type error for var level mismatch

* Improve specific var level mismatch error, fix tests in consequence

* Add variable level checks for (enum/record) rows

* Add tests for rows unification var level checks

* Fix various warning, clean TODOs and remove unusued functions

* Remove notes of variable levels

Adding those notes is postponed to follow-up pull request.

* Remove TODO comments

* Various renaming and doc fixes/improvements

* Apply suggestions from code review

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

* Update core/src/typecheck/mod.rs

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

* Fix links in rustdoc

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-20 17:16:41 +00:00
Yann Hamdaoui
ecd80adfd7
Replace assert macros by functions (#1464)
We defined various `assert_xxx` macro helpers in the early days for
tests. The only reason to use macros over simple functions was to report
the location of the caller located in the failing test, and not the code inside the helper, when
an assertion would fail. Since then we discovered the `#[track_caller]`
annotation which allows to do the same thing with bare functions. This
commit change such remaining macros to be bare functions.
2023-07-20 16:31:33 +00:00
Taeer Bar-Yam
5002968316
add std.contract.Sequence (#1452)
* add std.contract.Sequence

* nickel lists have `,`

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

* eta reduction

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

* example where it's actually useful

* capitalisation

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-07-20 07:25:00 +00:00
Viktor Kleen
da07e3ea55
Make the lexer accept scientific notation (#1456)
* Make the lexer accept scientific notation

* Mention scientific notation on doc/manual/syntax.md
2023-07-17 14:50:47 +00:00
Viktor Kleen
3d47bac01e
Static linking with nickel format (#1455)
* Enable `format` feature in the nix build and fix static linking

* Document static building

* Update flake.nix

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

* Enable `format` by default

* Remove `nickel-static` output on darwin

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-07-17 14:06:29 +00:00
jneem
396d8b384c
Use the Types AST variant for completion (#1450)
* Use the Types AST variant for completion

* Add missing snapshot
2023-07-13 15:04:18 +00:00
Viktor Kleen
76905f0a58
Update KEYWORDS with ne builtin type names (#1451)
The `KEYWORDS` list still contained `Num` and `Str` instead of `Number`
and `String`.
2023-07-13 12:49:26 +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
jneem
6d32dc48e5
Add a Types variant to Term (#1442)
* Add a Types variant to Term

* Mark Types as non-atomic

* Update core/src/term/mod.rs

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

* Only allow without_pos in tests

* Review comments

* Add a comment

* Improve typechecking of types in contract position

* Add a test for the new error

* Update core/src/eval/mod.rs

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

* Improve comment

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-07-13 10:28:34 +00:00
Yann Hamdaoui
081fc927a7
Improve query inteface (#1447)
* Improve :query interface

Previously, the query command of the REPL would accept a first argument
that could be a record access chain, followed by a second one which
could also be a field path. This means that, for querying a given path
`foo.bar.baz.blo`, there are 3 different but equivalent query
invocations:

- :query foo bar.baz.blo
- :query foo.bar baz.blo
- :query foo.bar.baz blo

Moreover, `:query foo.bar.baz.blo` without a second argument wouldn't
fail but pretend that there are no metadata, even if there are.

This commit simplify the overall interfaceo of the query command by just
accepting one argument which is a field path.

* Update core/src/program.rs

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

* Update core/src/repl/mod.rs

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

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-12 06:38:00 +00:00
Yann Hamdaoui
4a99f6a5f4
Note on polymorphic contracts and recursive records (#1175)
* First draft on polymorphic contracts and records

* Try to handle polarity flipping in arrow types correctly

* Update the note with a description of the issue and our process of resolving it

* Describe the problem in #1161 in more detail

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-11 12:59:34 +00:00
dependabot[bot]
0f3e0f0f1c
chore(deps): bump semver from 5.7.1 to 5.7.2 in /lsp/vscode-extension (#1444)
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 10:37:47 +00:00
Yann Hamdaoui
cd7eac27fe
Fix current version in manual and README (#1440) 2023-07-11 08:42:33 +00:00
Viktor Kleen
c6e98d849e
Fix release artifacts workflow failure (#1441)
An unintended and unnoticed side effect of reorganizing the workspace
crates seems to have been that crane puts the built static binary in a
subdirectory. Previously the derivation output was the static executable
directly. This throws off the release artifacts GitHub action.
2023-07-11 08:12:12 +00:00
Viktor Kleen
63bf9bb72e
Add term::make::static_access (#1438)
* Add `term::make::static_access`

Add a helper function to the `term::make` module to construct chains of
static record accesses.

* Provide a variant accepting an arbitrary `RichTerm` as the record

* Remove `term::make::static_access_`
2023-07-10 20:11:10 +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
jneem
7d9ac6b5ff
Add missing test for import invalidation (#1436) 2023-07-07 16:25:16 +00:00
jneem
7a0b170da0
Add notes on partial parsing (#1434) 2023-07-07 15:49:56 +00:00
Yann Hamdaoui
664c397aad
[Fix] Fix bad lexing of mutline string closing delimiter (#1435)
* StringEndMismatch -> StringDelimiterMismatch

* Remove unneeded lexer hack

We introduced a hack in the lexer because of some Logo's issue about
backtracking. Pre 1.0, the problem was related to sequences like:

```nickel
let x = "string" in m%%"some "%%{x}"%%m
```

Here, `"%%{x}` had to be interpreted as a double quote `"` followed by
an interpolation sequence `%%{`. The problem has been that backtracking
is required, because up to `{`, we don't know yet if we are lexing an
end delimiter `"%%m` or `"` followed by interpolation sequence. So we
added another token for this "ambiguous" (not literally) sequence, the
`CandidateQuoteInterpolation`. However, now that that the final `m` is
not required, a sequence of the form `"%%{` is either an end delimiter
followed by `{` (if there's as many `%` as in the opening delimiter), or
otherwise a verbatim `"%%{` (if there's less `%` than in the opening
delimiter). This can never be a double quote followed by an interpolated
sequence.

Thus, we can get rid of the ad-hoc `CandidateQuoteInterpolation` and
related special treatments, which makes the lexer simpler. This also get
rid of regression tests, because this subtelty had caused several issues
up to know, but they're now moot since the 1.0 syntax.

* Fix dangling reference in documentation
2023-07-07 15:38:56 +00:00
Yann Hamdaoui
422c4077a2
[Refactoring] Better separation of lexer mode (#1430)
* Lexer refactoring

Refactors the lexer for a better and cleaner separation between
different lexer modes, making it more readable and statically forbid
more invalid states. Also break the previously huge `Lexer::next` into
separate methods depending on the lexer mode.

* Fix comments

* Update core/src/parser/lexer.rs

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

* Update core/src/parser/lexer.rs

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-06 15:25:13 +00:00
Pim Snel
d918a7c02e
Add two examples: imports and foreach pattern (#1387)
* add install info using homebrew on macos

* Update README.md

Fix markdownlint-cli not being happy

* add two examples: imports and foreach pattern

* changes according to review suggestions

* Format new Nickel examples

* Add missing test annotations to examples

* Fix failing example annotations

* Make sure the test TOML parser doesn't choke

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
Co-authored-by: Viktor Kleen <vkleen+github@17220103.de>
2023-07-06 11:47:21 +00:00
jneem
ec3b9c4a35
Invalidate importers in NLS (plus a couple other import-related issues) (#1426)
* Add lsp-harness support for modifying files

* Fix a few related import issues.

- record imports correctly even if the imported file is already cached.
- avoid infinite recursion with circular imports. This previously
  worked only because the imports weren't correctly recorded.
- track reverse-dependencies also, and invalidate the LSP correctly.

* Small consistency cleanup

* Make better use of the typechecking and transforming states

* Remove boilerplate
2023-07-03 15:57:14 +00:00
Yann Hamdaoui
b145876281
flake.lock: Update (#1425)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/116b32c30b5ff28e49f4fcbeeb1bbe3544593204' (2023-06-21)
  → 'github:ipetkov/crane/4d350bb94fdf8ec9d2e22d68bb13e136d73aa9d8' (2023-06-29)
• Updated input 'flake-utils':
    'github:numtide/flake-utils/abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c' (2023-06-19)
  → 'github:numtide/flake-utils/dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7' (2023-06-25)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/3ae20aa58a6c0d1ca95c9b11f59a2d12eebc511f' (2023-06-23)
  → 'github:NixOS/nixpkgs/4bc72cae107788bf3f24f30db2e2f685c9298dc9' (2023-06-29)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/7807e1851d95828ed98491930d2d9e7ddbe65da4' (2023-06-20)
  → 'github:cachix/pre-commit-hooks.nix/522fd47af79b66cdd04b92618e65c7a11504650a' (2023-06-30)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/ec002586144fe0f48039dced270c188f0b8213ab' (2023-06-24)
  → 'github:oxalica/rust-overlay/ef95001485c25edb43ea236bdb03640b9073abef' (2023-07-01)
• Updated input 'topiary':
    'github:tweag/topiary/cba199369aca42cb00221a1ac0e27e9a02cf636f' (2023-06-21)
  → 'github:tweag/topiary/b4b3aa9f6fb6f8d220bcae033514327a32557786' (2023-06-30)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-07-03 09:06:39 +00:00
jneem
3975ac4fd9
Specify the test harness requests as toml instead of a custom format (#1424)
* Specify the test harness requests as toml instead of a weird custom format

* Update README
2023-06-30 18:46:41 +00:00
Yann Hamdaoui
21c8b849c5
Format benches as well using Topiary (#1423) 2023-06-30 15:50:04 +00:00