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
Taeer Bar-Yam
fe66a02bde
change nickel-nix to organist (#1691)
* change nickel-nix to organist

* Update README.md

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-10-20 10:09:34 +00:00
Björn Nilsson
933945d761
Fix doc, example code for pipe lacks prefix (#1692)
The example code for "pipe" doesn't compile because the method "pipe" lacks prefix. Fixed by changing "pipe" to "std.function.pipe"
2023-10-20 09:44:43 +00:00
Björn Nilsson
d61145b15b
Fix invalid example code in doc of blame_with_message (#1689)
Fix wrong method name: "std.contract.blame_with_message_message"
should be: "std.contract.blame_with_message"
2023-10-19 14:28:29 +00:00
dependabot[bot]
cde6290b08
chore(deps): bump rustix from 0.37.23 to 0.37.25 (#1688)
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.37.23 to 0.37.25.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.37.23...v0.37.25)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-19 09:54:03 +00:00
Yann Hamdaoui
2a727baaea
Get rid of most generated variables (#1679)
* add Closure node to AST

* Implement non-looping partial eq for Term

* Fix contracts app

* Use closure within records as well everywhere

* Fix double closurization

* Fix subst to update closurized attrs

* Fix type eq for closures

* More typecheck eq

* More work + formatting

* Get rid of share normal form + move Closurize to dedicated mod

* Accept new snapshots (error msg less noisy)

* Fix compilation warnings

* Fix various small TODOs left

* Cleaning comments and debug println

* Update documentation for new closurize approach

* Apply suggestions from code review

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

* Update core/src/closurize.rs

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

* Fix various code comments

* Post-rebase fixup

* Formatting + post-rebase fixup

* Restore array contract dedup fix messed up by rebases

---------

Co-authored-by: jneem <joeneeman@gmail.com>
2023-10-16 11:57:30 +00:00
Taeer Bar-Yam
859293a3e5
Make rustfmt work in match_sharedterm! (#1677)
* Make rustfmt work in match_sharedterm!

macros can have syntax that rustfmt doens't know how to deal with, so it
only triggers on macros that
1. are called with `()` or `[]` delimiters (not `{}`)
2. contain only valid rust syntax

our match_sharedterm! failed on both those counts, so this commit fixes
that. we move the `else` clause back inside the match statement as a
wildcard arm, and use the `match` keyword so that rustfmt understands
how we want the code formatted

* Update core/src/term/mod.rs

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

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-10-13 16:46:12 +00:00
Yann Hamdaoui
7e4ecd908c
Fix array closurization just forgetting common contracts (#1678)
* Fix array closurization just forgetting common contracts

* Reduce the number of iterator combinators
2023-10-13 15:23:22 +00:00
jneem
97e18afffb
Add cousin search to goto and hover (#1670)
* Add cousin search to goto and hover

* Code review comments
2023-10-12 21:51:34 +00:00
jneem
4dfd59a38c
First prototype of evaluation (#1672)
* First prototype of code action eval

* Update comment
2023-10-12 17:35:52 +00:00
Yann Hamdaoui
3edcb52ebb
Get rid of shallow_repr and print full terms (#1676) 2023-10-12 16:58:23 +00:00
Yann Hamdaoui
47823f582b
Array contract deduplication (#1674)
* Contract deduplication for arrays as well

* Fix reverted boolean check

* Fix other boolean error + clippy warning
2023-10-12 07:54:51 +00:00
Yann Hamdaoui
a3505a1e02
Print pretty diagnostic when a benchmark fails (#1675) 2023-10-11 16:29:59 +00:00
Yann Hamdaoui
f3ce8f3fab
Avoid quadratic behavior when optimizing contracts (#1673)
* Avoid quadratic behavior when optimizing contracts

* Formatting
2023-10-11 09:02:23 +00:00
Yann Hamdaoui
a80c20d115
Contract elision for static types (#1671)
* Extend record_op_kind to insertion and deletion

* Fix compilation errors

* Add specialized builtin contracts

* First take at optimizing static contracts

* Optimizing static contracts, second take

* More documentation

* Do not use has_field_all now that record_insert is fixed

* Apply suggestions from code review

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

* Fix clippy warning

* Fix cargo doc warning

* Fix manual snippets check

---------

Co-authored-by: jneem <joeneeman@gmail.com>
2023-10-10 10:23:05 +00:00
Yann Hamdaoui
94c25735d4
Fix record.update by making record.insert act consistently (#1669)
* Add variant of has_field that considers non-empty opt ones

* Extend record_op_kind to insertion and deletion

* Fix compilation errors

* Add regression test

* Pretty-printing of record operator variants

* Formatting

* Update core/src/term/mod.rs

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

---------

Co-authored-by: jneem <joeneeman@gmail.com>
2023-10-10 07:38:26 +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
jneem
8eae2c70fd
Add goto support for pattern bindings (#1665)
* Add goto support for pattern bindings

* Fix compilation after rebase
2023-10-05 00:59:11 +00:00
jneem
cc8f4e012f
Take the ancestor path into account when env-completing from uncles. (#1661)
* Track paths in the parent chain

* Don't offer the completion at the cursor

* Fix rebase issues

* Improve parent iter

* Fix docs
2023-10-05 00:05:03 +00:00
jneem
09e51fba6a
Remove/rename the Linearizer trait (#1663)
* Remove/rename the Linearizer trait

* TypeVisitor -> TypecheckVisitor
2023-10-03 22:04:23 +00:00
jneem
221215e48d
Add nls benchmarks (#1659) 2023-10-03 21:31:40 +00:00
Yann Hamdaoui
d904cc55d3
flake.lock: Update (#1662)
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/e35dcc04a3853da485a396bdd332217d0ac9054f' (2023-09-22)
  → 'github:NixOS/nixpkgs/8a86b98f0ba1c405358f1b71ff8b5e1d317f5db2' (2023-09-27)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/4f883a76282bc28eb952570afc3d8a1bf6f481d7' (2023-09-10)
  → 'github:cachix/pre-commit-hooks.nix/cb770e93516a1609652fa8e945a0f310e98f10c0' (2023-09-24)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/c0ad320f9aadcc3cb1e62794cb950fe243e077d6' (2023-09-23)
  → 'github:oxalica/rust-overlay/a4c3c904ab29e04a20d3a6da6626d66030385773' (2023-09-30)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-10-03 14:23:11 +00:00
jneem
7f1be1812f
Update lsp notes (#1660) 2023-10-02 14:29:20 +00:00
jneem
432983cd10
Nuke the linearizer (#1658)
* Convert hover

* WIP

* Slight cleanups

* Rename LinRegistry
2023-10-02 14:29:14 +00:00
Taeer Bar-Yam
c1798cd52e
build lalrpop in a separate derivation (#1637)
* build lalrpop in a separate derivation

* whoops

* get buildInputs from cargoArtifactsDeps

* small change to core (REVERT THIS)

* Revert "small change to core (REVERT THIS)"

This reverts commit 6284135ec8.

* don't build cargo artifacts for dev shell
2023-10-02 14:05:38 +00:00
Viktor Kleen
292c7ff6a0
Update 'RELEASING.md' (#1653)
The releasing guide still mentioned upload release artifacts for ARM64
manually. This is now obsolete with our ARM64 builder infrastructure.
2023-09-29 13:36:13 +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
Yann Hamdaoui
f06bda9239
Implement contract deduplication optimization (#1631)
* Duplicate contrat elision: first tentative

* Fix contract deduplication

The previous attempt wasn't fruitful, because we don't pass the initial
environment to the contract equality checker. This commit thread the
initial environment through the virtual machine and various functions to
make it available to the contract deduplicator

* Use contract deduplication for annotations as well

Use a special contract deduplication to avoid pretty printing many many
identical type annotations when evaluating. The actual contract
applications were already elided as far as evaluation is concerned, but
contracts annotations were still accumulated without deduplication.

* Rename elision->dedup which is better descriptive

* Fix clippy warning

* Fix cargo doc warnings

* Cosmetic improvements

* Mention idempotency assumption in the manual

* Update core/src/typecheck/eq.rs

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

* Fix REPL query not working anymore

* Update core/src/typecheck/eq.rs

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

* Formatting

* Fix clippy error

* Update core/src/program.rs

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

---------

Co-authored-by: Taeer Bar-Yam <Radvendii@users.noreply.github.com>
Co-authored-by: jneem <joeneeman@gmail.com>
Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-09-28 16:23:43 +00:00
Yuriy Taraday
f4a47920bb
Sign executables after patching revision on Darwin (#1636)
https://github.com/tweag/nickel/pull/1580 introduced patching of
resulting binary in a separate derivation that ends up with bad
(or missing) code signature which prevents it from running:

   % nix run
  zsh: killed     nix run

and Console.app revealing the reason:

  Exception Type:        EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
  Exception Codes:       UNKNOWN_0x32 at 0x00000001054e4199
  Exception Codes:       0x0000000000000032, 0x00000001054e4199

This change uses autoSignDarwinBinariesHook to sign the result that
seems to fix the problem.
2023-09-28 16:11:29 +00:00
Viktor Kleen
98824c5480
Honor nostdlib in customize mode as well (#1634) 2023-09-27 14:27:43 +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
jneem
86fb2fa961
Hover support without the linearizer (#1629)
* Convert hover

* Clean up some warnings

* Review comments
2023-09-26 22:41:38 +00:00
Viktor Kleen
0433886d11
Make eval an explicit subcommand and restructure the CLI somewhat (#1632)
* Make `eval` CLI explicit and remove `-f`

* Implement multiple file inputs as merging

* Use `add_string` instead of `add_term`

* `format` cannot create files anymore

* Update snapshot tests

* Separate customize mode from the `export` subcommand

* Decouple customize mode from export and make it available for every evaluation

* Disable an `unused_mut` warning

* Apply suggestions from code review

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

* Add a short option for `export --format`

* Update cli/src/eval.rs

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

---------

Co-authored-by: jneem <joeneeman@gmail.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-09-26 20:31:30 +00:00
Yann Hamdaoui
7dd104667a
flake.lock: Update (#1628)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/8b4f7a4dab2120cf41e7957a28a853f45016bd9d' (2023-09-04)
  → 'github:ipetkov/crane/3de322e06fc88ada5e3589dc8a375b73e749f512' (2023-09-23)
• Updated input 'crane/flake-utils':
    'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
  → 'github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384' (2023-09-12)
• Updated input 'crane/rust-overlay':
    'github:oxalica/rust-overlay/98ccb73e6eefc481da6039ee57ad8818d1ca8d56' (2023-09-03)
  → 'github:oxalica/rust-overlay/b87a14abea512d956f0b89d0d8a1e9b41f3e20ff' (2023-09-18)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/ace5093e36ab1e95cb9463863491bee90d5a4183' (2023-09-15)
  → 'github:NixOS/nixpkgs/e35dcc04a3853da485a396bdd332217d0ac9054f' (2023-09-22)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/f84bb1621574473d05e6ed79ba57a371d8ad8259' (2023-09-16)
  → 'github:oxalica/rust-overlay/c0ad320f9aadcc3cb1e62794cb950fe243e077d6' (2023-09-23)
• Updated input 'topiary':
    'github:tweag/topiary/7e6cb4f8b505eacee57aaf3c1ab0f3cf539da159' (2023-09-14)
  → 'github:tweag/topiary/8299a04bf83c4a2774cbbff7a036c022efa939b3' (2023-09-21)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-25 08:17:09 +00:00
Taeer Bar-Yam
9aa519f607
More CI speed (#1626)
* speed up nickelWasm

* build packages separately so all dependencies get cached

* comment
2023-09-23 23:41:06 +00:00
Erin van der Veen
83d189c0c1
Pin and update Topiary (#1624) 2023-09-22 13:44:47 +00:00
Viktor Kleen
f3d7430476
Remove the double contract application introduced in #1194 (#1625)
Because of #1228 we syntactically forbid contracts from containing free
type variables. This was implemented in #1271 and #1272. As a result,
the double contract application in #1194 became dead code. This PR
removes the `%dualize%` primop, the `dualize` field in `Label` and the
double application logic when constructing recursive environments for
records.
2023-09-22 13:44:10 +00:00
jneem
bcb0f71caa
Convert symbols request away from the linearizer (#1623) 2023-09-22 12:12:36 +00:00
Viktor Kleen
17adb43f87
Run a REPL session for nickel #repl snippets (#1615)
* Run a REPL session when checking `nickel #repl` snippets

* Adjust examples in the manual for new checks

* Fix some leftover error messages

* Address code review
2023-09-22 11:35:30 +00:00
Yann Hamdaoui
71d62de379
Assume -> ApplyContract (#1617)
* Assume -> ApplyContract

At the very beginning of Nickel, the duality between a type annotation and
contract annotation was reflected in their original naming, the assume
construct (contract annotation) and the promise construct (a type
annotation).

This terminology isn't used anymore, and isn't very telling for new
contributors. This PR get rid of old references to `Assume` and
`Promise`, and rename the `Assume` primitive operation to the more
boring but more explicit `ApplyContract`.

* Formatting
2023-09-21 17:33:53 +00:00
jneem
df15becc5d
Context completion (#1584)
* Add context completion

* Review comments

* Use either record completion or env completion, but not both

* Add test case for env completion

* Fix compilation
2023-09-21 14:33:53 +00:00
jneem
7937e5a175
Move goto away from the linearizer (#1610)
* Move goto away from the linearizer

* Add regression test for 881

* Add tests, add ident lookup

* Review comments

* Better name
2023-09-19 20:30:56 +00:00
Viktor Kleen
b02961324d
Testing Nickel snippets in the manual (#1611)
* First pass on testing snippets in `manual/syntax.md`

* Remove explicit `TestCase`

* Remove explicit panic

* Add test annotations to the manual

* Stop filtering markdown files

* Update `typing.md` example

* Apply suggestions from code review

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

* Some tweaks to multi line string examples

* Move from `nickel-...` info strings to `nickel #...`

---------

Co-authored-by: jneem <joeneeman@gmail.com>
2023-09-19 13:09:58 +00:00
gtsiam
365e14da36
Cleanup the code a bit (a lot) (#1595)
* Removed explicit state from Traverse trait

* Make clippy happy

* Consistent whitespace between documented items

I kept running into this while going through the codebase,
so I thought I'd fix it once and for all.

And no, I did not do this by hand. So I might have missed some cases.

* More formatting.

Mainly includes wrapping of comments to the 100 column mark,
as well as some more formatting on macros and strings.

* restore try_map_state in Traverse impl

* Removed IdentKind

It was technically only used in the PartialEq implmentation of Thunk.
Still, I don't think that had any effect.

* Fix doc comment

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>

---------

Co-authored-by: Taeer Bar-Yam <taeer.bar-yam@tweag.io>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-09-18 11:38:33 +00:00
Yann Hamdaoui
c1a2cb78a7
flake.lock: Update (#1612)
Flake lock file updates:

• Updated input 'flake-utils':
    'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
  → 'github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384' (2023-09-12)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b' (2023-09-08)
  → 'github:NixOS/nixpkgs/ace5093e36ab1e95cb9463863491bee90d5a4183' (2023-09-15)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa' (2023-08-17)
  → 'github:cachix/pre-commit-hooks.nix/4f883a76282bc28eb952570afc3d8a1bf6f481d7' (2023-09-10)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/1b4fad9dccece45c25b9ebda607427d69a8f1eae' (2023-09-09)
  → 'github:oxalica/rust-overlay/f84bb1621574473d05e6ed79ba57a371d8ad8259' (2023-09-16)
• Updated input 'topiary':
    'github:tweag/topiary/fe6083d2b7c762f5e8c63b9c79a8bd3ced12ea5d' (2023-09-09)
  → 'github:tweag/topiary/7e6cb4f8b505eacee57aaf3c1ab0f3cf539da159' (2023-09-14)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-18 08:02:11 +00:00
jneem
b2459d3172
Type-based completion in the new completer (#1577)
* Collect types into a table

* Type-based completion

This also adds a feature flag for turning off the old completer.

* Remove bogus file

* Explicitly visit type annotations

* Add a test for annotated types

* Only do one linearization traversal

* Fix docs, and avoid some clones

* Combine, and resolve metadata

* Add a test

* Slight improvements to the lsp spec

* Refactor

* Remove commented-out code

* Remove the confusing initial-env thing

* Complete the refactor, and document a little better

* Fix some rebase issues

* Clean up some unused code

* Remove obsolete doc

* Review comments
2023-09-15 19:19:45 +00:00
Yann Hamdaoui
508c492bfd
Update VSCode extension to 0.3 (#1609)
* Update VSCode extension to 0.3

* Formatting yarn.nix
2023-09-15 18:15:31 +00:00
Viktor Kleen
f28797ebf0
Update the version number in the manual introduction (#1607)
Update the version number to `1.2` and add a note to `RELEASING.md` so
we don't forget quite as often.
2023-09-15 09:11:14 +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