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

3958 Commits

Author SHA1 Message Date
Viktor Kleen
ee6369af8b
Fix an off-by-one error in the LSP formatter (#1605)
* Fix an off-by-one error in the LSP formatter

According to [the LSP specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range)
the end of a text range in the protocol is exclusive. When executing
a formatting request in the language server we want to replace the
entire document with the formatted result, including any trailing
newlines. This means we need to specify the beginning of the line after
the very last line in the document as the end of the range of text to
be replaced.

This also fixes an annoying behaviour when formatting with NLS in Helix.
Previously, Helix would insist on selecting (what looked like) the
entire document on every formatting request. With this change, Helix
refrains from doing this.

* Update LSP snapshot test
2023-09-14 14:34:21 +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
Yann Hamdaoui
0eb45e8feb
Remove recursive priorities (#1600)
Recursive priorites were added pre-RFC005, where their semantics was
straightforward. Because metadata could appear anywhere, recursive
priorities (or also called push priorities) just amounted to have a
primop that pushed the priorities down a term, in one lazy step.

Since RFC005, this isn't possible anymore, because only record field can
hold metadata. It's now much more intricate to implement, because when
encountering a `rec force` at the field level, we first need to know if
there's any value able to receive it underneath this field to know if we
should attach it to the field or no. To know that, we might need to
evaluate the field first, and then decide.

Before sorting out both the new semantics and implementation, this
commit disable the syntax (but keep the rest of the machinery) from
1.2.0 so that we can do some design before shipping new recursive
priorities or scraping them entirely. Recursive priorities were
undocumented, and should have been disabled from 1.0.0, so it's not
considered a breaking change.
2023-09-13 13:04:19 +00:00
Viktor Kleen
7c9e771ddd
Statically merge partial record definitions (#1599)
* Use `try_str_chunk_as_static_str` instead of duplicating the logic

* Simplify `merge_fields`

* Statically merge piecewise record definitions

* Replicate the behaviour of `eval::merge::merge_fields` more closely
2023-09-13 08:51:26 +00:00
Taeer Bar-Yam
aa1d9335c7
print nice logs without losing speedup (#1594)
* print nice logs without losing speedup

* forgot stderr (the important one)
2023-09-12 15:54:11 +00:00
dependabot[bot]
e95ab85e79
chore(deps): bump aws-actions/configure-aws-credentials from 3 to 4 (#1596)
Bumps [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) from 3 to 4.
- [Release notes](https://github.com/aws-actions/configure-aws-credentials/releases)
- [Changelog](https://github.com/aws-actions/configure-aws-credentials/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws-actions/configure-aws-credentials/compare/v3...v4)

---
updated-dependencies:
- dependency-name: aws-actions/configure-aws-credentials
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 07:36:10 +00:00
Yann Hamdaoui
c79bc9e6f6
Fix LSP regression (#1583)
* Fix LSP not showing hover information

After the bidirectional refactoring (better separating the rules between
`infer` and `check`), the LSP was experiencing regressions, not showing
hover information in some cases, in particular within statically typed
blocks.

It turns out the separation between `infer` and `check` makes less clear
which function is responsible for adding the term to the linearizer:
sometimes it's `check`, sometimes it's `infer`, and it really depends on
the call graph and where each function is called from.

It turns out the previous implementation was adding many terms in
double, and this caused the initial regression observed.

Morever, fixing is made hard by the fact that `infer` now doesn't have a
type to provide right now for the linearizer: it first need to, well,
infer it. But the linearizer currently relies on AST nodes being visited
in order, so we can't either call to it whenever we want.

The situation seemed intricate enough that it was easier to separate
"visiting the term" from "amending the type of the term". This commit
thus adds a `retype` method to the `Linearizer` trait, plus some
id-related signature changes. Now, the typechecking code can add a term
to the linearizer as soon as it visits it, and set the type later. More
discipline has been introduced so that `check` and `infer` don't repeat
the same term visits anymore.

Doing so, this commit also cleans a bit the LSP implementation which was
very hard to change getting it right: `IdGen` in particular is gone
(which was maintaining a counter by hand in parallel to the
linearization's size, which was very error-prone, and if any mismatch
occurred, anything could happen). The truth is, the refactor should be
much more involved to make the code maintainable, but this commit is
just a fix for the 1.2.0 release to get out, and the linearizer is a
legacy component that will be scraped soon when the AST-based LSP will
reach feature parity with the linearizer.

* Add Hover capability to tests

* Add regression test for hover after bidir pull request

* Formatting and code clean-up

* Apply suggestions from code review

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

* Make retype calls less verbose

* Fix documentation dangling link

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-09-11 15:35:04 +00:00
Yann Hamdaoui
e412993ad8
flake.lock: Update (#1593)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/80432e15452e55a72403da3bc91837508a4ccae3' (2023-09-01)
  → 'github:ipetkov/crane/8b4f7a4dab2120cf41e7957a28a853f45016bd9d' (2023-09-04)
• Updated input 'crane/flake-utils':
    'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11)
  → 'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
• Updated input 'crane/rust-overlay':
    'github:oxalica/rust-overlay/b520a3889b24aaf909e287d19d406862ced9ffc9' (2023-08-07)
  → 'github:oxalica/rust-overlay/98ccb73e6eefc481da6039ee57ad8818d1ca8d56' (2023-09-03)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/aa8aa7e2ea35ce655297e8322dc82bf77a31d04b' (2023-09-01)
  → 'github:NixOS/nixpkgs/db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b' (2023-09-08)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/cdf3b15af70f2db17d5f47822f12016f1a89bd73' (2023-09-02)
  → 'github:oxalica/rust-overlay/1b4fad9dccece45c25b9ebda607427d69a8f1eae' (2023-09-09)
• Updated input 'topiary':
    'github:tweag/topiary/577fe940aa0b9dae478b463bddd1238e20f86e3a' (2023-08-24)
  → 'github:tweag/topiary/fe6083d2b7c762f5e8c63b9c79a8bd3ced12ea5d' (2023-09-09)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-11 09:04:33 +00:00
Taeer Bar-Yam
f0bf0beba9
Cache more (#1580)
* cache most of the work even if rev changes

* longer string for more reliable search.

* more recognizable dummyRev

* nickel-lang-static needs env

* appease nixpkgs-fmt

* copy meta to new derivation

* add comment
2023-09-11 08:53:20 +00:00
Viktor Kleen
be9269a443
Fix the release artifacts workflow (#1573)
* Fix a typo in the release workflow

This changes `os.matrix` into the correct `matrix.os`.

* Use `nodeRuntimes` as required by nixpkgs master, now

* Add nix settings to github-runner.nix

* Disable diffutils tests on arm64 musl

* Add dependencies on `start-runner` in `release-artifacts.yaml`

* Use `--log-format raw-with-logs` like in the CI workflow

* Use the correct cargo package for `nickel-static`

* Adjust linker flags on arm64 musl

* Add github cli and docker to `github-runner.nix`

* Combine static binary and docker image building jobs for caching

* Allow docker access for github jobs

* Use `docker buildx` to assemble the multiplatform image
2023-09-06 09:14:59 +00:00
Yuriy Taraday
c4bda4945e
Add meta.mainProgram to packages where appropriate (#1579)
Allows to `nix run github:tweag/nickel#...` to work as expected
with all packages as well as `pkgs.lib.getExe` returning proper paths.

Also switch to `getExe` with nickel packages in flake.nix
to demonstrate how nice it looks.
2023-09-06 08:49:31 +00:00
suimong
20ae8e4bdf
Implement curried dot operator (#1578)
* display icon for nickel file in vscode explorer

* implemented with DynAccess.

* added tests.

* Update grammar.lalrpop

move implementation inside CurriedOp

---------

Co-authored-by: Ben Yang <ben@ya.ng>
2023-09-06 07:43:04 +00:00
Viktor Kleen
c557118f8a
Exit with nonzero exit code on failure (#1576)
We previously just reported the error and then pretended to exit
successfully. With this change the process returns `ExitCode::FAILURE`
whenever it needed to report an error, and `ExitCode::SUCCESS`
otherwise.

Fixes #1575
2023-09-05 15:09:24 +00:00
dependabot[bot]
795e2677fe
chore(deps): bump actions/checkout from 3 to 4 (#1572)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 08:52:35 +00:00
dependabot[bot]
46860193a3
chore(deps): bump cachix/install-nix-action from 22 to 23 (#1571)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 22 to 23.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v22...v23)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 08:51:10 +00:00
Viktor Kleen
4b9062690d
Add a note about an AWS provider bug into infra/README.md (#1570)
I had forgot about this issue when writing the README originally.
2023-09-04 16:46:00 +00:00
Viktor Kleen
0dd1e10863
Add infrastructure for on-demand ARM64 runners on AWS (#1569)
* Add infrastructure for on-demand ARM64 runners on AWS

With this change, ARM64 release artifacts will be built automatically by
a GitHub workflow. Since GitHub doesn't offer hosted runners running on
ARM64, we're spinning up an EC2 spot instance on demand and run the jobs
building ARM64 artifacts there.

As a fun side note, the Terraform infrastructure code is written
entirely in Nickel.

* Remove unused `update-github` script

* Address comments from code review

* Address comments from code review
2023-09-04 15:41:23 +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
Yann Hamdaoui
80e9abe2a0
Handle override and help inputs in customize mode (#1563)
* customize mode conflicts: improve help messages

* Enablze overriding input fields with --override

* Fix unescaped [ in rustdoc
2023-09-04 15:10:23 +00:00
Yann Hamdaoui
72cd17ca47
flake.lock: Update (#1567)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/ef5d11e3c2e5b3924eb0309dba2e1fea2d9062ae' (2023-08-23)
  → 'github:ipetkov/crane/80432e15452e55a72403da3bc91837508a4ccae3' (2023-09-01)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5690c4271f2998c304a45c91a0aeb8fb69feaea7' (2023-08-25)
  → 'github:NixOS/nixpkgs/aa8aa7e2ea35ce655297e8322dc82bf77a31d04b' (2023-09-01)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/e90223633068a44f0fb62374e0fa360ccc987292' (2023-08-26)
  → 'github:oxalica/rust-overlay/cdf3b15af70f2db17d5f47822f12016f1a89bd73' (2023-09-02)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-04 11:16:39 +00:00
Yann Hamdaoui
d2316b6588
Revert to special casing the parsing of "%...%{ in multiline strings (#1566)
* Revert "[Fix] Fix bad lexing of mutline string closing delimiter (#1435)"

This reverts commit 664c397aad.

After more investigation, it turns out the original change made it very
annoying to interpolate something between double quotes, because it
conflicts with the multiline string end delimiter:

m%" "%{hello}" "%

After the reverted change, this wouldn't parse correctly anymore. One
can escape the first quote, but it's verbose and harder to read:

m%" %{"\""}%{hello}" "%

Although, we can't see any case where an interpolation sequence with a
heading quotes would have a valid meaning in the reverted commit's
model: it's always an error (applying a string to something). Thus, if
there's a sequence `"%{` in a string, there is no other meaningful
interpretation than this is a quote followed by an interpolation
sequence.

We thus decided to revert this change, although it derives a bit from
the most simple interpretation of parsing multiline string.

* Post-revert fixup: restore some comments and renamings

* Document multiline string parsing special case

* Update core/src/parser/lexer.rs

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

* Fix interpolation sequence in pretty printer

---------

Co-authored-by: jneem <joeneeman@gmail.com>
2023-09-04 10:12:22 +00:00
deotime
0080bf5266
Render hover documentation as Markdown in LSP (#1559)
* Render documentation as markdown in LSP

* Use unindent crate to retain code indentation

* Render contracts seperate from documentation

* Remove usages of unindent

* Remove unindent from `Cargo.lock`

---------

Co-authored-by: BuildTools <DeoTimeTheGithubUser@users.noreply.github.com>
2023-09-04 09:00:36 +00:00
jneem
8f2def66ff
Make an enum for different input sources (#1560)
* Make an enum for different input sources

* Fix doc link

* Review comments

* Add a comment
2023-09-01 17:26:09 +00:00
Yann Hamdaoui
b687ea3322
Get rid of uninformative generic notes (#1564)
Upon the failure of a higher-order contracts, we used to include quite
generic notes showing a plain illustration of the kind of higher-order
violation that happened. However, this text was totally generic (the
example didn't relate to the source code at all), quite verbose (around
4-5 lines of notes), and to be honest, not very helpful.

We now have good mechanisms to underline the right part of the function
contract that failed, together with customized label (e.g. "broken by the
caller"), which makes look like the original generic note aren't very
valuable.

This patch ditches those notes altogether.
2023-09-01 17:24:14 +00:00
deotime
f03213c997
(LSP) Import completion (#1561)
* Import completion

* Use `cache::normalize_path` instead of `fs::canonicalize`

* Add cached files as candidates for import autocompletion

* Rename `InputFormat::from_path_buf` to `InputFormat::from_path`

* Deduplication between server cached files and disk files

---------

Co-authored-by: deotime <89555032+DeoTimeTheGithubUser@users.noreply.github.com>
2023-09-01 16:18:41 +00:00
Yann Hamdaoui
3891689a43
Fix incomplete check of row constraints (#1558)
In an attempt to free the allocation of the constraints of a record row
unification variable that is being assigned to some record rows, the
code checking that row constraints are satisfied was removing the
constraints from the global state. Since rows are defined as linked
list, if the constraint wasn't violated on the first row, this function
would recursively call itself. But then the subsequent recursive calls
would try to get the constraints from the state again, to only find an
empty set constraints, as it has been removed just before. The function
thus wouldn't detect constraint violations happening in the tail of the
record rows.

This patch defines a subfunction which passes the initial constraints
along recursive calls, such that they aren't lost during recursion,
instead of trying to get them from the state again at each recursive
call.
2023-09-01 14:40:52 +00:00
Taeer Bar-Yam
b8e292d44b
set record arguments with -- (#1475)
* set arguments with --

Create term that merges command line arguments with program

* Move building the override term into `Program`
* instead of immediately evaluating argument values, use
`ImportResolver::add_string` to make them separate imports.
* Move CLI export into its own file
* Integrate record builder interface
* Make record field paths work correctly
* Evaluate annotations, too, for record normal form
* Make term interfaces a first class concept
* Stop printing terms on export

* Rename eval_for_doc to be less doc-specific

And expand the documentation at the same time.

* Augment FieldInterface with more data

Augment the field interface type - for freeform argument passing in the
CLI - with additional metadata, such as being optional or defined, taken
directly from the original field's metadata. Add a somehow heuristic
(but simple) `is_input` method, which decides if a field is an input and
should have a dedicated argument.

Minor reworking/renaming of other part of the CLI export code around
freeform arguments.

* Restore the path argument, add more documentation

* Use Field/FieldMetadata instead of custom types

In the CLI export function, instead of using a structure that mostly
mirror record fields, we directly use record fields to avoid code
duplication, although fields do carry a bit more information that what
we exactly need.

* Use query printer to render freeform args help

* Continue proper handling of overrides/inputs in CLI

* Fix eval_record_spine, add sources for CLI arguments

* Remove debug println, improve CLI freeform output

* Move around reporting code to error module

* Actually implement --override, add custom error messages

* Make overrides have a `force` priority

* Add some untested tests

* Small rewording of Ident documentation

* Post-rebase fixups + get rid of Merge trait

* Fix snapshot test runner for freeform args

* Fix CLI freeform snapshot tests

* Fix unused import warning

* Formatting

* Review pass, smallfixes and clippy fix

* Fix cargo doc warnings

* Fix 1.72 new clippy warnings

* Update snapshots after extra-args -> customize mode

* Move the Combine trait in its own mod

* Apply suggestions from code review

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

* Update core/src/term/make/builder.rs

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

* Remove questionable Option<> layer

* Update cli/src/export.rs

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

* Update cli/src/export.rs

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

* Apply suggestions from code review

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

* Add warning about usage of Label::default

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
Co-authored-by: jneem <joeneeman@gmail.com>
2023-09-01 09:57:30 +00:00
Taeer Bar-Yam
6764f23710
Speed up CI (#1549)
* cargo doc cache dependencies

* simplified version string (better caching)

* remove double suffixes (e.g. nickel-lang-doc-doc)

* partially revert pname changes

* buffer CI output

* speedup log printing without jank

* revert reverting some pname changes (+ fix)
2023-08-30 15:23:10 +00:00
suimong
c984a4a18a
display icon for nickel file in vscode explorer (#1556)
Co-authored-by: Ben Yang <ben@ya.ng>
2023-08-30 08:06:14 +00:00
deotime
dad9e54c43
Add multiline string support for VSCode autoclosing pairs (#1553)
* Add multiline string support for VSCode autoclosing pairs

* Support up to 4 % symbols

---------

Co-authored-by: BuildTools <DeoTimeTheGithubUser@users.noreply.github.com>
2023-08-29 16:06:05 +00:00
jneem
028695d91d
Two issues with incomplete input (#1550)
This fixes an off-by-one error in the handling of incomplete input.
It also makes import resolution in incomplete input more reliable --
previously it would only work when the file being opened is in the
current working directory.
2023-08-29 15:06:42 +00:00
jneem
6c635ea14b
Handle let, static access, and contract annotations in term-~ased completion (#1551) 2023-08-28 22:17:46 +00:00
Yann Hamdaoui
182568a8da
flake.lock: Update (#1545)
* flake.lock: Update

Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/7809d369710abb17767b624f9e72b500373580bc' (2023-08-12)
  → 'github:ipetkov/crane/ef5d11e3c2e5b3924eb0309dba2e1fea2d9062ae' (2023-08-23)
• Updated input 'flake-utils':
    'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11)
  → 'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/d680ded26da5cf104dd2735a51e88d2d8f487b4d' (2023-08-19)
  → 'github:NixOS/nixpkgs/5690c4271f2998c304a45c91a0aeb8fb69feaea7' (2023-08-25)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/598b2f04ed252eb5808b108d7a10084c0c548753' (2023-08-19)
  → 'github:oxalica/rust-overlay/e90223633068a44f0fb62374e0fa360ccc987292' (2023-08-26)
• Updated input 'topiary':
    'github:tweag/topiary/e30432a29b6d3bb606cbb09b022a5ad0598810dc' (2023-07-31)
  → 'github:tweag/topiary/577fe940aa0b9dae478b463bddd1238e20f86e3a' (2023-08-24)

* Run `cargo fmt`

* Fix new clippy lints

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-08-28 11:01:43 +00:00
Viktor Kleen
72992646d8
Fix some leftover instances of the old enum syntax in the manual (#1548)
* Fix some leftover instances of the old enum syntax in the manual

* Update doc/manual/syntax.md

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

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-08-28 10:24:25 +00:00
deotime
9e6dc8c27d
Add REPL config attribute (#1546) 2023-08-28 07:57:39 +00:00
deotime
77aac6666b
Fix "wich" typo in documentation (#1547) 2023-08-27 10:47:35 +00:00
Viktor Kleen
a153a9b618
Fix contract application order in let bindings and annotations (#1544)
* Fix contract application order in let bindings and annotations

In a let binding `let foo | A | B = ...` and in an infix contract
annotation `foo | A | B` the contracts `A` and `B` were actually being
applied in reverse order. That is, first `B`, then `A`. The contract
application order for record fields was still correct, however.

The root cause was the fact that there were two places with code that
merged separate annotations into a single annotation containing multiple
contracts. With this change, both spots call into the same code and I've
added regression tests to ensure the correct behaviour.

* `Annot` -> `Combine` in comments

* Add a snapshot test for let-binding contract order
2023-08-25 15:03:38 +00:00
jneem
26faf51e33
Resolve imports for incomplete inputs also (#1542) 2023-08-25 14:29:06 +00:00
Viktor Kleen
6b44916454
Overhaul and improve testing of the pretty printer (#1532)
* Move `Type` pretty printer test into `core/src/pretty.rs`

* Revamp pretty printer for `TypeF::Array`

* Start overhauling and testing the Type pretty printer

* Simplify pretty printer integration test

* Expand pretty printer integration tests to include stdlib

* continue overhauling the pretty printer

* Add tests for "let" pretty printing

* Ignore empty annotations in TypeAnnotation::attach_term

* Get almost all pretty printer tests to pass, missing `pass/strings/symbolic_strings.ncl`

* Use `Term::StrChunks` when desugaring symbolic strings

* Fix missing newlines in multiline strings

* Handle record patterns in let bindings

* `fun` pretty printing

* Update snapshot tests

* Fix pretty-printer dependent test cases

* Remove TODO comment

* Improve formatting for record fields with metadata

* Remove a redundant clone and some redundant calls to `pretty`

* Consistently use `%<stuff>` for internal values

* Address comments from code review

* Derive `Eq` for `OpPos`

* format other binary operators the same way as `&&` and `||`

* Add a comment about special unary operators

* Adjust grouping for field metadata annotations

* Simplify `Array` pretty printing code

* Document the lack of `indoc!` in `pretty_multiline_strings`
2023-08-25 08:50:32 +00:00
dependabot[bot]
85fdb7e754
chore(deps): bump DeterminateSystems/update-flake-lock from 19 to 20 (#1543)
Bumps [DeterminateSystems/update-flake-lock](https://github.com/determinatesystems/update-flake-lock) from 19 to 20.
- [Release notes](https://github.com/determinatesystems/update-flake-lock/releases)
- [Commits](https://github.com/determinatesystems/update-flake-lock/compare/v19...v20)

---
updated-dependencies:
- dependency-name: DeterminateSystems/update-flake-lock
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-25 08:01:33 +00:00
jneem
e848fc3e88
Initial handling of incomplete input in nls (#1541)
* WIP

* Working extraction and reparsing

* werks

* Add a test

* Remove unused linearization param

* Cleanups and docs

* Allow quoted strings to count as a single token

* Add some docs about the initial env
2023-08-24 22:15:24 +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
jneem
63e2c1d19c
Rename symbols to idents (#1539)
* Rename symbols to idents

* Missed a couple
2023-08-22 02:30:56 +00:00
jneem
4e3bca4a3d
Usage/definition lookup table (#1535)
* WIP

WIP

WIP

* Working unit tests checkpoint

* Pass some tests

* A slight refactor and better docs

* Update core/src/destructuring.rs

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

* Update lsp/nls/src/linearization/mod.rs

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

* Update lsp/nls/src/position.rs

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

* Also track bindings in records

* Fix warnings

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-08-21 16:48:44 +00:00
Viktor Kleen
db12730802
Refactor destructuring bindings (#1537)
* Simplify parsing of record destructuring

* Capture pattern destructuring errors as snapshot tests

* Record the destructuring contract in a label

This makes error reporting point at the destructuring instead of at a
fictitious `Dyn`.
2023-08-21 08:46:02 +00:00
Yann Hamdaoui
85067fba47
flake.lock: Update (#1527)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/1a551ae11bff91521cbeaebb8ca59a101c9f33f8' (2023-08-03)
  → 'github:ipetkov/crane/7809d369710abb17767b624f9e72b500373580bc' (2023-08-12)
• Updated input 'crane/rust-overlay':
    'github:oxalica/rust-overlay/99df4908445be37ddb2d332580365fce512a7dcf' (2023-08-03)
  → 'github:oxalica/rust-overlay/b520a3889b24aaf909e287d19d406862ced9ffc9' (2023-08-07)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/18036c0be90f4e308ae3ebcab0e14aae0336fe42' (2023-08-04)
  → 'github:NixOS/nixpkgs/d680ded26da5cf104dd2735a51e88d2d8f487b4d' (2023-08-19)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/3139c4d1f7732cab89f06492bdd4677b877e3785' (2023-08-05)
  → 'github:cachix/pre-commit-hooks.nix/7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa' (2023-08-17)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/18ee2a71de24273e4ad4503b5604532f0b53f382' (2023-08-05)
  → 'github:oxalica/rust-overlay/598b2f04ed252eb5808b108d7a10084c0c548753' (2023-08-19)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-21 07:54:51 +00:00
jneem
a55c6488b0
Sort out idents and positions (#1531)
* Make Symbol available.

Ident is a symbol plus a position. The position isn't intended to carry
any semantics -- it's really just for diagnostics -- so it's ignored in
comparison and hashing. This is mostly useful, but sometimes
(particularly in the LSP) we do want meaningful positions. Also, a lot
of code that completely doesn't care about the positions were carrying
one around "by accident."

This PR makes Symbol publicly available, and updates many usages of
Ident to use Symbol instead. There are probably more places that
Symbol could be used.

We do not yet introduce a Symbol + meaningful position type. That will
be done in a future PR, and probably restricted to the LSP.

* two more conversions

* Update core/src/eval/operation.rs

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

* The big rename

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-08-16 21:06:30 +00:00
Taeer Bar-Yam
ecf667ecda
actually cache dependencies (version string was invalidating the cache (#1530) 2023-08-16 12:58:25 +00:00
Viktor Kleen
3df013169b
Use the original unevaluated type and contract annotation in nickel doc (#1529)
* Use the original unevaluated type and contract annotation in `nickel doc`

With this change we no longer print evaluated types or contracts in
field annotations for `nickel doc`. Ever since `nickel doc` started
evaluating terms to address #1462 contract and type annotations would be
evaluated before reaching the documentation extraction stage. This means
they would be affected by program transformations and the result would
most likely be meaningless to the user.

Incidentally, `nickel query` already correctly used the original
unevaluated type for contract annotations but not for type annotations.
If a type annotation contains a `Term` as a `TypeF::Flat` variant, it
was possible to trigger the same undesirable behaviour:

```
❯ cargo run --bin nickel -- query foo <<<'{ foo : { x | Dyn, y } = {x = 1, y = 2} | { x | Dyn, y } }'
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/nickel query foo`
• type: let %182 = $dyn in { x | Dyn, y, }

Available fields
• x
• y
```

Fixes #1519

* Add a snapshot test against regressions
2023-08-14 13:34:14 +00:00
jneem
3b5e15109a
Add a position lookup table instead of doing traversal. (#1523)
* Add a position lookup table instead of doing traversal.

* Comments and clippy

* Update lsp/nls/src/position.rs

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

* Review comments

* Cleanups to the disjointness pass

* cmon rustdoc

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-08-11 22:25:19 +00:00