Commit Graph

1499 Commits

Author SHA1 Message Date
Sofia Faro
765d7e3f53
Throw ContractError in template precondition field (#9760)
* Throw ContractError in template precondition field

changelog_begin
changelog_end

* s/pre-condition/precondition/where relevant
2021-05-20 19:10:25 +00:00
Remy
a2775605d8
LF: change format of ArithmeticError message (#9761)
in order to follow LF conventional syntax.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-20 20:10:31 +02:00
Moritz Kiefer
3827f82a7a
Fix consumedBy in rollback nodes for scenario service (#9746)
changelog_begin
changelog_end
2021-05-20 12:07:13 +00:00
Sofia Faro
2ba5ca7ca2
Make DA.Assert throw AssertionFailed instead of GeneralError (#9747)
* Make DA.Assert throw AssertionFailed instead of GeneralError

changelog_begin

- [Daml Standard Library] `assert`, `(===)`, and other assertion functions (see DA.Assert) now use a new `CanAssert` typeclass constraint instead of `CanAbort`, in preparation for exceptions support.

changelog_end

* Add CanAssert instances for Script and Trigger.

* buildifier-fix

* update script test runner output

* Fix flag and add tests.

* update script test runner again
2021-05-20 12:01:50 +00:00
Miklos
f5c84a2aa4
Daml-LF: Damlification of Scala/Haskell files (#9666)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-20 09:52:33 +02:00
Remy
0d931b2f4b
Speedy: implement Arithmetic builtin exceptions (#9653)
part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 21:46:48 +02:00
Remy
40b23810d2
Compiler: clean convertion builtin name (#9724)
This follows up #9716

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 19:16:29 +02:00
Sofia Faro
1794a6f969
Refactor GenerateStablePackages (#9744)
* Refactor GenerateStablePackages

Summary of changes:

* Split GenerateStablePackages executable into a library (containing the stable package data) and an executable (that writes out the packages)

* Hook up data-dependencies test to the new library so we don't have to manually update the number of stable packages every time we add a stable package or release a new LF version.

changelog_begin
changelog_end

* buildifier-fix
2021-05-19 13:57:09 +01:00
Moritz Kiefer
bb5dd4cbf3
Fix locking of envScenarioContexts (#9736)
This fixes a race condition in our handling of scenario contexts. See
the comments for details. I verified with a bunch of extra logging
that this is what is actually failing in our tests. I’ll try to
upstream the logging separately since ideally I’d like to have that in CI.

I ran all integration tests with --runs_per_test=20 over night and
with this change I’m no longer able to get it to flake so dropping the
flaky marker.

fixes #6910

changelog_begin
changelog_end
2021-05-19 12:51:30 +02:00
Remy
fcbba1cd95
LF: rename convertion builtins to be more obvious (#9716)
The name of some builtins will be exposed as part of the Exception
message. This PR, try to make conversion builtins more consistent and
more obvious, before we could not rename those.

This is part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-19 10:11:26 +00:00
Sofia Faro
b55613be6c
Parallelize the data-dependencies test. (#9733)
* Parallelize the data-dependencies test.

It runs about twice as fast on my laptop (240s -> 120s) when allowed to
run tests in parallel. I'm not sure this will work or make a huge
difference when it comes to timeouts in CI, but it's worth a shot.

changelog_begin
changelog_end

* TASTY_NUM_THREADS := 3

* set bazel tag for test
2021-05-19 10:03:00 +00:00
Moritz Kiefer
6245e3456c
Drop damlc integration test todo (#9735)
I have no idea what this is supposed to mean. I suspect it’s leftover
from Daml < 1.1 or something like that.

changelog_begin
changelog_end
2021-05-19 11:26:46 +02:00
Moritz Kiefer
2dbfe433b4
Fix conversion of TryContextInfo in scenario service (#9731)
There are two options here:

1. We unwind to the nearest parent exercise. This is what I
implemented.
2. We show the try context. At first it seems like this exposes more
information but really it doesn’t. You cannot locate the try so it’s
fairly meaningless.

A solution here could be to show the full context
stack instead but that’s a separate issue which I do not want to
tackle atm.

changelog_begin
changelog_end
2021-05-19 09:15:33 +02:00
Remy
a6c7b86afc
LF: Drop support of TO_QUOTED_TEXT_PARTY (#9721)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-18 21:29:04 +02:00
Sofia Faro
9d23b4337f
Split DA.Internal.Exception.Types into three packages. (#9709)
* Split DA.Internal.Exception.Types into three packages.

I think this is a good idea because it means the user can disambiguate between these modules in daml. All three types define a `message` field, so if the programmer wants to refer to the field for one of these types specifically, it's nice to have a canonical way to disambiguate them (by module name).

Also the module names show up in the error message for uncaught exceptions. These names are a bit nicer than "DA.Internal.Exception.Types".

Decoupling these types just sounds like a good idea going forward.

changelog_begin
changelog_end

* buildifier-fix

* update isInternal

* Update tests

* Use more general pattern in CommandServiceIT

* Update DarReaderTest
2021-05-18 18:42:11 +00:00
Remy
55c36cc93e
Compiler: drop BEToTextBigNumeric in favor of BEToText (#9728)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-18 14:49:03 +00:00
Sofia Faro
2a2c745978
Implement name collision check for type synonyms. (#9723)
Part of #3616

changelog_begin
changelog_end
2021-05-18 13:56:02 +01:00
Moritz Kiefer
0a1d00d1b3
Canonicalize junit output path (#9710)
fixes #9646

changelog_begin
changelog_end
2021-05-18 12:34:53 +02:00
Remy
d4fca0305b
LF: Change error exception for Arithmetic builtins (#9692)
This PR is a priliminary step toward making Arithmetic Builtin
throwing proper Daml Excetpions.

This is part of #8020.

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-18 10:41:44 +02:00
Remy
fc745f2224
LF: clean shifting BigNumeric builtin (#9704)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 19:26:14 +02:00
Sofia Faro
7a97d88f42
DA.BigNumeric: Split shift, add roundToNumeric. (#9702)
* Split BigNumeric.shift, add BigNumeric.roundToNumeric.

This is based on some feedback we received. The shift direction was
counterintuitive so splitting `shift` into `shiftLeft` and `shiftRight`
makes this more explicit. It's also convenient to have a function that
combines the rounding and casting of BigNumeric to a specific Numeric
scale.

changelog_begin

- [Daml Standard Library] `DA.BigNumeric.shift` has been split into
  `DA.BigNumeric.shiftLeft` and `DA.BigNumeric.shiftRight`.
  `DA.BigNumeric.roundToNumeric` is introduced, for rounding and
  converting a BigNumeric to a Numeric in a single move.

changelog_end

* hide `round` in DA.BigNumeric

* Simplify error docs, add doctest for roundToNumeric

* Update BigNumeric test
2021-05-17 15:43:27 +00:00
Sofia Faro
1edb110f99
Fix simplifier safety for AnyExceptionMessage (#9707)
* Fix simplifier safety for AnyExceptionMessage

This highlights the danger of shifting definitions. At some point this safety was correct (AnyException contained the message string directly, "throw" took a message argument), and then we decided to have AnyException call a function associated with the type (to speed up exception throwing & catching), and this safety became incorrect :-(

changelog_begin
changelog_end

* s/may crash/may throw
2021-05-17 14:04:23 +00:00
Sofia Faro
0ab37b3774
Use new exception builtins in stdlib. (#9703)
* Use new exception builtins in stdlib.

changelog_begin
changelog_end

* hide message fn

* be very explicit

* s/Just/Some
2021-05-17 13:22:30 +00:00
Sofia Faro
b19c8f2a7c
Drop sanitize, add MagicHash in data-dependencies. (#9698)
The only thing `sanitize` does is mangle the names of identifiers and
types that end in `#`. That can't be a good thing. This PR removes
sanitize and enables MagicHash in data-dependencies, meaning names can
end in `#` without causing issues. (MagicHash also enables unboxed
literals, but that doesn't matter here.)

In practice, sanitize was only affecting `GHC.Prim.Void#`, which we
define because GHC sometimes references it. AFAIK there's no other
use of `#` in the standard library that we don't rewrite away.

changelog_begin
changelog_end
2021-05-17 10:10:00 +00:00
Miklos
395ff58eec
Damlification of Bazel files (#9670)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 11:41:44 +02:00
Miklos
cd9933328a
runtime: Damlification of Scala files (#9668)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 10:28:50 +02:00
Sofia Faro
6568336588
Lift constraint tuples up to a type synonym in data-dependencies. (#9687)
* Lift constraint tuples up to a type synonym in data-dependencies.

Fixes #9663 and adds a regression test.

GHC was crushing the constraint tuples into regular constraints, so the function caller no longer matched the original LF API. By lifting the constraint tuple into a type synonym, we eliminate this effect.

Part of the issue here is that we're losing the original constraint tuple type synonym during LFConversion. I'll open a separate issue for that, since I think it's also worth fixing that going forward.

(Preserving the type synonym would solve this issue for newly compiled packages. By contrast, the fix in this PR works for both new and old packages.)

changelog_begin

- [Daml Compiler] Fixed a data-dependencies bug where functions in a data-dependency that used a constraint tuple constraint (e.g. `Template t`) could not be directly invoked.

changelog_end

* use foldl'

* Fix exception test that spawned this mess
2021-05-14 14:22:47 +01:00
Jost Berthold
6629aab009
DEL-8479 tag LF libs for SDK 1.13 release (#9680)
* DEL-8479 bump lib versions to 0.1.13

* HOTFIX use newer resolver lts-17.11 and protobuf from hackage


changelog_begin
changelog_end
2021-05-14 16:38:20 +10:00
Sofia Faro
55abd0b7f0
Add a data-dependencies test for user-defined exceptions (#9659)
* Add a data-dependencies test for exceptions.

Part of #8020

This only tests that (catching & throwing) user-defined exceptions compiles as expected across data-depndencies.

Once they're supported, we should also add a test involving throwing a built-in exception (arithmetic or contract errors) in the data-dependency and catching them in main.

changelog_begin
changelog_end

* Fix weird formatting

* Rename test case

* syntax error

* fix easy problems

* Work around constraint tuple bug.
2021-05-13 15:40:29 +01:00
Stephen Compall
ca9e89b3da
check whether collection.compat is unused when compiling for Scala 2.12 (#9604)
* check whether collection.compat is unused when compiling for Scala 2.12

- Instead of always suppressing warnings for collection.compat._,
  we should only do it for Scala 2.13

- We can also reduce boilerplate by automatically adding this
  option when both silencer_plugin and collection-compat are
  present

CHANGELOG_BEGIN
CHANGELOG_END

* remove unused import

* remove another unused import

* remove even more unused imports

* missed compat dependency

* more missed compat dependencies

* missed compat dependency

* use scala_deps in scaladoc_jar

- #8423 inlined the major version expansion, but this seems to
  have been prior to proper support by scaladoc_jar

* restore custom handling of participant-integration-api

- fixing scaladoc_jar isn't worth it for a single case, as with
  deps vs scala_deps
2021-05-11 21:54:14 +00:00
Moritz Kiefer
c3d79d4656
Allow OverloadedLists in data-dependencies (#9636)
* Allow OverloadedLists in data-dependencies

changelog_begin
changelog_end

* expand on rebindable syntax

changelog_begin
changelog_end
2021-05-11 12:11:14 +02:00
Remy
0d1f3db8a4
LF: refactor builtin exceptions in Speedy (#9605)
follow up #9595.

part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-11 09:18:27 +02:00
Moritz Kiefer
d6d01b04ef
Swap order SEScopeExercise and SBUBeginExercise (#9621)
* Swap order SEScopeExercise and SBUBeginExercise

SEScopeExercise pushes the KCloseExercise continuation. However, the
corresponding transaction node is only inserted when SBUBeginExercise
finishes. This causes an issue if SBUBeginExercise crashes/throws an
exception.

changelog_begin
changelog_end

remove weird comment

changelog_begin
changelog_end

Reenable another test

changelog_begin
changelog_end

* Update failing test

changelog_begin
changelog_end
2021-05-10 19:25:55 +02:00
Sofia Faro
9242540022
Make error throw a GeneralError. (#9613)
* Make error throw a GeneralError.

As well as abort, fail, etc.

changelog_begin
changelog_end

* keep the error message when you have an unhandled error in scenario

* Disable crashing opsem tests for now.

* Update CommandServiceIT regex pattern.

* Put | in wrong place :-|

* forgot to escape "

* Illegal repetition!
2021-05-10 10:47:43 +01:00
Moritz Kiefer
4c1fbeb194
Add duplicate contract key checks to Speedy (#9607)
changelog_begin
changelog_end
2021-05-07 17:24:42 +00:00
Moritz Kiefer
89e46bf90b
Address security vulnerabilities in //compiler/daml-extension (#9615)
changelog_begin
changelog_end
2021-05-07 14:54:54 +02:00
Sofia Faro
fd62671e0b
Introduce SINCE-LF-FEATURE in integration tests. (#9616)
* Introduce SINCE-LF-FEATURE in integration tests.

The idea being to avoid hardcoding LF feature version numbers in the integration tests, so we don't have to remember to update them once a feature comes out of 1.dev

changelog_begin
changelog_end

* Show list of features on error
2021-05-07 12:27:12 +00:00
Sofia Faro
22ba5fddd2
Remove builtin exception types from protobuf and ASTs. (#9595)
* Remove builtin exception types from protobuf/AST.

changelog_begin
changelog_end

* Remove builtin exxceptions from protobuf/ast.

* remove unecessary s"

* scalafmt

* syntax error

* Add TODOs

* Apply suggestions from code review

Co-authored-by: Remy <remy.haemmerle@daml.com>

* Add AnyException builtins in typing spec.

* Update protobuf "Next id" comment.

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-05-06 21:26:12 +00:00
Moritz Kiefer
5aa54017eb
Drop todo for conversion of exception primitives (#9597)
While there might be nicer ways to do this, the current way is
consistent what we do for example with `create` which seems pretty
comparable and the check that `ty1` is an exception type happens in
the LF typechecker (again consistent with how we check for create that
the type is a template type) so this seems fine.

changelog_begin
changelog_end
2021-05-06 17:09:44 +02:00
Moritz Kiefer
de80a6dc60
Drop ValueBuiltinException (#9576)
As discussed, we don’t want to expose this via serializable values at
least for now (and it’s not exposed on the ledger API anyway) so this
PR drops the type.

changelog_begin
changelog_end
2021-05-05 12:32:58 +02:00
Moritz Kiefer
c570a5ff2c
Fix BigNumeric literal validation (#9562)
* Fix BigNumeric literal validation

The calculation of scale is off and fails on
0.123456 which turns into 1929 % 15625.

I don’t really like the implementation here but I’m failing to come up
with a more direct way to calculate it. I blame the fact that I
haven’t had coffee yet.

changelog_begin
changelog_end

* Address review comments

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>

* Fix test

changelog_begin
changelog_end

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-05-04 14:55:00 +02:00
Moritz Kiefer
312ed6979c
Fix numeric docs for shift and add a few tests (#9564)
changelog_begin
changelog_end
2021-05-04 11:35:17 +00:00
Robin Krom
84359ffa73
nested record updates (#9505)
* record dot updates: update to new ghc-lib-parser

This updates the ghc-lib-parser library featuring record dot updates and
adds tests for the new feature.

CHANGELOG_BEGIN
CHANGELOG_END

* update snapshot after pin on windows

* added a test for error locations

* nested record puns test

* update ghc commit

* update of stack dependencies (linux)

* update stack snapshot(windows)
2021-05-03 16:27:01 +02:00
Sofia Faro
a5d1e185ab
Move builtin exceptions to a stable package. (#9523)
* Move builtin exceptions to a stable package.

This PR moves the built-in exceptions (GeneralError, ArithmeticError, ContractError) to a stable package in daml-prim, in preparation for removing them from LF proper.

Part of #8020.

changelog_begin
changelog_end

* Update tests

* rename the module

* couple that got away

* update hash

* Update dar reader test.

* typo

* questionable lint
2021-04-29 10:19:20 +00:00
Samir Talwar
e1af564bcc
Switch from @silent to @nowarn. (#9498)
* Switch from `@silent` to `@nowarn`.

This annotation is native to Scala 2.12.13+ and 2.13.2+. It replaces
most usages of `@silent`.

I had to get creative about a couple of use cases that didn't work.
Specifically:

  1.  Suppressing deprecation warnings works, but Scala 2.12 erroneously
      complains that the `@nowarn` is unnecessary.  I had to suppress
      this warning too with `-Ywarn-unused:-nowarn`.
  2.  I can't seem to suppress the warning, "The outer reference in this
      type test cannot be checked at run time." Instead, I have
      refactored the code to remove the warning.

We still need to use the silencer plugin to suppress some warnings about
unused imports (because of compatibility between Scala 2.12 and 2.13),
but this means we no longer need the library, and therefore it is not a
transitive dependency that downstream consumers need to worry about.

CHANGELOG_BEGIN
CHANGELOG_END

* Add some comments around `@nowarn` support.

* language-support/scala: Fix a warning suppression.

* Revert to the default warnings.

Compatibility was complaining.
2021-04-26 19:46:14 +00:00
Moritz Kiefer
4e1c5fedb3
Check visibility for by-key operation of local contracts (#9470)
* Check visibility for by-key operation of local contracts

fixes #9454

I tried out two approaches for this:

1. The one here where we add a new callback. This has the advantage
   that the engine remains oblivious to visibility checks. They are all
   done outside and the engine doesn’t even know about the reading
   parties.
2. Make the engine aware of the reading parties. A start of that is in
   #9458.

Both work in principle but I ended up going for 1 in the end. Doing
half of the visibility checks outside the engine and half inside just
seems worse than the current state.

changelog_begin

- [Daml Engine] Fix a bug where it was possible to
  fetch/lookup/exercise a local contract by key even if the reading parties
  are not stakeholders. See #9454 for details.

changelog_end

* Disable new test on Canton

changelog_begin
changelog_end

* Exclude from compat tests

changelog_begin
changelog_end

* s/LocalLookup/LocalFetch/

changelog_begin
changelog_end

* Address review

changelog_begin
changelog_end
2021-04-22 21:39:12 +02:00
Moritz Kiefer
524d43eacb
Support rollback nodes in scenario service (#9410)
This focuses on the semantics rather than the display in Daml Studio
which needs more work (and seems not all that important at this
stage).

This already uncovered a bug which also applies outside of scenarios:

The consumedBy field was not affected by rollbacks which breaks the
mustBeActive check in partial transactions. This PR fixes this by
caching on try and restoring on rollback.

changelog_begin
changelog_end
2021-04-22 12:52:33 +02:00
nickchapman-da
ffdb71d32a
Create rollback nodes (#9367)
* recode contractValuesInOrder in RollbackTest

* first stab at creating rollback node; tests updated

* Rollback nodes are transparent for the cid scheme

* deativate failing exception tests

changelog_begin
changelog_end

Co-authored-by: Remy Haemmerle <Remy.Haemmerle@daml.com>
2021-04-14 18:51:35 +02:00
Sofia Faro
1627b70427
Pattern matching for RoundingMode (#9381)
* Pattern matching for RoundingMode

- Fix the order of RoundingMode constructors in GHC.Types to match the LF built-in order. Try to match this order across all code and documentation, and added a test for this order.
- Implements pattern matching for RoundingMode. The added machinery could also be useful for solving #5753 in the future.
- Implements Show instance for RoundingMode. (Mainly so we can use them in tests.) Moved BigNumeric Show instance to GHC.Show.

changelog_begin
changelog_end

* mkScrutineeEquality typo

* fix roundingModeLiteralMap order

* Use custom type for building case body

* Factor GeneralisedCaseAlternative into GeneralisedCasePattern

* Fix finalize

* Remove unused bindings
2021-04-13 15:47:16 +00:00
Robin Krom
8480032d85
daml package: bump timeout for tests (#9377)
CHANGELOG_BEGIN
CHANGELOG_END
2021-04-12 09:45:32 +00:00
Robin Krom
f84b6abc05
daml build: add a --access-token-file for remote dependencies (#9358)
* daml build: add a --access-token-file for remote dependencies

This adds a `ledger.access-token-file` field in the `daml.yaml` project
file and a `--access-token-file` flag to `daml build` to authorize
querying/fetching of remote dependencies.

CHANGELOG_BEGIN
[daml build] A new flag `--access-token-file` is added for the `daml
build` command. It allows the specify the path to an access token to
authenticate against the ledger API. This is needed if the project
depends on a remote Daml package hosted on such a ledger. Alternatively,
the path to the token can also be specified in the `daml.yaml` project
file under the `ledger.access-token-file` field.
CHANGELOG_END
2021-04-08 23:20:52 +02:00
Richard Kapolnai
587bff2b9d
Fix comment formatting in state (#9359)
* fix Daml comments in DA.Action.State.Class.ActionState
changelog_begin
changelog_end

* fix typo

* add backticks
2021-04-08 12:14:50 +00:00
Moritz Kiefer
bac3521be9
Add sqrt to DA.Math (#9346)
* Add sqrt to DA.Math

fixes #9149

Not a huge fan of DA.Math but this seems like a nicer fix to #9149
than removing the lint.

changelog_begin
changelog_end

* revert change to lints

changelog_begin
changelog_end
2021-04-07 17:25:45 +02:00
Sofia Faro
06701f7d5e
Expose rounding modes as constructors + add BigNumeric docs. (#9336)
* Expose rounding modes as constructors.

This PR exposes the rounding modes as constructors for RoundingMode. Pattern matching for RoundingMode is not implemented and not critical (will open a separate issue).

This PR also adds documentation for BigNumeric.

changelog_begin
changelog_end

* Fix rounding mode literals

* Update data-types.rst

* expose constructors

* expose constructors (part 2)

* Update compiler/damlc/daml-prim-src/GHC/Types.daml

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Try to improve `Numeric n` description.

* Add message for RoundingMode match and a test.

* Restrict RoundingMode test to 1.dev

* Update version numbers to 1.13

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-04-07 14:58:31 +00:00
Remy
568a8528a8
LF: release preview of LF 1.13 (#9329)
CHANGELOG_BEGIN
- Daml: (Early access) add support for BigNumeric
CHANGELOG_END
2021-04-07 12:42:54 +02:00
Sofia Faro
e84a94e8c1
Update issue number for BigNumeric Divisible instance. (#9334)
changelog_begin
changelog_end
2021-04-06 16:37:16 +00:00
Sofia Faro
14b062ce40
Syntax highlighting for exceptions. (#9318)
* Syntax highlighting for exceptions.

* Add `exception`, `try`, and `catch` as keywords.
* Add `throw` as function name.

changelog_begin
changelog_end

* Updated wrong language definition.

* Add 'message'
2021-04-06 09:45:12 +01:00
Sofia Faro
f2e0464227
Add BigNumeric literals in Daml. (#9289)
* Add BigNumeric literals in Daml.

Adds support for BigNumeric literals (when available). Only literals that will fit in a single Numeric are supported for now.

I introduced the `IsNumeric t` typeclass because this is an easy way to restrict `fromRational` without moving it into its own typeclass. (Moving it into a typeclass causes some gnarly problems with the specializer -- it starts creating references to GHC.Real in an attempt to optimize the invocation, and that's a problem because  GHC.Real doesn't exist in LF.)

I then added the "fromNumeric" and "fromBigNumeric" conversion functions in that class, since they seem really convenient, and it also means we could in the future make it so that any type that implements `IsNumeric` gains literals (via Numeric or BigNumeric literals). This would improve a lot of Numeric code, since it eliminates the need to annotate types so often! But for now only Numeric and BigNumeric literals are supported.

changelog_begin
changelog_end

* lint

* Add test for too large bigNumeric
2021-03-31 13:39:39 +00:00
Robin Krom
b4bda47e7d
remote pkgs: resolve package names in data dependencies via ledger (#9270)
* remote pkgs: resolve package names in data dependencies via ledger

This implements part 3) of #8976.

This adds the ability to specify package names/versions in daml.yaml in
the data-dependencies stanza. They are being resolved via the project
ledger and a daml.lock lock file.

CHANGELOG_BEGIN
  [remote dependencies] Package names and versions, as well as package
  ID's are allowed in the `data-dependencies` list of `daml.yaml`. These
  packages are fetched from the project ledger. The auto-generated
  `daml.lock` file keeps track of the package name/version to package
  ID's resolution and should be checked in to version control of the
  project.
CHANGELOG_END

* added docs

* Update compiler/damlc/lib/DA/Cli/Damlc/DependencyDb.hs

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Update docs/source/daml/reference/packages.rst

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* suggestions

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-03-31 15:37:36 +02:00
Andreas Herrmann
4edefbc2d9
Generate DALFs for data-dependencies in Daml script dump (#9265)
* Don't mark dalfs in data-dependencies as main dalfs

This causes the LF version consistency check to fail on DALF data
dependencies that were generated with a different LF version and also
occur in dalfsFromDependencies. E.g. a dalf like `daml-prim-DA-Types`
triggers this issue.

changelog_begin
- [DAML Compiler] DALFs in data-dependencies that are imported directly
  now require corresponding `--package` flags to make them visible. The
  reason for this is that DALFs that are data-dependencies are no longer
  treated as main DALFs.
changelog_end

* Daml script dump write DALFs instead of DARs

Produces DALFs for dependencies and adds them to the data-dependencies.
Package flags for main DALFs are added to the build options.

* Update test-cases

* address review

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-03-31 10:14:56 +02:00
Moritz Kiefer
eb91dcf853
Only walk list once in splitAt (#9275)
* Only walk list once in splitAt

No idea if that makes a significant difference anywhere but walking
the list twice is definitely not faster.

changelog_begin
changelog_end

* Avoid hardcoded locations in tests

changelog_begin
changelog_end
2021-03-30 19:26:59 +02:00
Remy
6c1f404c7d
LF: Add TO_TEXT_BIGNUMERIC (#9276)
This is part of #8719.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-30 13:31:42 +02:00
Sofia Faro
27dbf0bef9
BigNumeric in the stdlib cleanup. (#9253)
* Cleaning up BigNumeric somewhat.

Done in this PR:
- Moved BigNumeric and RoundingMode to GHC.Types to be alongside Numeric and Decimal
- Additive, Multiplicative, Number instances for BigNumeric
- Eq, Ord instances for BigNumeric and RoundingMode

Todo:
- BigNumeric literals in Daml
- Constructors and pattern matching for rounding mode
- Better documentation

changelog_begin
changelog_end

* remove ^ for now

* define (^) because it's required

* Error in (^) for negative powers.

* better error message

* import fromString and error

* Add -Wno-unused-imports because of compiling to different versions.

* add (fromString) and (error)

* Update bignumeric test.
2021-03-29 13:33:36 +00:00
Moritz Kiefer
077d8da58f
Upgrade nixpkgs (#9248)
* Upgrade nixpkgs

changelog_begin
changelog_end

* ghc bump

changelog_begin
changelog_end

* more native buildinputs

changelog_begin
changelog_end

* Switch assignment

changelog_begin
changelog_end

* update lockfile

changelog_begin
changelog_end

* Revert "Switch assignment"

This reverts commit af6d25120b.
2021-03-26 21:26:40 +01:00
Moritz Kiefer
767e47fb94
Make occurence occur less often (#9258)
changelog_begin
changelog_end
2021-03-26 21:17:09 +01:00
Remy
181afe4607
Daml: Add basic support for BigNumeric in 1.dev (#9243)
CHANGELOG_BEGIN
CHANGELOG_END
2021-03-26 09:00:05 +01:00
Sofia Faro
f670daec6f
Add try-catch syntax. (#9203)
* Add try-catch syntax.

changelog_begin
changelog_end

* ++

* +++

* ++[>++<-]>

* ++[>++<-]>+

* ++[>+++<-]>

* ++[>+++<-]>+

* ++[>++++<-]>

* Use try-catch in ExceptionSyntax test

* add a syntax test for try catch

* +++[>+++<-]>

* +++[>+++<-]>+

* enable test4

* typo

* add a test with multiple patterns and guards

* final patch sha

* update stack snapshot (unix)

* update stack snapshot (win)
2021-03-25 13:36:09 +00:00
Moritz Kiefer
39377e88d6
Add unique(on)? to DA.List.BuiltinOrder (#9233)
changelog_begin

- [Daml Stdlib] Add unique(on)? as more efficient versions of unique,
  uniqueOn using the builtin daml-lf ordering.

changelog_end
2021-03-25 13:14:15 +01:00
Moritz Kiefer
a8cb170ed1
Add Ord instances for Any(Template|Choice|ContractKey) (#9224)
* Add Ord instances for Any(Template|Choice|ContractKey)

This is useful to use them as map keys. We have a large application
that currently does a linear search over a potentially very large set
of contracts which can be replaced with a map lookup with this.

changelog_begin
changelog_end

* Match builtin equality for Any(Template|Choice|ContractKey)

changelog_begin
changelog_end

* Use primitives directly

changelog_begin
changelog_end
2021-03-24 16:33:14 +01:00
Moritz Kiefer
81c710f8fc
Add DA.List.BuiltinOrder module (#9226)
This provides variants of `dedup*` and `sort*` which rely on Daml-LF’s
builtin ordering (using Map internally). I don’t have microbenchmarks
but even in macrobenchmarks this is a measurable improvement which
isn’t particularly surprising.

changelog_begin

- [Daml Stdlib] Add `DA.List.Builtinorder` module. This module provides
  variants of `sort*` and `dedup*` which rely on Daml-LF’s builtin
  ordering and are significantly more efficient in some cases.

changelog_end
2021-03-24 16:33:05 +01:00
Moritz Kiefer
4fd1cf7c28
Fix doctests (#9225)
Haven’t tracked down when they broke. They used to work at some point
but atm they are very broken and don’t test anything.

This PR fixes the bash mess to parse the files correctly and fixes two
minor issues that creeped in by virtue of the doctests being broken.

changelog_begin
changelog_end
2021-03-24 12:56:37 +01:00
Moritz Kiefer
90c5ce703a
Optimize mapOptional and add more efficient findOptional (#9214)
* Optimize mapOptional and add more efficient findOptional

Given that we don’t have list fusion catOptionals . map f is clearly
less efficient than this version.

I also added findOptional which can be pretty handy in certain cases.

changelog_begin
changelog_end

* more foldr

changelog_begin
changelog_end

* fix tests

changelog_begin
changelog_end
2021-03-23 17:07:45 +00:00
Remy
1e0c67c306
LF: Add RoundingMode and BigNumeric in Haskell Ast (#9215)
This is part of #8719.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-23 16:50:17 +00:00
Moritz Kiefer
e492603808
More manual list fusion in stdlib (#9217)
Both of these seem sufficiently common that it seems worth optimizing
them.

I realize I’m switching somewhat randomly between foldr and
hand-written recursion. Either should be better than traversing the
list twice but I think it’s a clear sign that we need some benchmarks
to establish the benefits or downsides of one over the other properly.

changelog_begin
changelog_end
2021-03-23 17:08:43 +01:00
Remy
51c5eac66e
LF: Add BigNumeric to archive proto (#9210)
CHANGELOG_BEGIN
CHANGELOG_END
2021-03-23 13:58:22 +00:00
nickchapman-da
c1cf2756a8
add rollback node to transactions (#9178)
* New transaction node: NodeRollback. Fixup every match with a crash + TODO.

changelog_begin
changelog_end

* remove 3 methods from NodeRollback which are not needed to fulfill its interface

* add override to remaining 4 methods implemented in body of NodeRollback

* remove unrequired 2nd type parameter (Cid) from NodeRollback

* add missing 8020 marker
2021-03-23 08:49:25 +00:00
Robin Krom
f89aa294e5
damlc pkg: use cache for already present packages (#9193)
* damlc pkg: use cache for already present packages

This only downloads packages from a remote ledger, if the package is not
already present in the dependency db as a normal dependency.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-22 13:57:38 +01:00
Robin Krom
081623b493
fix: bad package id validation (#9183)
Package ids are 64 lower case hex digits.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-18 16:25:57 +01:00
Robin Krom
8c64f120da
pkgid data deps (#9153)
* damlc: Allow package IDs in data-dependencies.

This is the next step outlined in issue #8976. If package id's are
present in the `data-dependency` section of the daml.yaml file, we try
to fetch them (and their transitive dependencies) from the default
ledger of the project.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-18 12:17:38 +01:00
Sofia Faro
c26c349c8b
Generate exception instances from syntax. (#9140)
* Generate exception instances from syntax.

changelog_begin
changelog_end

* II

* III

* VII

* update ghc patch and add test

* VIII

* IX

* Remove DatatypeContexts

* X

* update stack snapshot

* don't need datatypecontexts warning anymore

* X-2

* XII

* XIII
2021-03-17 12:19:22 +00:00
Moritz Kiefer
75f7688cae
Expose unhandled exception values and types (#9158)
This PR addresses the TODO to expose the actual exception values and
type instead of the message. This allows us to simply speedy a bit by
removing the continuation used for that but more importantly it means
we can now catch and handle the exception in Daml script.

changelog_begin
changelog_end
2021-03-17 12:10:19 +01:00
Moritz Kiefer
f6effb228a
Add a compile-only damlc target (#9164)
This untangles the dependency structure a bit so that //daml-lf no
longer ends up depending on daml script and sandbox and similar crap
which should improve build times in general.

changelog_begin
changelog_end
2021-03-17 10:31:37 +01:00
nickchapman-da
9b2158508b
Add new variant to Value.scala for builtin-exceptions. (#9084)
* Add new variant to Value.scala for builtin-exceptions.

final case class ValueBuiltinException[+Cid](tag: String, value: Value[Cid]) extends Value[Cid]

And push through the code consequences.
Most places fixed up.
A couple more things to do in this PR (marked NICK)
A couple of things which can be left for later (marked 8020)

fix build

fix another scala match

changelog_begin
changelog_end

* fix any match

* add marker of code which needs attending to in the PR

* extend ledger-api value.proto & fix LfEngineToApi

* undo/comment-out the change to value.proto

* add tests in HashSpec for BuiltinException

* code but dont yet enable value-gen for builtin exceptions

* address comments which suggest we crash in various places

* support BuiltinException in scenario_service.proto

* one more TODO 8020 tag
2021-03-16 13:15:33 +00:00
Robin Krom
7669d8c88c
daml pkg: split installation of deps and package db inititialization (#9056)
* daml pkg: split installation of deps and package db inititialization

This is the next step for the daml package manager program #8976.
This splits the installation of dependencies from the initialization of
the (ghc) package database.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-12 22:55:11 +01:00
Remy
70379d4e85
LF: Experiment Hook for 1.dev (#9051)
This PR adds a hook in the compiler and the engine to allow easy prototyping of new features.

In particular by using this hook, one can add a new feature in 1.dev with modifying:

    compiler
    type checkers (both Haskell and Scala)
    archive Protobuf
    archive decoder

In addition of development speed, this also adds a bit of confidence, as the peaces enumerated above are not touched when adding the feature: The feature can be added by modifying only 1.dev Daml standard library and Speedy.

aa7991f8 shows a use case of this hook.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-11 21:36:49 +01:00
Sofia Faro
e538f2d676
Add DA.Exception and enable LF primitives. (#9082)
- Add `DA.Exception` module that re-exports `DA.Internal.Exception`
while hiding the `DamlException` class.

- Uncommented out the primitive calls in `DA.Internal.Exception`, so
the standard library is actually calling the underlying LF primitives.

- Expanded the `ExceptionDesugared` test to actually throw and catch
an exception. :-)

changelog_begin
changelog_end
2021-03-11 11:42:16 +00:00
Remy
8a35528514
LF: Make 1.12 default compiler output (#9058)
CHANGELOG_BEGIN
- [Compiler] The compiler produces LF 1.12 by default. LF 1.12 only reduces transaction size.
CHANGELOG_END
2021-03-10 16:44:29 +00:00
Sofia Faro
e6ea8fa9b3
Start adding exception syntax support. (#8960)
* Start adding exception syntax support.

changelog_begin
changelog_end

* .

* ..

* . .

* ....

* .___.

* ..__..

* ._._._.

* update stack snapshot

* recompile ghc-lib

* update stackage

* add CmmParse patch

* incorporate CmmParse.y patch into ghc branch

* Add a first test for exception syntax desugaring.

* Add a test for multiple message declarations

* update ghc patch

* Update duplicate message test with location

* add brackets test

* Add final patch SHA

* update stack-snapshot and unpin for unix

* Update stackage pin on windows
2021-03-10 12:07:53 +00:00
Moritz Kiefer
0281b442b8
-Werror all the things (#9027)
We used to do this for some packages but it broke cpp. I don’t
actually know why it doesn’t do that anymore but I’ll gladly accept
that fact and turn it on everywhere.

changelog_begin
changelog_end
2021-03-04 19:08:59 +01:00
Moritz Kiefer
2c08586d33
Expose Daml stacktraces for Daml Script errors (#9025)
* Expose Daml stacktraces for Daml Script errors

This finally plugs together the pieces from the previous PRs to
provide stacktraces on any ScriptF command (and thereby anything
involving an interaction with the ledger).

fixes #8754

changelog_begin

- [Daml Script] When running Daml Script on the command line you will
  now see a Daml stacktrace on failures to interact with the ledger
  which makes it significantly easier to track down which of the calls
  fails. By default, you will only get the callsite of functions like
  `submit`. To extend the stack trace, add `HasCallStack` constraints
  to functions and those will also be included.

changelog_end

* Fix non-determinism in tests

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end
2021-03-04 16:13:50 +01:00
Robin Krom
3758b57a87
pkg deps: Move all dalfs to package dependency directory (#9002)
As a first step for the daml package manager, we move all dalf files
from (data-)dependencies to a new `.daml/dependencies` directory.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-04 11:37:03 +01:00
Moritz Kiefer
e5421288d9
Improve errors on duplicate record field names (#9010)
* Improve errors on duplicate record field names

fixes #8994

changelog_begin
changelog_end

* Apparently I was wrong about names

changelog_begin
changelog_end

* hlint

changelog_begin
changelog_end

* newlines don’t render well in daml build

changelog_begin
changelog_end

* maybe I should test if my code compiles before pushing

changelog_begin
changelog_end
2021-03-04 10:13:24 +01:00
Moritz Kiefer
32dc8b007b
Include stack traces for all ScriptF commands (#8999)
This PR adds stack traces to all ScriptF commands and handles those in
the converter. Those stack traces are not yet used. To ease review,
I’ve left that for a separate PR. The plan is to use this to tackle
https://github.com/digital-asset/daml/issues/8754.

changelog_begin
changelog_end
2021-03-03 15:07:09 +01:00
Robin Krom
7490832966
damlc-test: add 'large' label to BUILD (#8997)
Hopefully this gives the tests more time to complete on the mac nodes.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-03 11:38:57 +00:00
Robin Krom
11ec339f6f
feature: damlc lints all files in project directory (#8979)
* feature: damlc lints all files in project directory

fixes #8887.

This changes the input options of `damlc lint` to take several files. If
no file is given, all `.daml` files contained in the directory are
linted.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-02 15:50:57 +01:00
Moritz Kiefer
ec36066986
Split LedgerInteraction into different files (#8975)
Pure shuffling around there is no logic change in here. I keep getting
lost in the 1.4k LedgerInteraction file so this client splits it up
into a 4 different files to make it a bit easier to navigate.

changelog_begin
changelog_end
2021-03-01 16:27:34 +01:00
Moritz Kiefer
514bf2597e
Include table view for failed scripts (#8967)
fixes #8966

changelog_begin

- [Daml Studio] Failed scripts (and scenarios) now also offer the
  option to view the table view at the state before the failing
  transaction to ease debugging.

changelog_end
2021-03-01 09:58:01 +01:00
Robin Krom
012b04368d
damlc test: feature: add --all flag. (#8919)
* damlc test: feature: add --all flag.

This adds a flag `--all` that will test all present scenarios/scripts in
the code and also report code coverage with respect to all present
templates/choices, whereas without the flag, code coverage is reported
relative to a single package.

CHANGELOG_BEGIN
[damlc test] Added a `--all` flag to test all present scripts/scenarios.
CHANGELOG_END
2021-02-26 18:44:40 +01:00
Moritz Kiefer
275eaedd2a
Fix closure references in Daml Repl (#8950)
* Fix closure references in Daml Repl

Turns out the comment "we probably need to extend this to merge the
modules from each line" was exactly correct: If the result evaluates
to a closure (or a value including a closure), it can reference
definitions from the current module. This happens if the simplifier
lifted something out of the current definition (otherwise we have only
one and it cannot be recursive so no chance of leaking a reference).

This PR fixes this by checking whether the result references the
current module and if it does, we keep it around.

changelog_begin
changelog_end

* Address review comments

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end
2021-02-26 13:29:42 +00:00
Gary Verhaegen
1b56b31e80
document potentially-surprising Month <-> Enum (#8923)
Based on a [forum question] by Alxander Bernauer.

[forum question]: https://discuss.daml.com/t/enum-instance-for-month-is-misleading/2098?u=gary_verhaegen

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-25 10:33:52 +01:00
Remy
a9b035e92e
LF: release LF 1.12 (#8856)
CHANGELOG_BEGIN

    - [LF] Release LF 1.12. This version reduce the size of transaction

    - [Compiler]: Change the default LF output from 1.8 to 1.11.

CHANGELOG_END
2021-02-24 21:17:33 +01:00
Gary Verhaegen
f0f2e710c1
document HasField (#8922)
* document HasField

This is stolen directly from @sofiafaro-da's excellent [forum answer].

[forum answer]: https://discuss.daml.com/t/generating-record-update-functions-to-be-used-as-parameters/2091/3?u=gary_verhaegen

CHANGELOG_BEGIN
CHANGELOG_END

* remove currying & add warning to sue dot syntax instead

* add set -euo pipefail to preview script
2021-02-24 16:55:10 +00:00
Moritz Kiefer
8ebc8d3fc8
Sort Daml REPL options to clean up --help (#8936)
Not perfect but probably much cleaner than what we had before. Some
of the orders can definitely be debated and I don’t have strong
feelings beyond the first 5 so if someone feels strongly, I’m open to
changing things.

New output:

Usage: damlc repl [DAR] [-i|--import PACKAGE]
                  [--ledger-host ARG --ledger-port ARG]
                  [--access-token-file TOKEN_PATH] [--application-id ARG]
                  [--tls] [--cacrt ARG] [--pem ARG --crt ARG]
                  [--max-inbound-message-size ARG]
                  [(-w|--wall-clock-time) | (-s|--static-time)]
                  [--project-root ARG] [--project-check]
                  [--include INCLUDE-PATH] [--package-db LOC-OF-PACKAGE-DB]
                  [--shake-profiling PROFILING-REPORT] [--jobs THREADS]
                  [--debug] [--ghc-option OPTION]
  Launch the Daml REPL.

Available options:
  -h,--help                Show this help text
  DAR                      DAR to load in the repl
  -i,--import PACKAGE      Import modules of these packages into the REPL
  --ledger-host ARG        Host of the ledger API
  --ledger-port ARG        Port of the ledger API
  --access-token-file TOKEN_PATH
                           Path to the token-file for ledger authorization
  --application-id ARG     Application ID used for command submissions
  --tls                    Enable TLS for the connection to the ledger. This is
                           implied if --cacrt, --pem or --crt are passed
  --cacrt ARG              The crt file to be used as the trusted root CA.
  --pem ARG                The pem file to be used as the private key in mutual
                           authentication.
  --crt ARG                The crt file to be used as the cert chain in mutual
                           authentication.
  --max-inbound-message-size ARG
                           Optional max inbound message size in bytes.
  -w,--wall-clock-time     Use wall clock time (UTC). (this is the default)
  -s,--static-time         Use static time.
  --project-root ARG       Path to the root of a project containing daml.yaml.
                           You should prefer the DAML_PROJECT environment
                           variable over this option.See
                           https://docs.daml.com/tools/assistant.html#running-commands-outside-of-the-project-directory
                           for more details.
  --project-check          Check if running in Daml project.
  --include INCLUDE-PATH   Path to an additional source directory to be included
  --package-db LOC-OF-PACKAGE-DB
                           use package database in the given location
  --shake-profiling PROFILING-REPORT
                           Directory for Shake profiling reports
  --jobs THREADS           The number of threads to run in parallel. When -j is
                           not passed, 1 thread is used. If -j is passed, the
                           number of threads defaults to the number of
                           processors. Use --jobs=N to explicitely set the
                           number of threads to N. Note that the output is not
                           deterministic for > 1 job.
  --debug                  Enable debug output
  --ghc-option OPTION      Options to pass to the underlying GHC

changelog_begin
changelog_end
2021-02-24 14:31:55 +00:00
Remy
d17dd7e5f1
Ledger API test tool: test against legacy and preview version. (#8913)
* Ledger API test tool: test against legacy and preview version.

+ use dictionary instead of alias to map version keywords to LF version 

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-23 09:19:17 +01:00
Remy
d92f2c7003
Ledger: refactor bazel packaging of tedger test tool (#8894)
improve previous generalization from #8695

- use lf version instead keyword (like 'stable', 'latest', 'dev') to
  tag actual target.  This will allow two keywords to map to the same
  versions without doing twice the compilation/test work.

- use alias to map keywords tag target to versioned tag target.

- move package manage dar to test_commong.

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-22 11:41:19 +01:00
Sofia Faro
ff7f54b896
Rename tryCatchRaw to _tryCatch. (#8897)
This matches the name of other internal functions more closely, like
_toAnyTemplate and _fromAnyChoice.

changelog_begin
changelog_end
2021-02-18 18:26:08 +00:00
Jost Berthold
5d44ff9085
Upgrade the LF library build setup (resolver, dependencies, version) (#8865)
Upgrade Daml LF library extraction to latest versions and newer GHC

changelog_begin
changelog_end
2021-02-17 07:07:17 +01:00
Moritz Kiefer
777749539c
Draw the rest of the Scala 2.13 owl (#8852)
* Draw the rest of the Scala 2.13 owl

Not quite but pretty close and this switches us over from inclusions
to exclusions which makes it much easier to track.

Ledger API test tool should be fixed by #8821. Non-repudiation needs a
tiny bit of work since unwrapArray doesn’t work the same on 2.13 but
shouldn’t be hard to fix.

changelog_begin
changelog_end

* Fix ScriptService tests

Those tests were all dumb. They asserted on a fixed order while the
function to sort the things was broken so we ended up with the random
Map order which is unsurprisingly not the same.

This is easily fixed by fixing the sort function.

There is also a second issue with query not sorting.

changelog_begin
changelog_end

* Turns out if you fix one test the next one breaks

And clearly nobody ever tested this or give this a second thought.

changelog_begin
changelog_end
2021-02-15 19:20:24 +00:00
Robin Krom
0c72d07f27
damlc: fix: catch UserError instead IOException (#8850)
* damlc: fix: catch UserError instead  IOException

When the package-db metadata can not be parsed, an exception is thrown
and needs to be catched.  Previously we were catching IOException, but
in this case it's actually a UserError that is thrown.

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-15 19:16:37 +01:00
Robin Krom
5ec36e4ff9
damlc test: show full coverage report (#8834)
* damlc test: show full coverage report

We add a flag `show-coverage` to `damlc-test` to show templates that
are never created and choices that are never executed during the tests.

CHANGELOG_BEGIN
[damlc test] A new flag `show-coverage` shows full test coverage
reports.
CHANGELOG_END
2021-02-15 16:40:13 +01:00
nickchapman-da
dbd017ee49
Support exceptions in speedy. (#8612) 2021-02-15 11:07:12 +00:00
Sofia Faro
34fe42237d
data-deps: Dont let defaults leak constraints. (#8833)
* data-deps: Dont let defaults leak constraints.

Fixes #8802

changelog_begin
changelog_end

* use expandSynApp instead of expandTypeSynonyms

* revert isConstraint change

* fix indentation
2021-02-12 15:44:29 +00:00
Remy
4d38719cb2
LF: first draft of the exception internal API for PartialTransaction (#8808)
This is part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-12 14:06:34 +01:00
Moritz Kiefer
68bd6f065c
Fix warnings when compiling daml-stdlib (#8826)
No point in outputting a bunch of warnings about deprecations that are
expected and cannot be fixed.

changelog_begin
changelog_end
2021-02-12 13:10:39 +01:00
Moritz Kiefer
f15a2a36b0
Bump DLint to include fix for disable comments (#8820)
changelog_begin

- [DLint] You can now disable dlint hints for a specific functions in
  the form `{- DLINT ignore functionName "hintName" -}`, e.g.,

```
{- DLINT ignore noHint "Use concatMap" -}
noHint f xs = concat (map f xs)
```

Note: The undocumented {- HLINT -} pragmas are no longer supported.

changelog_end
2021-02-12 11:13:44 +01:00
Robin Krom
49d957bec1
damlc: show test coverage (#8810)
* damlc: show test coverage

We add output to show percentage of created templates and executed
choices for `damlc test`.

This fixes #6370.

CHANGELOG_BEGIN
[damlc] Feature: Test coverage is reported for `damlc test`.
CHANGELOG_END

* added a test

* Update compiler/damlc/lib/DA/Cli/Damlc/Test.hs

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* suggestions

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-02-11 17:08:41 +01:00
Remy
c5f0b3636c
LF: Refactor PartialTransaction Context (#8804)
This prepares the introduction of rollback node.

This is part of #8020.

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-10 14:12:57 +01:00
Moritz Kiefer
e196a7cc73
Clarify documentation around --project-root (#8790)
fixes #8783

changelog_begin
changelog_end
2021-02-10 12:03:59 +01:00
Sofia Faro
2943c4089c
Pick up user-defined exceptions in LFConversion. (#8777)
This uses a "DamlException" tag to annotate which types should
be exported as exceptions. This tag will be added during the
desugaring of exceptions.

The code that scrapes for the HasMessage instance is based on the
corresponding template instance scraping code, but simplified since
we only have to pick up one instance. If we decide to pack more
information into the DefException structure in the future, we can
easily extend this.

This PR also adds a small test to make sure that a user-defined
exception is exported as such.

changelog_begin
changelog_end
2021-02-09 12:27:09 +00:00
Moritz Kiefer
773ddada04
Upgrade nixpkgs (#8190)
* Upgrade nixpkgs

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* No ibazel

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* Switch agent pool

changelog_begin
changelog_end

* .

* .

changelog_begin
changelog_end
2021-02-08 11:12:07 +00:00
Robin Krom
e79966b890
ghcide: cached goto definitions (#8751)
We update ghcide, which enables cached goto definitions that keep
working when the document doesn't compile anymore. This also adds a test
to lsp-tests for this feature.

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-04 21:05:12 +01:00
Moritz Kiefer
4b33da2420
Expose transaction trees in DAML Script (#8750)
This is spun off from #7934 for ease of review.

For now, all of this is hidden (and for extra caution also marked as
early access). I expect we’ll tweak the API in a bunch of ways before
marking it stable but this at least is sufficient for the prototype.

At this point, we cannot support this over the JSON API. Not too
worried about that at least for now.

fixes #7847

changelog_begin
changelog_end
2021-02-04 15:21:30 +01:00
Martin Huschenbett
06a33d2c53
DLint: Disable "Redundant pure" lint by default (#8733)
* DLint: Disable "Redundant pure" lint by default

When using `ApplicativeDo`, e.g. in Daml Scripts, a final pure might be
necessary although it would be redundant in a monadic context. This
leads to spurious warnings from the linter which I found quite
confusing.

CHANGELOG_BEGIN
CHANGELOG_END

* Adjust tests

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-03 17:38:19 +00:00
Robin Krom
6bb76bda58
lsp-tests: test for no internal symbols (#8708)
This updates the daml-ghcide dependency and also adds a test to check
that we are not showing any internal symbols and dependencies in the
outline in daml studio.

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-02 11:28:22 +01:00
Moritz Kiefer
2528998d00
Generate docs for preview LF version (#8712)
changelog_begin
changelog_end
2021-02-02 10:25:30 +01:00
Robin Krom
5c5c2527a2
lsp-tests: test for no internal imports (#8699)
We add a test to check that there are no internal imports returned by
the `getDocumentSymbols` endpoint for an empty module.

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-29 22:17:21 +01:00
Sofia Faro
44c7b0bd53
Deprecate DA.Next.Set and DA.Next.Map (#8689)
Fixes #8449

changelog_begin

- [DAML Standard Library] DA.Next.Map and DA.Next.Set are deprecated.
  Please use DA.Map and DA.Set instead, or use DA.TextMap directly
  for ledger API backward compatibility.

changelog_end
2021-01-29 13:29:13 +00:00
Sofia Faro
69b28d2ef2
Add --target=1.12 support in the compiler. (#8673)
* Add --target=1.12 support in the compiler.

changelog_begin

- [DAML Compiler] Add support for ``--target=1.12`` in the DAML compiler.

changelog_end

* version1_12 not version1_11

* Update codegen tests.

* Update codegen tests again

* Fix data-dependencies test.
2021-01-29 12:41:21 +00:00
Moritz Kiefer
5d91a25306
Disable deriving-defaults per file (#8684)
Disabling it per target works nicely for compilation but it gets
annoying in ghci since the warnings are still triggered. We could
disable it everywhere but I think the warning is generally useful. I
tried patching proto3-suite to use DerivingStrategies but that doesn’t
work because haskell-src is dead and doesn’t support it. So for now
adding it to the per-file list seems like the best option.

changelog_begin
changelog_end
2021-01-29 11:01:55 +00:00
Sofia Faro
98fe621066
Add DA.Set to match DA.Map (#8651)
* Add DA.Set to match DA.Map

Fixes #8448

changelog_begin
changelog_end

* Make it a stable package

* Add test.

* add map field

* fix stable-packages test

* update Examples.daml
2021-01-28 16:12:16 +00:00
Robin Krom
ce4fff5133
ghcide: update to newest commit (#8665)
* ghcide: update to newest commit

CHANGELOG_BEGIN
CHANGELOG_END

* update golden tests
2021-01-28 15:03:52 +01:00
Richard Kapolnai
ce5d3bed1e
Add note about loglevel to trace and debug api doc (#4756)
* Add note about loglevel to trace and debug api doc

CHANGELOG_BEGIN
CHANGELOG_END

* Explain log level in comment of debug

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* fix typo

* propagate explanation to trace, traceId and debug

* Fix DA.Internal.Prelude location

changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-01-26 14:56:11 +00:00
Robin Krom
036e46a1ee
damlc: check for inconsistent dependencies (#8619)
* damlc: check for inconsistent dependencies

This fixes #8553.

We check that all dependencies have the expected LF version.

CHANGELOG_BEGIN
CHANGELOG_END

* move filter to guard

* turn mainUnitId lookup into set lookup
2021-01-26 12:57:24 +01:00
Moritz Kiefer
e0c5abd647
Switch to GHC 8.10.3 (#8394)
* Switch to GHC 8.10.3

changelog_begin
changelog_end

* Update bazel-haskell-deps.bzl

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* Comment on rules_haskell patch

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2021-01-25 11:53:53 +00:00
Gary Verhaegen
ce8c38bac1
copyright updates (#8610)
CHANGELOG_BEGIN
CHANGELOG_END
2021-01-22 15:03:36 +00:00
Sofia Faro
438c204fc4
Add choice observers in LF spec. (#8592)
* Add choice observers in LF spec.

Part of #7709. Adds choice observers to the syntax, type system, and
and operational semantics of LF. Adds a test for the operational
semantics of choice observers.

changelog_begin
changelog_end

* typo

* remove duplicate rule

* Always have choice observers

* Add comment in serialization section
2021-01-22 13:10:41 +00:00
Georg Schneider
56c1405b60
Fix stdlib docs for unless (#8597)
* Fix stdlib docs for unless

* Fix stdlib docs for unless

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Georg Schneider <georg.schneider@digitalasset.com>
2021-01-22 06:18:55 +01:00
Sofia Faro
461273bb8f
Cleaning up the eval order tests. (#8580)
When I first wrote these tests I didn't realise you could have the `@ERROR` annotation anywhere in the file so I put them all near the top. This PR is just to move the `@ERROR` annotations closeer to where the error is generated, so it's easier to maintain. This is in preparation for updating the spec & tests for choice observers.

changelog_begin
changelog_end
2021-01-21 11:25:41 +00:00
Robin Krom
aa8c1f8fee
damlc: incremental package db initialization (#8541)
* damlc: incremental package db initialization

We keep a hash over all dependencies of a project in the package
database metadata and only recompute the package database if a
dependency changes, i.e. the computed hash changes.

Fixes #4413.
Fixes #8409.

CHANGELOG_BEGIN
CHANGELOG_END

* using Fingerprint

* added tests

* format

* use SdkVersion instead of hardcoded version

* added a reference in tests

* factored out project file template
2021-01-20 15:52:37 +01:00
Gary Verhaegen
756b6ce942
update compiler header (#8520)
Channelling my inner Dan.

CHANGELOG_BEGIN
CHANGELOG_END
2021-01-15 12:40:19 +00:00
Robin Krom
32ca8fb831
telemetry: use an extra cache directory for telemetry (#8439)
* telemetry: use an extra cache directory for telemetry

If the sdk's `.daml` directory is not writable, telemetry fails and
kills the IDE. We add a new assistant environment variable "DAML_CACHE".
If set, this directory is used for telemetry cache data.

Fixes #8396.

CHANGELOG_BEGIN
CHANGELOG_END

* try creating directory

* check for already existing machine id file

* set DAML_CACHE to read-only in assistant integration tests
2021-01-15 11:44:18 +01:00
Gary Verhaegen
867041ce61
hide with-dlint option (#8506)
Quoting @cocreature on Slack:

> the fact that --with-dlint is exposed as a public option at all seems
> broken. I don’t think it was ever intended to be one.

CHANGELOG_BEGIN

- [Daml CLI] Three options that were never meant to be public are now
  hidden from the output of various `daml xxx --help` commands. The
  options still have the same effect when present, so this is not (yet)
  a breaking change. Using these options tends to result in very
  unhelpful, when not outright broken, dlint configurations, so we expect
  existing usage to be low to nonexistent. If you do use them please
  share your use-case with us. The options are:
  - `--with-dlint`
  - `--without-dlint`
  - `--allow-overrides`

CHANGELOG_END
2021-01-14 18:56:59 +01:00
Moritz Kiefer
427ea0fb7d
Remove redundant list of LF versions (#8490)
* Remove redundant list of LF versions

After #8472, I realized that there must be a list used for daml-stdlib
and daml-prim already and it turns out there is. I’ve removed that one
in favor of the one added in #8472 since I like having all in one
place and the one from #8472 is created by filtering an existing list
instead of creating a completely separate list like we do here.

changelog_begin
changelog_end

* Introduce SCRIPT_LF_VERSIONS

changelog_begin
changelog_end
2021-01-13 13:21:39 +00:00
Sofia Faro
51c014b367
Add the missing UTryCatch primitive. (#8462)
* Add the missing UTryCatch primitive.

I tested that the types are correct by uncommenting the corresponding
line in DA.Internal.Exception (which must remain commented, because
the engine does not yet support exceptions).

changelog_begin
changelog_end

* indent/associate

* typo :-(
2021-01-13 10:33:55 +00:00
Gary Verhaegen
9ec54628a2
do not support Eq, Ord, Show for large tuples (#8475)
CHANGELOG_BEGIN
CHANGELOG_END
2021-01-12 17:43:35 +01:00
Sofia Faro
e604ba1fad
Add LFConversion support for exception primitives. (#8427)
* Add conversion for exception types

* Start adding exception primitives.

changelog_begin
changelog_end

* add more error message primitives

* Comment out the exception primitives for now.

* Dont use runtimeUnsupported

* Organize DA.Internal.Exception a bit.

* Add ActionThrow and ActionCatch.

* import all of DA.Internal.Prleude

* haskell brain
2021-01-11 14:05:24 +00:00
Shaul Kfir
7b409b9e87
Typo fix in fmap documentation (#8350)
changelog_begin
changelog_end
2021-01-11 11:01:44 +00:00
Moritz Kiefer
22ce940954
Upgrade scalafmt and enable trailing commas (#8437)
This PR updates scalafmt and enables trailingCommas =
multiple. Unfortunately, scalafmt broke the version field which means
we cannot fully preserve the rest of the config. I’ve made some
attempts to stay reasonably close to the original config but couldn’t
find an exact equivalent in a lot of cases. I don’t feel strongly
about any of the settings so happy to change them to something else.

As announced, this will be merged on Saturday to avoid too many conflicts.

changelog_begin
changelog_end
2021-01-09 11:37:37 +01:00
Bernhard Elsner
cda93db944
Daml case and logo (#8433)
* Replace many occurrences of DAML with Daml

* Update docs logo

* A few more CLI occurrences

CHANGELOG_BEGIN
- Change DAML capitalization and docs logo
CHANGELOG_END

* Fix some over-eager replacements

* A few mor occurrences in md files

* Address comments in *.proto files

* Change case in comments and strings in .ts files

* Revert changes to frozen proto files

* Also revert LF 1.11

* Update get-daml.sh

* Update windows installer

* Include .py files

* Include comments in .daml files

* More instances in the assistant CLI

* some more help texts
2021-01-08 12:50:15 +00:00
Moritz Kiefer
424faa923a
Port damlc dependencies to Scala 2.13 (#8423)
* Port damlc dependencies to Scala 2.13

I got a bit fed up by the fact that going directory by directory
didn’t really work since there are two many interdependencies in
tests (e.g., client tests depend on sandbox, sandbox tests depend on
clients, engine tests depend on DARs which depend on damlc, …).

So before attempting to continue with the per-directory process, this
is a bruteforce approach to break a lot of those cycles by porting all
dependencies of damlc which includes client bindings (for DAML Script)
and Sandbox Classic (also for DAML Script).

If this is too annoying to review let me know and I’ll try to split it
up into a few chunks.

changelog_begin
changelog_end

* Update daml-lf/data/src/main/2.13/com/daml/lf/data/LawlessTraversals.scala

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* fixup lawlesstraversal

changelog_begin
changelog_end

* less iterator more view

changelog_begin
changelog_end

* document safety of unsafeWrapArray

changelog_begin
changelog_end

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-01-08 07:22:38 +01:00