1
1
mirror of https://github.com/tweag/nickel.git synced 2024-10-06 08:07:37 +03:00
Commit Graph

3927 Commits

Author SHA1 Message Date
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
jneem
99531e68ad
Add support for completion requests to the lsp harness (#1404)
* Add support for completion requests to the lsp harness

* Fix warning

* Add missing tests

* Apparently completion order is non-deterministic
2023-06-30 12:37:18 +00:00
Yann Hamdaoui
6d6a74381a
Update the copyright holder (#1422)
Tweag has been acquired in 2022 by Modus Create. Update the various
licenses to reflect the new legal owner of this project's intellectual
property, which is Modus Create LLC.
2023-06-30 11:03:25 +00:00
foo-jin
f93b823c03
manual docs: fix mismatch between input command and its echo in the output (#1421)
* fix mismatch between input command and its echo in the output

* Update merging.md

---------

Co-authored-by: Viktor Kleen <vkleen+github@17220103.de>
2023-06-29 22:04:10 +00:00
Yann Hamdaoui
78dc3b580f
vscode-nickel: add logo and categories (#1420) 2023-06-29 16:14:17 +00:00
Viktor Kleen
5a1d17644d
Merge RecordOperand into Atom in the grammar (#1418)
Having separate `RecordOperand` and `Atom` productions turns out to be
unnecessary. As a positive side effect, this change fixes a parse error
discovered by @yannham:

```nickel
let foo = {bar = fun x => x} in %assume% foo.bar foo.bar
```

This error stemmed from an oversight in parsing prefix primops
where the second argument was required to be an `Atom` instead of
a `RecordOperand`.

It also improves the pretty printing of record access by reducing
unnecessary parentheses. For example, `std.string.length` was previously
printed as `(std.string).length`.
2023-06-29 15:10:37 +00:00
Viktor Kleen
f98bc15656
Make the pretty printer parenthesise negative numbers (#1417)
Have the pretty printer consider a `Term::Num(n)` an atom only if
`n` is positive. This code path is pretty tricky to hit, since a
unary minus gets changed into subtraction from `0` during parsing and
while evaluation can of course lead to negative numbers appearing in
`Term::Num`, the result typically doesn't require parentheses. However,
it is very easy to hit this path when trying to use the pretty printer
for Nickel code generation.
2023-06-29 13:28:24 +00:00
Yann Hamdaoui
f94e5af026
Fix LSP panic on requesting doc symbols from VSCode (#1416) 2023-06-29 11:57:57 +00:00
Yann Hamdaoui
f5f0ed5255
Various fixes to VSCode extension (#1413)
* Various updates to VSCode extension

Last fixes before publishing the VSCode extension on the VSCode market
place:
 - rename the parent containing directory from client-extension to vscode-extension
 - add a display name and a description
 - update the README, add links to non-Nix installation method
 - small fixes to the textmate Nickel grammar

* Update flake.nix after rename client-extension -> vscode-extension

* Improve the TextMate grammar, fix interpolation handling

* Fix highlighting in VSCode extension
2023-06-29 11:40:35 +00:00
Viktor Kleen
44f5eb610e
Make the pretty printer correctly escape field names (#1410)
* Make the pretty printer correctly escape field names

Previously, the pretty printer relied on `Ident::label_quoted` for
printing record field names. This function blindly placed an identifier
between quotes if it was deemed necessary. This produces incorrect
results if the identifier label itself contains quotes, for example.

* Move `Ident::label_quoted` into `pretty` as a freestanding function
2023-06-29 08:36:53 +00:00
Viktor Kleen
36425a45a8
Stop recompiling the quoting regex for printing identifiers (#1412)
As observed by @jneem we were constantly recompiling the regular
expression determining whether quoting an identifier is necessary.
This change improves the pretty printer performance on a non-synthetic
example by a factor of 3.
2023-06-28 14:38:38 +00:00
Viktor Kleen
ccf88b4099
Make the pretty printer understand let rec (#1411)
Fixes #1409
2023-06-28 14:30:10 +00:00
Simon Žlender
a4fad2b935
Full vscode extension (#1405)
* Full vscode extension

* Update lsp/client-extension/syntaxes/nickel.tmLanguage.json

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>
2023-06-28 09:24:39 +00:00
Yuriy Taraday
37ab9424d5
Upload docker image to GHCR in release workflow (#1347)
* Fix typo in release-artifacts workflow

* Enable cachix substituter in release-artifacts workflow

So that we don't rebuild everything during release.

* Upload docker image to GHCR in release workflow

Also add labels recognised by GHCR to the image.
2023-06-27 16:03:01 +00:00