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
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
* 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
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
* 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
* 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
* 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
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
* 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
* 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.
* 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
* 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
* 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!
* 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
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
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
* 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>
* 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)
* 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
* 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.
* 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
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
* 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
* 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
* 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
* 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>
* 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'
* 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