Commit Graph

980 Commits

Author SHA1 Message Date
Moisés Ackerman
03203b7360
Define encoding/decoding for module imports (#11036)
* Define encoding/decoding for module imports

First step towards closing #10773

changelog_begin
changelog_end

* Update compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion/MetadataEncoding.hs

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-09-28 08:48:48 +00:00
Sofia Faro
4075624cfc
interface methods: Haskell AST (#11018)
* interface methods: Haskell AST for methods

Part of #11006. This leaves typechecker and LF conversion for later, on
the haskell side.

changelog_begin
changelog_end

* Forgot ECallInterface in DecodeV1

* fix a test
2021-09-27 10:10:21 +01:00
Sofia Faro
bf8b75dab5
interface methods: Add protobuf definitions. (#11005)
* interface methods: Add protobuf

Adds protobuf definitions for interface methods and calling them.
Encoders/decoders just ignore the extra stuff or error out.

Part of #10810 (maybe)

changelog_begin
changelog_end

* Update issue numbers where appropriate

* update stable protos
2021-09-23 14:55:19 +01:00
Moisés Ackerman
35666caae8
Add MINIMAL pragma for Additive type class (#11001)
* Add MINIMAL pragma for Additive type class

This ensures that the compiler gives an error if both (-) and negate are missing in an instance

Fixes #11000

changelog_begin
changelog_end

* Add test case to ensure incomplete Additive instance declaration triggers error message
2021-09-23 11:01:53 +00:00
Sofia Faro
d52a2857da
interface: Add test for conversion functions (#10991)
Test conversions of both payloads and contract ids

changelog_begin
changelog_end
2021-09-22 16:39:58 +00:00
Sofia Faro
34390f7062
interfaces: Implemented conversions, added test. (#10982)
Part of #10810

- Implemented ToInterface, FromInterface in speedy
- Added a test that exercises and fetches an interface
- Fixed a bug in SBUChoiceInterface

Hey, interfaces work now!

changelog_begin
changelog_end
2021-09-22 15:50:54 +01:00
Moritz Kiefer
99836d2610
Handle fetchByKey callback correctly in scenario runner (#10980)
fixes #10977

Turns out assertions are good unless they’re wrong …

This only affects scenarios, the engine never looks at the callback.

changelog_begin
changelog_end
2021-09-22 13:19:57 +02:00
Moritz Kiefer
4acf34b5fc
Add conversions from/to interfaces in Daml parser (#10954)
* Add conversions from/to interfaces in Daml parser

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-09-21 18:24:12 +00:00
Robin Krom
2edfc062a0
ifaces: name collision, typecheck fetch/exercise (#10896)
* ifaces: name collision, typecheck fetch/exercise

This adds name collision detection and adds typechecking for
fetch/exercising of interface instances.

CHANGELOG_BEGIN
CHANGELOG_END

* turn on exercises in InterfaceDesugared test case

* Update compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/NameCollision.hs

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-09-20 21:40:26 +00:00
Moritz Kiefer
cac8391d4c
Bump ghc-lib to include daml interfaces parser (#10747)
changelog_begin
changelog_end
2021-09-16 17:52:16 +00:00
Moritz Kiefer
9b0fa29aec
Separate exercise & fetch for interfaces from templates (#10908)
* Separate exercise & fetch for interfaces from templates

part of #10810

changelog_begin
changelog_end

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs

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

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-09-16 12:05:11 +00:00
Moritz Kiefer
f08ac5f65c
Desugar interface implements declarations (#10895)
* Desugar interface implements declarations

This PR adds desugaring for tplImplements. This consists of the
corresponding typeclass instance (which we just ignore in LF for now,
we probably need it once we have pure functions) and a _implements_
top-level value.

changelog_begin
changelog_end

* Address review feedback

changelog_begin
changelog_end
2021-09-15 19:48:59 +00:00
pbatko-da
6dcdaa411c
[DPP-589] Add CLI flag to select minimum enabled TLS version (#10854)
- Add support for specifying either 1.2 or 1.3 as minimum TLS versions for ledger api server.
- Log enabled protocols (~TLS versions) and cipher suites at server and client startup.
- Add integration tests against Sandbox-classic and Sandbox

CHANGELOG_BEGIN
Sandbox: Add CLI flag to select minimum enabled TLS version for ledger API server.
CHANGELOG_END
2021-09-14 12:37:38 +02:00
Moritz Kiefer
9a4c9df06a
Implement LF desugaring of interface definitions (#10834)
This only handles the interface definition, not the implementation in
the template. There are also a few rough edges:

1. It maks all choices as consuming.
2. it ignores locations

But for a poc that doesn’t seem too bad.

The tests don’t do anything super useful since the typechecker falls
over but I checked tha tthe generated LF looks more or less reasonable.

changelog_begin
changelog_end
2021-09-13 15:15:31 +02:00
Moritz Kiefer
6d347d4e88
Add daml interfaces to the Haskell LF AST (#10811)
* Add daml interfaces to the Haskell LF AST

Just copied from Sofia’s PR with no changes and stubbed all usages of
it that aren’t trivial.

changelog_begin
changelog_end
2021-09-08 15:48:02 +00:00
Moritz Kiefer
8830eaa2ec
Drop controller can syntax from compiler tests (#10807)
You definitely want to review this with whitespace disabled.

changelog_begin
changelog_end
2021-09-08 15:28:09 +02:00
Moritz Kiefer
e9c8af5024
Bump ghc-lib to include dropped parsing code for generic templates (#10735)
* Bump ghc-lib to include dropped parsing code for generic templates

changelog_begin
changelog_end

* bump snapshot

changelog_begin
changelog_end

* drop old generics file

changelog_begin
changelog_end

* drop other broken file

changelog_begin
changelog_end

* Bump again

changelog_begin
changelog_end

* bump to merged commit

changelog_begin
changelog_end

* and bump snapshots

changelog_begin
changelog_end
2021-09-01 15:35:40 +02:00
Moritz Kiefer
6016633bb7
Construct ParsedModule directly in Daml Repl (#10701)
This is a relatively large change unfortunately which unfortunately
requires reimplementing parts of the logic of the typechecker & core
compilation. I don’t think it is too bad but we might want to think
over time if we can factor this better.

This fixes #10073 and fixes #10664 by referencing the exact types
instead of going via the renamer.

There are some minor changes around error messages for "module not
found" errors. This is because these are now caught in the
typechecker instead of in our own code. We could keep the errors but
it requires duplicating even more logic and I don’t really see what it
buys us so I think I prefer the approach here.

changelog_begin

- [Daml Repl] Fix a bug where bindings with out of scope types would result in error in following lines.

changelog_end
2021-08-30 17:28:16 +02:00
Leonid Rozenberg
adbe65fae1
Document ActionFail vs CanAbort (#10657)
CHANGELOG_BEGIN
CHANGELOG_END
2021-08-25 20:51:29 +02:00
Moritz Kiefer
fc9d35935a
Drop alternative rules from dlint config (#10646)
We don’t have Alternative in daml-stdlib so these don’t make any sense.

changelog_begin
changelog_end
2021-08-25 12:52:51 +02:00
Moritz Kiefer
055be4b3cb
Disable deprecation warnings for data-dependencies (#10647)
Makes no sense to warn about this at this point since you cannot do
anything about this once that fails.

changelog_begin
changelog_end
2021-08-23 16:39:57 +02:00
fabiotudone-da
4a9331ca55
Upgrade Nixpkgs [KVL-1045] (#10624)
* Update the channels link in Upgrading.md

* Update the nixpkgs-unstable commit

CHANGELOG_BEGIN
CHANGELOG_END

* Fix new `hlint` warnings.

Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2021-08-20 12:34:19 +00:00
Robin Krom
0c1878530b
test: test for platform independent dars (#10535)
We add a CI test to check that dars don't depend on the underlying
operating system where the dar is build.

CHANGELOG_BEGIN
CHANGELOG_END
2021-08-17 18:59:12 +02:00
Sofia Faro
fb09b72f96
Improve divulgence warning message. (#10595)
Based on feedback from @bame-da on issue #9947

changelog_begin
changelog_end
2021-08-17 13:06:03 +01:00
hgrano
4430f52cdc
changelog_begin (#10579)
- [Daml Stdlib] Ord instance added for NonEmpty
changelog_end
2021-08-15 12:52:03 +02:00
Moritz Kiefer
c447898cc9
Fix display of unhandled exceptions in the scenario service (#10572)
fixes #10570

I’m increasingly convniced, that the future failures here are a
maintenance nightmare and we should switch to Either completely but
not in this PR

changelog_begin
changelog_end
2021-08-12 14:35:26 +02:00
Gary Verhaegen
9756bf8104
add minimumOn & maximumOn (#10527)
Requested in #10509. Should we also add `minimumBy` and `maximumBy` for
consistency with `sortBy`?

CHANGELOG_BEGIN
- The DA.List and DA.List.Total modules now export minimumBy, maximumBy,
  minimumOn and maximumOn, respectively behaving similarly to sortBy and
  sortOn.
CHANGELOG_END
2021-08-11 16:34:38 +00:00
Moritz Kiefer
348c6de92c
Add dlint rule to suggest === (#10485)
* Add dlint rule to suggest ===

This rule doesn’t quite work in all cases since you can have types
that have Eq instances but not Show instances. However, I think the
benefits of people learning about this are much larger than the
downsides here of getting a hint that doesn’t apply in edge cases.

changelog_begin
changelog_end

* fix all the tests, why are there so many :(

changelog_begin
changelog_end
2021-08-05 09:44:57 +00:00
Robin Krom
36f3ba8a6a
lsp-types patch for platform independence (#10288)
* fix shake rebuild tests

* patch pretty printing in ghc

* pin linux deps

* pin windows deps

* cosmetics

* address review

* update ghc commit hash

* pin linux stackage deps

* update stack snapshot

* pin windows deps
2021-08-04 21:33:52 +02:00
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
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
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
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
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
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
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
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
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
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
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