Commit Graph

1499 Commits

Author SHA1 Message Date
Remy
41009f79cc
Compiler: Make LF 1.14 the default output (#10394)
CHANGELOG_BEGIN

- [Compiler] Default compiler output LF version is now 1.14

CHANGELOG_END
2021-07-28 12:14:56 +02:00
Remy
72cf2f36d3
LF: replace bazel keyword stable by default (#10410)
to refer to the compiler default LF output.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-27 09:27:03 +02:00
Andreas Herrmann
9c064dac35
Allow imports of internal modules (#10397)
* Allow imports of internal modules

changelog_begin
- [Daml Compiler] Imports of internal modules from stable packages are
  no longer illegal. Previously, the compiler raised an error when it
  encountered imports of internal modules such as
  `DA.Internal.Template`. Such imports are now accepted by the compiler.
  Note, however, that internal modules are still not part of the stable
  API. Fixes https://github.com/digital-asset/daml/issues/10379
changelog_end

* ~unstable~

https://github.com/digital-asset/daml/pull/10397#discussion_r676485891

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2021-07-26 11:45:52 +00:00
Remy
4a33c03f72
LF: Add check of nesting in SValue.toValue (#10370)
The conversion of SValue to Value already ensures the resulting value
has a serializable type. Here we add a check to ensure it does not
overpass the maximum allow nesting.
2021-07-22 17:49:54 +02:00
Sofia Faro
b701caab7d
Report divulgence warning at commit location. (#10329)
* Pass commitLocation along in engine warning log.

changelog_begin
changelog_end

* Use commitLocation in diagnostics.

* scalafmt

* update divulgence test

* Fix commitLocation and expected diagnostic locations
2021-07-20 15:47:49 +00:00
Sofia Faro
cf2f79db4e
Register divulgence warning as a diagnostic (#10289)
* Register divulgence warnings as diagnostics

The divulgence warnings for a scenario are registered as a diagnostic,
when there isn't a scenario error. (Rationale: Scenario errors already
include the warnings in their text, after trace log entries.)

Part of #9947, follow up from #10253

changelog_begin
changelog_end

* Rewrite case expression to make it more readable

* Fix a couple integration tests
2021-07-20 09:50:23 +01:00
Remy
159728d716
LF: use Either by default in all archive reader API (#10295)
This is a follow up of #10277.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-19 19:48:37 +02:00
nickchapman-da
0e09f3ba08
Remove optLocation field from transaction nodes. (#10301)
* Remove Optional[Location] field from transaction nodes.

xoptLocation

working but very messy!

cleanup PartialTransaction code

pass locationInfo in CompleteTransaction

dont pass locationInfo in SumittedTransaction

pass optLocation to CheckAuthorization

temp reinstate xoptLocation in ExerciseContextInfo

cleanup Conversions.scala

remove Optional[Location] field from transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END

* fix bad merge

* fix build after merge

* rename

* doc comment, and question
2021-07-19 13:03:30 +00:00
Remy
f033bc2bbb
LF: Clean legacy from archive proto + TEXT_TO_CODE_POINTS typo (#10286)
Thanks to @tristan-da for pointing this out.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-15 16:01:08 +02:00
Sofia Faro
6e447c567e
Patch export filtering of GHC.Types.[] in damldocs (#10282)
The type isn't explicitly exported in GHC.Types but it should still be exported.

changelog_begin
changelog_end
2021-07-15 11:01:35 +01:00
Remy
caf85a2270
LF: rationalize archive Parser/Reader/Decoder (#10239)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 11:05:17 +02:00
Sofia Faro
b8e2198873
Separate traces from warnings in engine. (#10253)
* Separate traces from warnings in engine.

I decided to separate the engine warnings from the tracelog after all,
because I think it will make testing and maintenance easier in the
long run.

Part of #9947, follow up from #10179

changelog_begin
changelog_end

* scalafmt

* Apply suggestions from code review

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

* dont use case class for WarningLog

* revert TraceLog changes from last PR

* Scala 2.12 doesnt have ArrayBuffer.addOne :(

* remove isWarnEnabled check

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-07-13 14:24:27 +00:00
Sofia Faro
00d622f268
Make @UNTIL-LF exclusive, add @UNTIL-LF-FEATURE. (#10240)
In the damlc integration tests.

changelog_begin
changelog_end
2021-07-12 10:46:36 +00:00
Moritz Kiefer
6680d368a1
Warn on DA.Exception import (#10201)
* Warn on DA.Exception import

We had a few confused users that imported that module and got weird
errors. The warning should hopefully make things a bit clearer. We
could do this for other modules as well but I’ll leave that for
separate PRs.

changelog_begin

- [Daml Compiler] Importing DA.Exception on LF < 1.14 now produces a
warning that exceptions require Daml-LF >= 1.14.

changelog_end

* Add a test for exception imports

changelog_begin
changelog_end
2021-07-08 16:51:19 +00:00
Remy
ebb76dca4c
LF: reorganize errors in com.daml.lf.archive (#10213)
* LF: reorganize errors in com.daml.lf.archive

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END

* fix
2021-07-08 13:03:42 +00:00
Remy
41b8448b17
LF: Simplify archive reader. (#10208)
* LF: Simplify archive reader.

- decouple Reader and Decoder
- introduce case class to handle hash, proto payload, and version

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' review

* cosmetic
2021-07-07 19:56:40 +00:00
Moritz Kiefer
6586dde11e
Move exercise context computation to the client side (#10199)
We probably want to start displaying the full ptx on the client side
but for now this at least moves things out of speedy and into the
rendering layer where they belong.

It also fixes IncompleteTransaction to unwind properly so the roots
are really the roots.

changelog_begin
changelog_end
2021-07-07 15:44:47 +02:00
Sofia Faro
98b5ffee01
Add divulgence warning and test in script service. (#10179)
* Add divulgence warning and test in script service.

Part of #9947, building on the key visibility checks from #10136

This PR adds a divulgence warning inside the traceLog.
I wasn't sure whether:

1. these warnings should be kept in a separate structure from the
   traceLog, and therefore transmitted separately, or
2. these warnings should be kept together with traces, but the severity
   should be tracked and also transmitted over grpc, and warnings should
   be logged as warnings instead of as debug messages, or
3. these warnings should be kept together with traces, but
   logged as warnings instead of debug messages,
4. these warnings should be treated exactly like traces

I'm leaning toward #2, but this PR implements #3.

This PR tests the warning via the script service tests.

changelog_begin
changelog_end

* scalafmt

* Address Moritz's review

* Rename traceLog.add to traceLog.addDebug

* fix test

* Add test using exercise

* add single transaction test
2021-07-06 13:05:52 +01:00
Jost Berthold
8a6e3ee95b
DEL-8657 update version info for Haskell LF libraries (#10160)
* DEL-8657 update version info for Haskell LF libraries

CHANGELOG_BEGIN
CHANGELOG_END

* DEL-8657 add a missing module
2021-07-02 09:46:53 +10:00
Remy
0a6df5c4db
LF: Clean Interpretation Error (#10145)
* LF: Clean Interpretation Error

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END

* fix

* Address Mortiz' review

* fix
2021-06-30 16:49:48 +00:00
Moritz Kiefer
fa80f1b615
Bump ghcide and upgrade to lsp/lsp-types (#10139)
* Bump ghcide and upgrade to lsp/lsp-types

changelog_begin
changelog_end

* Bump rev

changelog_begin
changelog_end
2021-06-30 12:16:12 +00:00
Stefano Baghino
bb4641756f
Daml assistant capitalization (#10140)
changelog_begin
changelog_end

- DAML -> daml
- Assistant -> assistant

The capitalization of the latter fixed one occurrence of a capitalized 'A'
which was inconsistent with the vast majority of uncapitalized 'a's.
2021-06-29 14:32:44 +02:00
Remy
3df2566305
Scenario: move Scenario Error Throwable to scenario package (#10075)
com.daml.lf.speedy.SErrorScenario => com.daml.lf.scenario.Error

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-28 12:04:57 +00:00
Remy
398300b76f
LF: Move Speedy Interpretation Error to transaction package (#10091)
to be accessible from any package

part of #9974

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-25 20:50:15 +02:00
Moritz Kiefer
d4150ac078
Refactor error reporting in Daml Repl (#10118)
* Refactor error reporting in Daml Repl

fixes #10098

As mentioned in that issue, the current behavior is a mess which
silently drops errors in certain cases. This PR switches things around
so that errors are reported to the client and we print them there
making sure that no error should ever get lost.

changelog_begin
changelog_end

* Bump timeout

changelog_begin
changelog_end
2021-06-25 14:08:44 +00:00
Remy
a6b536f3c4
Compiler: Make LF 1.13 the default output (#9907)
* Compiler: Roll LF Version

Fix #8591

CHANGELOG_BEGIN
- [Compiler] Default ouput LF version is now 1.13
CHANGELOG_END
2021-06-24 11:58:50 +02:00
Moritz Kiefer
b2bb45e4d9
Bump daml repl timeout (#10089)
changelog_begin
changelog_end
2021-06-23 14:19:26 +00:00
Moritz Kiefer
85e383ce0b
Fix --max-inbound-message-size flag in Daml Repl (#10078)
fixes #10072

changelog_begin
changelog_end
2021-06-23 10:10:40 +02:00
Remy
58b1c4e771
Speedy: Refactor contract Id/Key callback (#10033)
CHANGELOG_BEGIN
CHANGELOG_END
2021-06-22 16:34:28 +02:00
Moritz Kiefer
e4c1c58317
Run scenarios in off-ledger machine (#10070)
* Run scenarios in off-ledger machine

This PR builds on the previous PR that split scenario execution in two
different speedy machines and now actually makes the machine that runs
scenarios run in off-ledger mode just like we handle Daml Script.

This required a bunch of refactoring to make it nice so apologies for
the slightly large PR. Hopefully it’s still relatively easy to follow
and luckily it deletes more code than it adds.

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* review comments

changelog_begin
changelog_end

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2021-06-22 12:11:00 +02:00
Moritz Kiefer
febca5d62d
Use ScenarioRunner.submit in Daml Script (#10053)
* Use ScenarioRunner.submit in Daml Script

changelog_begin
changelog_end

* privatize ledger variable

changelog_begin
changelog_end

* drop space

changelog_begin
changelog_end
2021-06-17 17:12:45 +00:00
Sofia Faro
2f5186938e
Allow constraints in any position in data-deps. (#10049)
This fixes #8411. It turns out the issue was some missing parentheses.

changelog_begin
changelog_end
2021-06-17 15:45:10 +01:00
Moritz Kiefer
2b915e93da
Split scenario & ledger execution (#10039)
* Split scenario & ledger execution

This PR by no means aims to solve everything we can do here. It is
rather the minimal change that I could get to work that provides us
with one Speedy machine for scenario execution (which is still an
on-ledger machine to avoid having to change the callsites to much in
this PR) and one speedy machine per submission.

There is tons of cleanup we can do afterwards but this should
hopefully set the right foundations.

changelog_begin
changelog_end
2021-06-17 12:45:35 +02:00
Victor Peter Rouven Müller
d1aa256d0d
Force css-what resolution in compiler/daml-extension & fully regenera… (#10025)
* Force css-what resolution in compiler/daml-extension & fully regenerate the lock file

changelog_begin
changelog_end

* Don't force resolution as it's unecessary
2021-06-16 10:27:48 +00:00
Moritz Kiefer
836a82a6b6
Add proper error handling for missing contract keys (#9972)
* Add proper error handling for missing contract keys

These are clearly not internal errors so we should not be calling
`crash` here. Canton in fact already started string matching on the
crash message which is definitely not what we want.

changelog_begin
changelog_end

* backwards compat

changelog_begin
changelog_end

* fix tests

changelog_begin
changelog_end
2021-06-14 09:12:30 +00:00
nickchapman-da
5f0f5756bf
Define IncompleteTransaction for use by scenario-service (#9952)
* Define IncompleteTransaction for use by scenario-service

changelog_begin
changelog_end

* improve names as per review comments
2021-06-10 15:06:58 +00:00
Remy
512f1fd87d
LF: Preview version of LF 1.14 (#9906)
+ Preview support for Exceptions.
+ byKey flag for transaction nodes.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 20:40:53 +02:00
Remy
7bc925e4d2
LF: Factorize the logic for AST lookup (#9871)
Factorize the logic for AST lookup in
 - compiler 
 - type checker 
 - preprocessor
 - script triggers 
 - some tests

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-03 13:32:56 +02:00
Sofia Faro
e38bb4a55d
Make data-deps exception tests version-aware. (#9870)
* Make data-deps exception tests version-aware.

This PR changes the exception data-dependencies tests to test cross-version imports of exceptions (once we release exceptions in preview).

It also removes the last exceptions TODO from the Haskell side, other than changing `featureMinVersion` for once we start releasing excepions.

Part of #8020

changelog_begin
changelog_end

* qualify everything

* typo
2021-06-01 13:18:29 +00:00
Sofia Faro
1595f06215
Special case _tryCatch @Update in LFConversion. (#9864)
* Special case _tryCatch @Update in LFConversion.

This is in line with the special cases for (>>=), pure, etc

changelog_begin
changelog_end

* , args

* EUpdate
2021-06-01 11:41:47 +00:00
Moritz Kiefer
2a1e1ba1d5
Add a Foldable instance for Set (#9860)
changelog_begin
changelog_end
2021-06-01 10:54:20 +00:00
Rafael Guglielmetti
6af6c930a3
Fix behavior of Math.sqrt at 0 (#9818) (#9828)
* Fix behavior of Math.sqrt at 0 (#9818)

CHANGELOG_BEGIN
[Daml Compiler] Ensure that sqrt(0.0) == 0 and 0 ** 0 == 1
CHANGELOG_END
2021-05-31 15:25:47 +02:00
Sofia Faro
f355931a59
Fix typeclass detection in data-dependencies (#9830)
* Fix typeclass detection in data-dependencies

Fixes #9689 which was actually caused by misinterpreting a constraint
synonym as an empty typeclass.

This PR fixes and deduplicates the logic for detecting typeclass
definitions in data-dependencies. It also tries to avoid lifting
constraint tuples unnecessarily (since constraint synonym
definitions are already lifted). And for any constraint tuples
that are lifted, it picks a more unique name.

The PR adds a regression test, and a test for nested constraint tuples.

changelog_begin
changelog_end

* Preserve nice comment.
2021-05-28 12:25:46 +01:00
Remy
1f021b25c6
LF: Drop Builtin Exceptions completly (#9790)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-26 19:30:44 +02:00
Sofia Faro
7a7b5fee76
Add a data-dependencies test for stdlib exceptions. (#9799)
* Add a data-dependencies test for stdlib exceptions.

changelog_begin
changelog_end

* fix test and run damlc test
2021-05-26 10:04:43 +01:00
Robin Krom
a336363020
ghc-lib: update (#9742)
* ghc-lib: update

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-25 15:52:39 +02:00
Remy
8ef93611fa
Scenario: Test ArithemticError (#9757)
Two integration-type tests:

- An uncaught arithmetic error
- A caught arithmetic error

This is part of #8020

CHANGELOG_BEGIN
CHANGELOG_END
2021-05-25 14:43:27 +02:00
Sofia Faro
d2089796b2
Make succ/pred throw an ArithmeticError on overflow. (#9783)
* Make succ/pred throw an ArithmeticError on overflow.

Part of #8020.

This is the only remaining case in daml-prim & daml-stdlib where it seems correct to me to throw a different exception type rather than `GeneralError`.

changelog_begin
changelog_end

* Fix Enum
2021-05-25 10:11:50 +01:00
Sofia Faro
cd2ed07a50
Rename ContractError to PreconditionFailed (#9782)
* Rename ContractError to PreconditionFailed

Part of #8020

changelog_begin
changelog_end

* Packaging.hs mistake
2021-05-25 10:11:37 +01:00
Remy
5855a9941f
LF: Drop CONTRACT_ERROR (#9754)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-21 09:12:29 +00:00
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