Commit Graph

1235 Commits

Author SHA1 Message Date
Sofia Faro
e52c2a0252
Bundle ghcversion.h and hpp with damlc. (#8278)
* Bundle hpp with damlc.

This PR eliminates the red squiggly lines you get when opening up the
standard library in daml studio (e.g. after a Go To Definitien).

(When CPP is used, Go To Definition is still pointing to the wrong place,
because the line numbers are messed up. But it's better than having a
million error messages.)

We could also remove --cpp flag in a separate PR, though that may be
considered a breaking change.

changelog_begin
changelog_end

* cleanup locateRunfiles jank

* Revert "cleanup locateRunfiles jank"

This reverts commit 82552003ae.
2020-12-14 17:23:41 +00:00
Remy
7d31135645
LF: retire VersionTimeline (#8273)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-14 16:56:47 +01:00
Robin Krom
54e442b2e5
damlc: warn on bad package names/versions. (#8254)
* damlc: warn on bad package names/versions.

This fixes #7208 and #7317. When package names or versions are
encountered in the daml.yaml that will be rejected by ghc-pkg when the
package is loaded as dependency, a big warning is output.

CHANGELOG_BEGIN
CHANGELOG_END

* hlint

* multiline strings

* update version regex

* update package name regex

* better error formatting regex printing
2020-12-14 16:44:43 +01:00
Remy
44c5b8a777
LF: remove version from value nested in GenNode. (#8217)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-11 17:12:14 +01:00
Remy
009b030463
LF: Simplify Language Version representation (#8258)
We drop the distinction (at the type level) of Dev and Stable language
version.  The two main reason that motivate this choice:
* we never really used this distinction.
* we want to add the concept of "preview" version (which is neither Dev nor Stable)

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-11 16:21:45 +01:00
Moritz Kiefer
5c077a4550
Add multi-party submissions to DAML Script (#8240)
* Add multi-party submissions to DAML Script

changelog_begin

- [DAMl Script] Add early-access submitMulti and submitMultiMustFail
  for multi-party submissions. This is only supported in DAML Studio at
  the moment.

changelog_end

* Fix daml-lf prettyprinter

changelog_begin
changelog_end

* Cleanup visibleIn

changelog_begin
changelog_end

* Fix JsonApiIt

changelog_begin
changelog_end

* s/Set()/Set.empty

changelog_begin
changelog_end

* Cleanup token check

changelog_begin
changelog_end

* Update daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/LedgerInteraction.scala

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

* Document ParticipantView

changelog_begin
changelog_end

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-12-11 12:45:32 +01:00
Gary Verhaegen
05b5473a76
replace daml-licenses with NOTICES (#8241)
At some point in time, `daml-licenses` was supposed to list the licenses
for all of our Haskell dependencies. It's not been updated in ages, and
we now have a reliable way to get at all our dependencies.

This is arguably a bit weird since the command is `daml damlc license`,
and it lists licenses for everything (`daml license` would make more
sense), but it seems a lot better to give a correst superset than an
incorrect list.

Perhaps we can move the command to `daml license` at some point, but I'd
see that as a separate step. (That would technically be a breaking
change, but I think this one might be OK.)

CHANGELOG_BEGIN
CHANGELOG_END
2020-12-10 16:46:13 +01:00
Gary Verhaegen
be2ad76897
fix link to AST (#8238)
CHANGELOG_BEGIN
CHANGELOG_END
2020-12-10 15:48:58 +01:00
Moritz Kiefer
5f1d5ad118
Fix prettyprinting in DAML REPL (#8214)
We used a weird mix of prettyprinting and string concatenation. This
breaks as soon as you have a line break somewhere because indentation
is messed up at that point. This PR fixes that by consistently (at
least more consistently than before) using the prettyprinting lib.

fixes #8213

changelog_begin

- [DAML REPL] Fix a bug where bindings with very long types sometimes
  resulted in parse errors on following lines. See #8213

changelog_end
2020-12-09 15:24:43 +01:00
Sofia Faro
84e5881236
Add serializability check for exceptions. (#8151)
* Add serializability check for exceptions.

Part of #8020

changelog_begin
changelog_end

* typo
2020-12-07 14:44:24 +00:00
Richard Kapolnai
9d2dd51684
Doc: fix minor issues in intro 2 (#8175)
* remove inadequate picture

* simplify example

* fix format in comment

* typo

* add signature screenshot

* dummy whitespace
CHANGELOG_BEGIN
CHANGELOG_END

* revert dummy whitespace
2020-12-05 16:23:12 +01:00
nickchapman-da
0867605e1a
Don't loose signatures in template let binding (#8136)
* update ghc-lib patch

* update stack-snapshot.yaml

changelog_begin
changelog_end

* bazel run @stackage-unpinned//:pin (on linux) and update stackage_snapshot.json

* testcase to check type signatures in template-lets are not ignored

* update to ghc-lib commit hash following merge

* update snapshot

* update snapshot after pin on windows

* update stack pin on linux

Co-authored-by: Nick Chapman <nchapman@digitalasset.com>
2020-12-03 15:08:02 +00:00
Sofia Faro
6b7f714c4d
Add exception type coherence check on Haskell side (#8137)
* Add exception type coherence check on Haskell side

changelog_begin
changelog_end

* update pretty instance

* follow martin suggestions
2020-12-02 14:36:22 +00:00
Sofia Faro
0df1a79ee3
Add DAML_EXCEPTIONS feature. (#8114)
* Add DAML_EXCEPTIONS feature.

Part of #8020. This extracts the DAML_EXCEPTIONS feature from #8023
since we need it for typechecking & LF conversion soon.

changelog_begin
changelog_end

* add full url

* add another url
2020-12-01 12:38:41 +00:00
Sofia Faro
6499ee9716
Add exceptions in DAML-LF AST (Haskell side) (#8112)
* Add exceptions in DAML-LF AST (Haskell side)

Updates the Haskell DAML-LF AST for exceptions, including
encode/decode, and updates all the functions that deal with the
AST directly.

changelog_begin
changelog_end

* Missed some TODOs in DecodeV1
2020-11-30 16:18:29 +00:00
Sofia Faro
72e2f7d967
Update protobuf for exceptions. (#8087)
* Update proto file for exceptions

* s/CONS/MAKE

* typo

* DefException

* var is interned

* fix DefException numbers

* adjust decoding slightly

* lint

* Update scala decoder.

changelog_begin
changelog_end

* update simplifier tests

* move the MAKE up front

* suggestions

* fix pretty

* add placeholder builtin infos on scala side

* add exceptions feature on scala side

* fix typos

* forgot THROW
2020-11-30 10:42:17 +00:00
Remy
e4869083fe
LF: drop support from deprecated LF versions. (#8083)
CHANGELOG_BEGIN
CHANGELOG_END
2020-11-27 21:33:45 +01:00
Samir Talwar
9976b4cd50
Bazel: Factor out logic around Protobuf JARs. [KVL-714] (#8084)
* kvutils: Use ScalaPB to generate a Scala JAR for daml_kvutils.proto.

* Bazel: Delete the unused `da_java_binary` rule, and inline `_wrap_rule`.

* Bazel: Factor out Java/Scala protobuf class generation into a helper.

CHANGELOG_BEGIN
CHANGELOG_END

* daml-lf/archive: Use `proto_jars`.

* Bazel: Remove the visibility modifier from `proto_jars`.

It's too confusing. Just make everything public.

* daml-lf/archive: Push protobuf source tarballs into `proto_jars`.

* Bazel: Add comments to the various parts of `proto_jars`.

* daml-assistant: Do unpleasant things with `location` in Bazel.
2020-11-27 08:34:53 +00:00
Remy
174ba1de30
Compiler: Clean compiler from from Exercise's actors (#8076)
This is the Haskell counterpart of #8071.
This advances the state of #7155.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-26 15:38:30 +01:00
Remy
41543ad161
LF: drop support for Exercise's actors (#8071)
This is a first set toward dropping support of deprecated LF version
(#7155).

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-26 14:38:16 +01:00
Sofia Faro
4ac8d7cdf1
Make featureCppFlag field optional. (#8014)
Some features, in particular daml-lf encoding features, don't make any sense to have an associated CPP flag. I made the CPP flag optional and removed these unnecessary feature flags (based mostly on whether the flags were used in the standard library).

changelog_begin
changelog_end
2020-11-19 12:40:41 +00:00
Sofia Faro
ddf1378273
Use a NonEmpty list in makeLocalValBinds. (#8013)
Rewrite makeLocalValBinds to make the non-emptiness of the `binds`
argument explicit.

changelog_begin
changelog_end
2020-11-19 11:29:19 +00:00
nickchapman-da
6a745ed1fa
Support choice observers in 1.dev (#7922)
* Adapt to new desugaring for choice observers.

update hash of ghc patch.

changelog_begin
changelog_end

update ghc patch to final version

update stack-snapshot hashes for ghc-lib(-parser)

update stackage_snapshot.json, following `bazel run @stackage-unpinned//:pin`

expose Optional constructors for desugared code to use

adapt LFConversion to expect a 4-tuple for a desugared choice def/sig

update LFConversion for choice-observers

first example using new choice observer syntax.

fix scala type checker to have correct scoping rules for choice-observers

remove comment from example which says it is broken

improve variable names

improve tests for choice-observer clause

only test choice-observers SINCE 1.dev

add jq queries for choice observeres

make positive statement in jq test which checks choice obserers are present

test behaviour of choice observers

squash me

typo

* test more choice-observer divulgence

* Update documention for choice observers.

changelog_begin
Support choice observers in 1.dev
changelog_end

* fix docs build

* fix daml docs choice-observers example

* address comments: rewording text

* annotate choices observers as early-access in documention

* split out documentation code-snippets which require --target=1.dev

* final tweaks to documentation text
2020-11-18 19:51:15 +00:00
Sofia Faro
6c7e37a330
Rewrite multiple binding lets sequentially. (#8006)
* Rewrite multiple binding lets sequentially.

This PR enforces a sequential evaluation and dependency on
multiple-binding lets, by rewriting,

  let x1 = e1
      x2 = e2
      ...
      xn = en
  in b

Into a chain of single-binding let expressions,

  let x1 = e1 in
    let x2 = e2 in
      ...
        let xn = en in
          b

And likewise, rewriting multi-binding let statements in a "do" block,

  do
      ...
      let x1 = e1
          x2 = e2
          ...
          xn = en
      ...

Into single-binding let statements,

  do
      ...
      let x1 = e1
      let x2 = e2
      ...
      let xn = en
      ...

This PR fixes #6788 and adds a bunch of tests.

This is a bugfix, but it may break existing code that relies on
out-of-order let bindings. The suggested fix is to simply reorder
the let bindings, placing them in order of their dependency.

CHANGELOG_BEGIN

- [DAML Compiler] The DAML compiler now enforces sequential
  ordering for ``let`` expressions with multiple bindings.
  This fixes a bug where ``let`` expressions would be evaluated
  in the wrong order.

CHANGELOG_END

* Update compiler/damlc/daml-preprocessor/src/DA/Daml/Preprocessor.hs

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

* adjust last binding behavior

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-11-18 19:32:08 +00:00
Martin Huschenbett
f0e5bed36f
DAML-LF: Add interning for type to DAML-LF 1.dev (#7893)
* DAML-LF: Add interning for type to DAML-LF 1.dev

We add two new features to DAML-LF 1.dev:

* a per package list (or table) of `Type` messages, and
* a new case in the `Type` message which is an index into this table.

In combination, these two features can be used to allow DAML-LF
encoders to perform hash-consing of `Type` messages. We also change the
Haskell implementation of our DAML-LF encoder to do exactly that when
targetting DAML-LF 1.dev.

Doing this has a few benefits:

1. The DALFs produced by `damlc` get smaller: I've seen a case where
   the size dropped from 69MB to 45MB.
2. DAML-LF decoders need to decode less data.
3. Decoded packages use less memory because identical structures are
   now shared. This is particularly helpful in situations where we need
   to keep the interface (or signature) of a package in memory for a
   long time.

This PR mostly takes care of the Haskell implementation. However, we
need to make the Scala implementation of the decoder aware of the new
features as well since we have tests that load DAML-LF 1.dev into the
engine. A decoder and _targeted_ tests on the Scala side will follow
in a separate PR.

CHANGELOG_BEGIN
CHANGELOG_END

* Make jq tests aware of type interning

CHANGELOG_BEGIN
CHANGELOG_END

* Improve jq test

CHANGELOG_BEGIN
CHANGELOG_END

* Apply Remy's suggestions

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

* Improve the imperative bits

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-11-18 11:14:30 +00:00
Moritz Kiefer
221dd5189f
Fix missing trace statements on failed submits (#7987)
changelog_begin

- [DAML Script] Fix a bug where trace statements from a failing
  transaction where not displayed in DAML Studio.

changelog_end
2020-11-17 17:09:24 +01:00
Robin Krom
5bfff4e9ba
sandbox: fail on already existing port-file. (#7929)
Fixes #7806. This aligns the port file behaviour of the sandbox with the
HTTP JSON API.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-17 11:08:37 +01:00
Sofia Faro
f7e096afc3
Make GHC recognise our ($) operator. (#7969)
* Make GHC recognise our ($) operator.

Fixes #4555 by moving ($) to GHC.Base and giving it a levity polymorphic
signature, as GHC expects. Added a regression test.

changelog_begin
changelog_end

* Update line numbers for debug...

* Fix `daml test-script` tests

changelog_begin
changelog_end

* fmt for the format gods

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-11-16 15:10:14 +00:00
Sofia Faro
f7ba14a4c4
Allow for lets before letrec transformation. (#7956)
* Allow for lets before letrec transformation.

Fixes #7953 by adjusting the letrec transformation to handle
(optional) nonrecursive lets before the letrec binding, and adds
a regression test.

changelog_begin
changelog_end

* typo

* apply martin suggestions
2020-11-12 23:25:39 +00:00
Martin Huschenbett
b926c6f061
damlc: Tiny improvement to DAML-LF type checker (#7948)
I suppose there's not much to say.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-11 15:41:15 +00:00
Sofia Faro
5d86abce55
Avoid generating ill-formed kinds in DAML compiler (#7944)
* Perform kind-checking in DAML compiler.

This PR avoids generating invalid kinds (i.e. kinds of the form k ->
Nat) during LF conversion, and adds a small "kind checking" step
whenever a type variable is introduced in the LF typechecker (since the
only way to get invalid kinds is to introduce them in a `forall`).

Right now there's no way to test that both the typechecker & the
conversion raise an error here, and in general, we try to always push
our LF type errors into GHC type errors or LF conversion errors. This
is something we can work on (adding actual LF typechecker tests). But
also, I verified manually that the type checker raises the error, in
the absence of the changes to LF conversion.

Ok, last point: The test case here has a weird location, but I tried and
couldn't figure out how to get a better location. I think this is a
general problem with the GHC Core representation?

changelog_begin
changelog_end

* Add more kind checks and restrict test version.

* fix test again
2020-11-11 14:43:20 +00:00
Sofia Faro
62cd53d402
Add a warning for GHC.Types.Symbol (#7921)
* Add a warning for GHC.Types.Symbol

CHANGELOG_BEGIN

- [DAML Compiler] Added a warning for references to
  the GHC.Types.Symbol kind since these cannot be
  preserved across data-dependencies.

CHANGELOG_END

* lint

* Address review comments

* fix LFNameCollisions test

* improve LFNameCollisions fix
2020-11-10 18:16:14 +00:00
Robin Krom
f78d375fe4
damlc: fix: relative output path relative to cwd (#7927)
* damlc: fix: relative output path relative to cwd

This fixes #7913. Build output path were considered relative to the
project root instead of the current working directory.

CHANGELOG_BEGIN
CHANGELOG_END

* adding a test
2020-11-10 15:05:06 +01:00
Robin Krom
a491002483
daml ledger: implementation of ledger commands via json api (#7885)
* daml ledger: implementation of ledger commands

Implementation of the remaining daml ledger commands via HTTP JSON
service endpoints instead of gRPC.

Fixes #4824 .

CHANGELOG_BEGIN
[daml assistant] `daml ledger` commands can now also be run against the JSON API instead of the gRPC API.
CHANGELOG_END
2020-11-09 16:24:45 +01:00
Martin Huschenbett
a83871b948
damlc: Check DAML-LF pattern matches for exhaustiveness (#7892)
* damlc: Check DAML-LF pattern matches for exhaustiveness

`damlc` has always produced exhaustive pattern matches in DAML-LF since
GHC adds a default branch with a call to `error` message as soon as a
pattern match is not exhaustive. It was a complete oversight on our
side that we did not enforce this properly in DAML-LF. Since `damlc`
has never produced non-exhaustive pattern matches, enforcing this now
and for all DAML-LF versions is only theoretically a breaking change,
namely if people hand-crafted DAML-LF, but not practically.

This check is as under-tested as the rest of our Haskell implementation
of the DAML-LF type checker. Well, all our other tests implicitly check
that the type checker does not give false errors. However, we have no
tests ensuring that the type checker is not too permissive. Fixing this
situation would require a big time investment since we currently don't
have a simple way to produce DAML-LF without going through GHC, which
will always produe well-typed DAML-LF.

I will update the DAML-LF specification wrt pattern matching
exhaustiveness in a separete PR.

This PR does not have a changelog entry since there's no impact for our
users.

CHANGELOG_BEGIN
CHANGELOG_END

* Make check linear in match size not constructor number

CHANGELOG_BEGIN
CHANGELOG_END

* Move lookupWithIndex in Data.List.Extended

CHANGELOG_BEGIN
CHANGELOG_END

* Implement the suggestions

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-06 17:15:04 +01:00
Martin Huschenbett
b01d327211
Haskell: Add hlint rule to suggest foldl' over foldl (#7897)
* Haskell: Add hlint rule to suggest foldl' over foldl

`foldl` is lazy in a way that almost never is what you want since it
can cause space leaks without any benefit. `foldl'` does not have this
problem. See https://www.well-typed.com/blog/2014/04/fixing-foldl/ for
more details.

CHANGELOG_BEGIN
CHANGELOG_END

* Fix all existing occurrences of foldl

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-05 18:32:44 +00:00
Martin Huschenbett
814e62caf5
damlc: Don't warn on TypeOperators and UndecidableInstances (#7909)
Currently, we're warning that both extensions might not work with
`data-dependencies`. However, we have tests that demonstrate that both
extensions actually do work with `data-dependencies`. Since there's
been customer demand to remove these warnings, we'll do so.

CHANGELOG_BEGIN
[damlc] Don't warn anymore that the language extensions TypeOperators
and UndecidableInstances might not work with `data-dependencies`.
CHANGELOG_END
2020-11-05 16:43:31 +00:00
Martin Huschenbett
123811cef9
damlc: Split data-deps test out of packaging tests (#7894)
The packaging test suite has become just so big that it regularly
exceeds its 15 min timeout. There are some deeper issues here, for
instance that we set up tons of tiny DAML projects and call
`daml build` on each of them. Each of those builds initializes a
package database, which is one of the things that seem to take
noticable time. Unfortunately, fixing these issues is a bigger effort.

This PR is more of a band aid rather than a proper solution: split the
packaging tests into two parts: the packaging tests and the tests for
data-depenendencies. Effectively, this amounts to giving the old
packaging test suite a 30 min time budges, but at least the two parts
can now be run in parallel.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-05 11:04:46 +01:00
Martin Huschenbett
075cab697b
damlc: Rotate type checking of case expressions by 90 degrees (#7873)
Currently, the Haskell implementation of the DAML-LF type checker
first branches on the pattern and then on the type of the scrutinee.
This PR changes it to first branch on the type of the scrutinee and
then on the pattern. This allows for destructing the type of the
scrutinee only once intead of repeating it for each pattern. This
should be good for performance, which is a nice side effect of this
change.

The main reason why I'm changing this is because we want to implement
an exhaustiveness check. This seems rather complicated to achieve with
the current implementation and will be significantly easier after this
change.

This PR is purely a refactoring and does not change the semantics of
amnything. In particular, it does not touch the decision that default
patterns match on anything, even no other pattern would match on the
value.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-04 13:06:00 +01:00
Sofia Faro
e75d42ddc3
Represent overlap modes at the type level. (#7864)
On request by @hurryabit, this PR changes the representation of
overlap modes by moving it to the type-level. Since the value-level
encoding never made it into a stable release, this isn't a breaking
change. Also, the data-dependency and roundtrip tests are unchanged,
only the daml-test-files overlap mode test had to be updated.

changelog_begin
changelog_end
2020-11-03 12:40:36 +00:00
Martin Huschenbett
5853d24a80
damlc: Make record projection sections faster (#7853)
Currently, `damlc` compiles a record projection section `(.foo.bar)`
into
```
getField @"bar" . getField @"foo"
```
Since we don't inline the `.`
operator, this is slower than it could be.

This PR changes the compilation scheme to produce
```
\record -> getField @"bar" (getField @"foo" record)
```
This is significantly faster since it avoids a couple of function
applications.

My micro benchmarks show a speedup of 1.8x for a single application of
`(.foo.bar)`. For a chain of length 3, as in `(.foo.bar.baz)`, the
speedup is even 2.3x.

This PR does add any new tests since the existing tests, particularly
the ones in `Records.daml`, already cover that area.

CHANGELOG_BEGIN
[daml] Performance improvements for record selector sections such as
`(.foo.bar)`.
CHANGELOG_END
2020-11-03 09:13:48 +01:00
Remy
21c1c951f1
LF: remove control of input/output value/transaction versions. (#7858)
This is made obsolete by #7788.

CHANGELOG_BEGIN
CHANGELOG_END
2020-11-02 20:02:53 +01:00
Martin Huschenbett
6572457973
damlc: Use fresh names when compiling builtins (#7809)
* damlc: Use fresh names when compiling builtins

Currently, we're always using the variables names `v1`, `v2`, ... for
the lambdas we introduce during the conversion of partially applied
builtins to DAML-LF. This can lead to problems when the variable name
is already in use. The test cases used to fail because of the usage of
`v2`.

This PR fixes the issue by properly generating fresh names. There's no
test case for type variables since I don't know how to trigger an
issue. Fixing it seems a good idea nevertheless.

CHANGELOG_BEGIN
CHANGELOG_END

* Add Sofia's suggestions

CHANGELOG_BEGIN
CHANGELOG_END

* Fix a nasty typo

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

* Fix more issues pointed out by Sofia

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2020-10-29 14:17:52 +01:00
Jussi Mäki
fa9bc4a984
Cache computation of top-level values at definition level (#7818)
* Cache computation of top-level values at definition level

Earlier the computation of a top-level value was only cached at the
use-site in SEVal. This introduces SDefinition which contains the same
mechanism as SEVal to cache the computation.

As expected this does not impact performance much:

before: CollectAuthority.bench  //daml-lf/scenario-interpreter/CollectAuthority.dar  CollectAuthority:test  avgt   40  44.267 ± 0.728  ms/op
after: CollectAuthority.bench  //daml-lf/scenario-interpreter/CollectAuthority.dar  CollectAuthority:test  avgt   40  43.693 ± 0.702  ms/op

What this does have a significant impact is on reducing the number of distinct
SValues for things like type class dictionaries etc, so that now we have one
SValue per dictionary rather than one per SEVal.

CHANGELOG_BEGIN
CHANGELOG_END

* Address code review

* Fix speedy tests
2020-10-28 13:39:20 +00:00
Sofia Faro
5aa5ea6f41
Add roundtrip tests for MetadataEncoding. (#7833)
* Add roundtrip tests for MetadataEncoding.

changelog_begin
changelog_end

* buildifier fixx
2020-10-28 13:09:40 +00:00
Sofia Faro
3f64a6ae8d
Add MINIMAL pragma support in data-deps. (#7815)
* Add MINIMAL pragma support in data-deps.

CHANGELOG_BEGIN

- [DAML Compiler] MINIMAL pragmas are now imported correctly
  in data-dependencies.

CHANGELOG_END

* fix test

* Review comments

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

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
2020-10-28 10:37:23 +00:00
Sofia Faro
201a6e8c1b
Refactor fun dep and overlap mode implementations. (#7810)
* Refactor fun dep and overlap mode implementations.

This PR moves the functional dependency and overlap
mode encoding/decoding functions to a single module,
separate from the rest of LF conversion or
data-dependencies, in preparation of adding more
annotations of this sort (e.g. MINIMAL).

This involves a small amount of refactoring to get
the types to line up... It should be a little easer
to write some roundtrip tests for these now.

I'm not super satisfied with how much fun dep / overlap
mode logic is still left in LFConversion.hs and
DataDependencies.hs, but this is a step in the right
direction at least.

changelog_begin
changelog_end

* Rename Encoding to MetadatEncoding
2020-10-26 15:59:39 +00:00
Martin Huschenbett
e49b07092a
damlc: Minor cleanup in setFieldPrim conversion (#7802)
That `setFieldPrim` is so far away from `getFieldPrim` has bugged me
for a while now. I _strongly_ feel that they should be next to each
other.

There are also a few outdated comments that are brought up to date.

CHANGELOG_BEGIN
CHANGELOG_END
2020-10-26 08:57:25 +00:00
Martin Huschenbett
9dec66899b
Compiler: Add more tests for record projection conversion (#7786)
This PR adds a couple of tests that ensure that various syntactic
variants of record projection all get translated into the according
DAML-LF primitive as soon as we know the record type and field name.

This PR also fixes some inconsistencies in the translations of
`getField` and `getFieldPrim`. The change for `getField` does not have
any impact if the simplifier is run since the simplifier would perform
the inlining for a partially applied `getField` we perform here.

Nevertheless, performing this inlining in the conversion to DAML-LF has
some advantages. First of all, we also run it in cases where the
simplifier is turned off, like incremental computation. Second, this is
such a crucial optimization that I want to be as sure as possible that
it is run. Third, doing the inlining in the conversion is cheap and
removes a bit of load from the simplifier. Fourth, the consistency with
the other record primitives is quite nice too.

CHANGELOG_BEGIN
CHANGELOG_END
2020-10-23 13:32:33 +02:00
Martin Huschenbett
35a401f575
Fix scenario service vs struct projections bug (#7778)
* Fix scenario service vs struct projections bug

In a recent change, we have sped up the projection from structural
records by means of an inference in the DAML-LF type checker. This
change was made under the assumption that users of the DAML interpreter
run through package validation before compiling to the internal Speedy
AST. Unfortunately, that assumption was wrong and not covered by our
existing tests.  Manually testing of a new release candidate reminded us
of the fact that the scenario service skips package validation for the
sake of faster response times in the IDE.

This PR drops the assumption that package validation is always run.
Instead, we add the old implementation of struct projection, which works
without DAML-LF type checking, back and use it whenever the AST has not
been annotated with the information inferred by the type checker. We do
the same for struct updates.

We improve test coverage by _additionally_ running the `damlc`
integration tests without package validation for the latest stable
version of DAML-LF and DAML-LF 1.dev. These tests would have caught the
issue we only discovered during manual testing.

CHANGELOG_BEGIN
CHANGELOG_END

* Add some explanations

CHANGELOG_BEGIN
CHANGELOG_END
2020-10-23 13:30:56 +02:00