Commit Graph

233 Commits

Author SHA1 Message Date
Moisés Ackerman
1f2b709781
Data.NameMap: remove runtime check on HOF name changes (#14907)
* Add 'damlc validate-dar' test case for interface definition

* Add failing 'damlc validate-dar' test cases for interface instances

* Remove instance MonoTraversable e (NameMap a) from Data.NameMap

* Add (orphan) instance MonoTraversable ModuleRef (NameMap a) in DA.Daml.LF.Ast.Optics

* Data.NameMap: remove runtime check on HOF name changes

changelog_begin
changelog_end
2022-09-02 14:36:29 +00:00
dylant-da
804a0b7b9d
Reenable tests from #14773 #14770 / Add new tests for 1.15 (#14836)
* Squashed commit of the following:

commit fd04d54efffdd182b15ed5350ac190fd7e800f2c
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 14:46:19 2022 +0100

    lint

commit 117a3e1253cbede690127b66ee73a7ad7a75fd51
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 13:16:00 2022 +0100

    Temporarily disable isCompleted assertions - they appear to be too eager

commit a17e30b045affad557c1282b9c56229f64ab0d51
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 12:21:40 2022 +0100

    Remove unnecessary NotExtended tests, fix module names, reenable some

commit 075a62e6f263b86a342e887a0015cf0b812ad4e1
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 10:48:24 2022 +0100

    Remove InterfaceConversions - interface exercises are now Interface-only

commit 4b8a7b4a061ea740e5b72c06b99cf6eaced2315d
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 10:39:03 2022 +0100

    Update carbon test names for 1.dev suite test

commit 04e735223cc2c06fa3dd014538edcc5e4d5dd191
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 10:23:45 2022 +0100

    Point to 1.15 for carbon tests

commit 450e49479fc2daed3bc6a08234a95df8fe80382e
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 10:11:23 2022 +0100

    Move InterfaceSubscriptionsIT test to 1.15 folder

commit b1cd99d8074f789927d2e02b46a085fcd7a88319
Merge: 1dfdc2e7c5 f21b165c78
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 29 09:47:09 2022 +0100

    Merge remote-tracking branch 'origin/main' into dylan-lf-15-reenable-tests

commit 1dfdc2e7c503e9d798b60bc1279633295e50bb0c
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 25 16:58:37 2022 +0100

    Add NotExtended versions of all tests which use extended interfaces

commit 6398fa96c5c1d14dda1ff724d3d4b5de6301b97b
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 25 13:01:30 2022 +0100

    Make versions of tests that are NotExtended

commit c2daf05e134ab3d0d27d83a7ef24e07553b15c3e
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 25 12:20:03 2022 +0100

    Reenable disabled tests from #14770 / #14773

commit f390d37941
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 25 11:56:52 2022 +0100

    Remove 1.dev-only references from 1.15 protobuf

commit 87d6b540aa
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 25 11:36:08 2022 +0100

    Temporarily disable failing damlc tests

commit 05ea7bdb75
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 25 09:49:08 2022 +0100

    Update desugared daml for UExerciseInterface[Guarded] generation

commit 14fdd5f725
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 25 09:44:59 2022 +0100

    Run damlc interface tests w/o requires when since DAML_INTERFACE

commit d73c86df3f
Merge: 9a83d0776e 00705af419
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Wed Aug 24 16:35:31 2022 +0100

    Merge remote-tracking branch 'origin/main' into dylan-lf-15-minimal-distinguish-guards

commit 9a83d0776e
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Wed Aug 24 15:22:59 2022 +0100

    Exclude via $cexerciseGuarded check - ClassOpId approach did not work

commit b635dcd7cb
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Wed Aug 24 12:59:57 2022 +0100

    Add check for isId to splitDFunId

commit dcfa1e0ebf
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Wed Aug 24 11:43:19 2022 +0100

    Remove all instances of guarded exercises in versions <= 1.15

commit b0985ccdbd
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 23 13:10:15 2022 +0100

    Remove guarded exercise when Extended Interfaces are not enabled

commit 125280ca60
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 15:33:55 2022 +0100

    Clarify purpose of `Maybe Expr` type for exercise guard

    Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

commit 50cff3004b
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 15:32:17 2022 +0100

    Remove unnecessary mention of v1_14 from supportedInputVersions

    Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

commit 89744ef341
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 15:31:04 2022 +0100

    Rename interface features

    Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

commit c173799c47
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 15:23:13 2022 +0100

    Attach correct range to guard support error (if any)

    Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

commit c41f8480ed
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 18 12:57:28 2022 +0100

    Update to new GHC revision, removes pred argument from `exercise`

commit d9dfe87252
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 16 12:06:04 2022 +0100

    Desugar UExerciseInterface[Guarded] differently, point to updated GHC

commit dd0ac96dcd
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 16 12:05:53 2022 +0100

    Make exercise guards nullable, ignore Nothing in decode/encode

commit 53e23fac26
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 23 13:13:09 2022 +0100

    lint

commit abf5267051
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 23 12:50:04 2022 +0100

    Move InterfaceSubscriptionsIT test back into 1.dev suite

commit c2d1499747
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 23 12:00:17 2022 +0100

    Use dictionary comprehension to generate ledger/test-common test_names

commit 0d5f167fc6
Merge: 0242452662 ec4c86ac2d
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 23 10:27:21 2022 +0100

    Merge remote-tracking branch 'origin/main' into dylan-lf-15-minimal

commit 0242452662
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 23 10:26:29 2022 +0100

    Temporarily disable decode extended interface primitives test

commit b17ca7f03c
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 16:26:10 2022 +0100

    lint

commit ceaca2b0f6
Merge: c11eb08083 95d00c4e8a
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 16:12:43 2022 +0100

    Merge remote-tracking branch 'origin/main' into dylan-lf-15-minimal

commit c11eb08083
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 15:20:50 2022 +0100

    Disable PureConfigReaderWriter tests that assume early-access == stable

commit 03734d2f23
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 14:02:55 2022 +0100

    Also disable conformance-test-tls1.2-or-newer-1.15

commit e683ea3d7c
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 14:00:45 2022 +0100

    Temporarily disable 1.15 conformance tests - handle in another PR

commit 6fb140b0b6
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 13:59:58 2022 +0100

    lint

commit 65531fe577
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 22 11:00:41 2022 +0100

    Run retroactive implements tests only in extended interfaces

commit edf20bf4a7
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Fri Aug 19 17:48:39 2022 +0100

    Fix StableVersions back to 1.14, make EarlyAccessVersions 1.15

commit 12818dc58f
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Thu Aug 18 18:06:36 2022 +0100

    Allow unsafe_from_interface and interface_template_type_rep in 1.15

commit ff7271de1a
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Fri Aug 19 10:55:40 2022 +0100

    Update tests with extended interface features to only run on 1.dev

commit 9558feaec8
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Fri Aug 19 16:47:19 2022 +0100

    satisfy changelog check

    CHANGELOG_BEGIN
    CHANGELOG_END

commit 337cc25b7a
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Wed Aug 17 16:36:45 2022 +0100

    Fix InterfaceNotSupported message to 1.15 or higher

commit 4282ae396b
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 16 17:41:15 2022 +0100

    Move v1_15 ledger-api-tests into own suite

commit ac3d0a9f25
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Fri Aug 19 15:18:41 2022 +0100

    Reinclude 1.15 in COMPILER_LF_VERSIONS to build model-tests-1.15

commit 718879020d
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Fri Aug 19 14:43:35 2022 +0100

    Add 1.15 test suite to testtool

commit a6fd63d3d9
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Fri Aug 19 14:43:23 2022 +0100

    Add 1.15 as preview version

commit f5c48ddc99
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Fri Aug 19 14:43:12 2022 +0100

    Make 1.14 default again

commit b9527c1136
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Wed Aug 17 14:23:16 2022 +0100

    Update Version 1.15 changelog with Call/implements

commit 9cecad5205
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Wed Aug 17 11:24:49 2022 +0100

    Add Tests file for 1.15 in ledger API testtool

commit cde583d08d
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 16 16:41:58 2022 +0100

    Remove references to dev from 1.15 protobufs

commit 904da5679b
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 16 13:04:19 2022 +0100

    Stage 1.15 protobuf

commit 196fa6a3cf
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Tue Aug 16 11:54:20 2022 +0100

    Update Ast/Version & docs for 1.15, split interface into simple/extended

commit 1c58421f2d
Author: Dylan Thinnes <dylan.thinnes@digitalasset.com>
Date:   Mon Aug 15 13:05:37 2022 +0100

    Add version 1.15 - move interfaces into them

* API-test-tool: add InterfaceSubscriptionsIT to LF 1.15 tests

CHANGELOG_BEGIN
CHANGELOG_END

* fix bug

* Add version 1.15 - move interfaces into them

* Update Ast/Version & docs for 1.15, split interface into simple/extended

* Make 1.14 default again

* Update tests with extended interface features to only run on 1.dev

* Fix StableVersions back to 1.14, make EarlyAccessVersions 1.15

* Run retroactive implements tests only in extended interfaces

* Disable PureConfigReaderWriter tests that assume early-access == stable

* lint

* Move InterfaceSubscriptionsIT test back into 1.dev suite

* lint

* Remove unnecessary mention of v1_14 from supportedInputVersions

Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

* Run damlc interface tests w/o requires when since DAML_INTERFACE

* Temporarily disable failing damlc tests

* Reenable disabled tests from #14770 / #14773

* Move InterfaceSubscriptionsIT test to 1.15 folder

* Remove InterfaceConversions - interface exercises are now Interface-only

* Re-enable assertEquals

* Modify PureConfigReaderWriterSpec to account for stable != early-access

* Disable conformance tests

* Disable on-canton conformance_test instead

* Remove InterfaceTypeRepCheck - all exercises are on interface now

* Fix UpcastDowncast tests

* Fix DowncastUpcast 1.15 test, convert assets to token in Guarded test

* Move typerep/unsafeFromInterface decode tests to basic interfaces

* Fix desugared daml for damlc test changes

* Reintroduce InterfaceConversions - remove impossible exercise

This reverts commit 075a62e6f263b86a342e887a0015cf0b812ad4e1.

* Reintroduce InterfaceTypeRepCheck - fix test to use T2Choice

This reverts commit d8a0a7f299.

* Run InterfaceTypeRepCheck for LF 1.15

Co-authored-by: Remy Haemmerle <Remy.Haemmerle@daml.com>
Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
2022-08-30 13:58:31 +00:00
dylant-da
6ece737e46
Desugar guards compatibly with 1.15/1.dev split (#14773)
* Add version 1.15 - move interfaces into them

* Update Ast/Version & docs for 1.15, split interface into simple/extended

* Stage 1.15 protobuf

* Remove references to dev from 1.15 protobufs

* Add Tests file for 1.15 in ledger API testtool

* Update Version 1.15 changelog with Call/implements

* Make 1.14 default again

* Add 1.15 as preview version

* Add 1.15 test suite to testtool

* Reinclude 1.15 in COMPILER_LF_VERSIONS to build model-tests-1.15

* Move v1_15 ledger-api-tests into own suite

* Fix InterfaceNotSupported message to 1.15 or higher

* satisfy changelog check

CHANGELOG_BEGIN
CHANGELOG_END

* Update tests with extended interface features to only run on 1.dev

* Allow unsafe_from_interface and interface_template_type_rep in 1.15

* Fix StableVersions back to 1.14, make EarlyAccessVersions 1.15

* Run retroactive implements tests only in extended interfaces

* lint

* Temporarily disable 1.15 conformance tests - handle in another PR

* Also disable conformance-test-tls1.2-or-newer-1.15

* Disable PureConfigReaderWriter tests that assume early-access == stable

* lint

* Temporarily disable decode extended interface primitives test

* Use dictionary comprehension to generate ledger/test-common test_names

* Move InterfaceSubscriptionsIT test back into 1.dev suite

* lint

* Make exercise guards nullable, ignore Nothing in decode/encode

* Desugar UExerciseInterface[Guarded] differently, point to updated GHC

* Update to new GHC revision, removes pred argument from `exercise`

* Attach correct range to guard support error (if any)

Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

* Rename interface features

Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

* Remove unnecessary mention of v1_14 from supportedInputVersions

Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

* Clarify purpose of `Maybe Expr` type for exercise guard

Co-Authored-By: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>

* Remove guarded exercise when Extended Interfaces are not enabled

* Remove all instances of guarded exercises in versions <= 1.15

* Add check for isId to splitDFunId

* Exclude via $cexerciseGuarded check - ClassOpId approach did not work

* Run damlc interface tests w/o requires when since DAML_INTERFACE

* Update desugared daml for UExerciseInterface[Guarded] generation

* Temporarily disable failing damlc tests

* Remove 1.dev-only references from 1.15 protobuf

Co-authored-by: Moisés Ackerman <6054733+akrmn@users.noreply.github.com>
2022-08-25 14:20:03 +01:00
dylant-da
a74c020ddd
Add version 1.15 - move interfaces into them (#14770)
* Add version 1.15 - move interfaces into them

* Update Ast/Version & docs for 1.15, split interface into simple/extended

* Stage 1.15 protobuf

* Remove references to dev from 1.15 protobufs

* Add Tests file for 1.15 in ledger API testtool

* Update Version 1.15 changelog with Call/implements

* Make 1.14 default again

* Add 1.15 as preview version

* Add 1.15 test suite to testtool

* Reinclude 1.15 in COMPILER_LF_VERSIONS to build model-tests-1.15

* Move v1_15 ledger-api-tests into own suite

* Fix InterfaceNotSupported message to 1.15 or higher

* satisfy changelog check

CHANGELOG_BEGIN
CHANGELOG_END

* Update tests with extended interface features to only run on 1.dev

* Allow unsafe_from_interface and interface_template_type_rep in 1.15

* Fix StableVersions back to 1.14, make EarlyAccessVersions 1.15

* Run retroactive implements tests only in extended interfaces

* lint

* Temporarily disable 1.15 conformance tests - handle in another PR

* Also disable conformance-test-tls1.2-or-newer-1.15

* Disable PureConfigReaderWriter tests that assume early-access == stable

* lint
2022-08-23 13:39:16 +00:00
Moisés Ackerman
ed046a11b5
Pretty print interfaces (#14742)
* Pretty print interface instances in templates

* Pretty print interface definitions, including nested interface instances

changelog_begin
changelog_end
2022-08-18 10:42:01 +02:00
Moisés Ackerman
009c3c306b
Add interface instance syntax, including retroactive interface instances (#14715)
* Extract qualifyLocally in LFConversion

* Update ghc rev

* Add parent type argument to interface instance desugaring types

* Check interface instance parent in LFConversion

* Convert interface instances in interface declarations

* Update daml-test-files to use 'interface instance' syntax

* Update other tests to use 'interface instance' syntax

* Update interface reference docs to use 'interface instance' syntax

* Update other files to use 'interface instance' syntax

* Add todo in DA.Daml.LF.Ast.Pretty

* Add daml-test-files for retroactive interface instances

changelog_begin
changelog_end
2022-08-17 12:06:59 +00:00
Moisés Ackerman
ad2740498b
Interface instance typechecking (haskell) (#14683)
* Remove -XRankNTypes in DA.Daml.LF.TypeChecker.Check

* Add TemplateOrInterface type in Haskell

* Define type InterfaceInstanceHead in daml-lf-ast

* Define 'lookupInterfaceInstance'

* Use lookupInterfaceInstance for checking implemented interfaces

* Use lookupInterfaceInstance for checking required interfaces

* Extract checkInterfaceInstance from checkIfaceImplementation

* Reword 'implements' errors in terms of interface instances

* Introduce tmplParam in checkInterfaceInstance

* Check interface instances in interface

* Add InterfacePart argument to ContextDefInterface

changelog_begin
changelog_end
2022-08-11 10:53:41 +00:00
Moisés Ackerman
c146bee87d
Reduce duplication between implements and co-implements (#14607)
* Reduce duplication between implements and co-implements

This extracts the common part (methods and view) to a new type InterfaceInstanceBody

changelog_begin
changelog_end
2022-08-04 17:01:15 +02:00
Remy
b163638d19
Damlc: Remove precondition for interface (#14548)
* Damlc: Remove precondition for interfaces

follow up of #14511, goes together with digital-asset/ghc#129

* Address Ackerman's review

* Update ghc rev

CHANGELOG_BEGIN
CHANGELOG_END
2022-07-28 16:34:12 +00:00
dylant-da
8d93efdd12
Add EViewInterface to LF - stub compilation/interpretation in speedy (#14486)
* Add ViewInterface to LF - stub interpretation in speedy

* Remove templateId and viewtype from EViewInterface

* Fix lint
2022-07-21 15:10:53 +00:00
dylant-da
ab948dd8de
Update LF AST protobuf for interface viewtype and implementation view (#14439)
* Update protobuf to include viewtype and implementation view

* Stub interface viewtype and implements view in updated AST

* Set views on Java builders in DecodeV1Spec

CHANGELOG_BEGIN
Update LF AST protobuf for interface viewtype and implementation view -
not currently linked to syntax or engine changes, all stubbed out in
LFConversion.
CHANGELOG_END

* Add view field to CoImplements

* Update iterators & parsers to account for CoImplements view

* Replace uses of TBuiltin(BTUnit) with TUnit

* Remove superfluous "Available in versions >= 1.dev" comment

* Fix missing TUnit imports, missing view param in daml-lf/parser

* Remove unused imports from DecodeV1Spec

* Add stub view in AstSpec
2022-07-19 12:00:04 +00:00
Moisés Ackerman
ee394702b8
Add CoImplements to DefInterface in protobuf (#14053)
* Update docstring for TemplateImplements.tpiMethods
    * The change happend on https://github.com/digital-asset/daml/pull/13142

* Add CoImplements to DefInterface in protobuf
    * Also adds encoding/decoding logic in the haskell side

* Part of https://github.com/digital-asset/daml/issues/14047

changelog_begin
changelog_end
2022-06-03 16:05:18 +00:00
Remy
ae8f50dbb8
LF: drop inheretedChoices from Implements (#14068)
part of #13653

CHANGELOG_BEGIN
CHANGELOG_END
2022-06-02 18:48:54 +00:00
Remy
ea0d101913
Interface: Rename fixedChoice to choice (#13883)
CHANGELOG_BEGIN
CHANGELOG_END
2022-05-17 12:03:53 +02:00
Moisés Ackerman
f59d1cd0b4
Convert experimental primitive TYPEREP_TYCON_NAME into proper LF builtin (#13465)
* Convert experimental primitive TYPEREP_TYCON_NAME into proper LF builtin

* Add entry for TYPEREP_TYCON_NAME in daml-lf spec

* disable quickcheck test in DA.Test.Packaging

changelog_begin
changelog_end
2022-03-31 14:35:46 +02:00
Moisés Ackerman
f9f1611d46
Unsafe interface conversion primitives (#13391)
* Add unsafeFromInterface method to HasFromInterface class

* Use unsafeFromInterface instead of fromInterface + experimental primitive

* Drop THROW_WRONGLY_TYPED_CONTRACT experimental primitive

* Add UnsafeFrom{,Required}Interface LF primitives

* Add convertPrim cases for UnsafeFrom{,Required}Interface

* Add InterfaceGuarded tests for WronglyTypedContract cases

changelog_begin
changelog_end

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2022-03-25 10:07:14 +00:00
Sofia Faro
1feb4d25eb
Drop typerep argument from ExerciseInterface. (#13284)
* ifaces: Remove typerep arg from UExerciseInterface

changelog_begin
changelog_end

* Drop typerep argument in protobuf and haskell ast

changelog_begin
changelog_end

* scalafmt

* fix ExprParser

* fix PhaseOneTest

* fix validation test

* update evidencing security
2022-03-15 13:53:06 +00:00
Gary Verhaegen
dfa648f585
hunt down DAML better (#13195)
Process:

- `git ls-files -z | xargs -0 -n 100 sed -i --follow-symlinks 's/DAML/Daml/g'`
- `git add -p`
- `git restore -p`
- Check there is no unstaged change left.

To review:

- Check for false positives by carefully reviewing the diff in this PR.
- Check for false negatives with `git grep DAML`.
- Quicker check for fals positives:

```
git grep DAML | grep -v migration | grep -v DAML_
```

Fixes #13190

Note: This is the "second half" of #13191, which failed to cover all the
remaining DAMLs because of:

```
$ git ls-files | grep "'"
compiler/damlc/tests/daml-test-files/MangledScenario'.daml
```

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-08 17:04:58 +01:00
Gary Verhaegen
961ca80b77
hunt down DAML (#13191)
Process:

- `git ls-files | xargs sed -i 's/DAML/Daml/g'`
- `git add -p`

To review:

- Check for false positives by carefully reviewing the diff in this PR.
- Check for false negatives with `git grep DAML`.

CHANGELOG_BEGIN
- Removed all traces of DAML. This may affect error messages and debug
  outputs.
CHANGELOG_END
2022-03-08 14:25:25 +01:00
Sofia Faro
b842b53ff4
Delete vestigial InterfaceChoice from AST (#13017)
* Delete vestigial InterfaceChoice from AST

This is a leftover from when interfaces had virtual choices.

changelog_begin
changelog_end

* delete more
2022-02-22 13:59:04 +00:00
Moisés Ackerman
3ce272b9f0
Replace experimental interface primitives with proper LF primitives (#12678)
* Add new primitives to proto spec

* implement E{Signatory,Observer}Interface in terms of EResolveVirtual{Signatory,Observer}

* define EToTypeRep primitive in terms of EToTypeRep Expr

* Remove experimental primitives TO_TYPE_REP and RESOLVE_VIRTUAL_{SIGNATORY,OBSERVER} 

changelog_begin
changelog_end
2022-02-03 13:36:45 +00:00
Moisés Ackerman
403efa70ba
Add support for interfaces through data-dependencies (#12516)
* reconstruct HasMethod instances from interface definitions

* reconstruct DamlInterface context

changelog_begin
changelog_end
2022-01-26 16:34:39 +00:00
Gary Verhaegen
d2e2c21684
update copyright headers (#12240)
New year, new copyright, new expected unknown issues with various files
that won't be covered by the script and/or will be but shouldn't change.

I'll do the details on Jan 1, but would appreciate this being
preapproved so I can actually get it merged by then.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-03 16:36:51 +00:00
Moritz Kiefer
77a37cf213
Drop damlc code for LF <= 1.11 (#12121)
* Drop damlc code for LF <= 1.11

Still a tiny bit left for pre 1.14 but this covers most of it.

changelog_begin
changelog_end

* delete numeric equal prmitives

changelog_begin
changelog_end
2021-12-13 14:19:48 +00:00
Moritz Kiefer
82465e2e85
Drop Decimal completely from damlc (#12120)
no need to keep it if we can neither read nor write it.

changelog_begin
changelog_end
2021-12-13 12:30:53 +00:00
Moritz Kiefer
36106c39de
Drop featureNumeric (#12119)
Also unused now that we only support LF >= 1.14.

changelog_begin
changelog_end
2021-12-13 11:20:04 +00:00
Moritz Kiefer
7f76cf1bdf
Drop featureAnyType and featureTypeRep (#12112)
and ofc drop the codepaths that use it.

All pre LF < 1.14 so unused and untested.

changelog_begin
changelog_end
2021-12-13 10:25:20 +01:00
Moritz Kiefer
778def6f48
Drop non-type synonym code from LF conversion (#12110)
* Drop non-type synonym code from LF conversion

We stopped emitting LF < 1.8, this is unused and untested at this
point.

changelog_begin
changelog_end

* drop parameter from mkDictProj

changelog_begin
changelog_end

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

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

Co-authored-by: Sofia Faro <sofia.faro@digitalasset.com>
2021-12-10 16:32:46 +00:00
Sofia Faro
04dd386dcc
interfaces: Add up/downcast in haskell AST (#12048)
Adds EToRequiredInterface and EFromRequiredInterface in
the Haskell AST, and the typechecker.

Part of #11978

changelog_begin
changelog_end
2021-12-08 13:22:08 +00:00
Sofia Faro
1dd813170d
interfaces: Add "requires" field in Haskell AST. (#12016)
* interfaces: Add "requires" field in Haskell AST.

Part of #11978. Adds typechecking for this on the interface and
implementation side.

changelog_begin
changelog_end

* Fix all the errors
2021-12-07 17:01:45 +00:00
Moritz Kiefer
cf172619e5
Drop support for Daml-LF party literals-LF from the Haskell side (#11930)
This PR enforces that forbidPartyLiterals is always `true` and drops
the corresponding literals from the AST in our Haskell code. Scala
code will follow separately.

part of #11581

changelog_begin
changelog_end
2021-12-01 11:00:09 +01:00
Moritz Kiefer
16135e6f7c
Limit supported input versions in damlc to >= LF 1.8 (#11905)
* Limit supported input versions in damlc to >= LF 1.8

1.8 was the version that introduced type synonyms, we really don’t
gain much by dropping more since data-dependencies mainly depends on
that. and this provides for a very natural upgrade path for users
where pretty much everyone should be able to upgrade directly to SDK
2.0 without having to go through intermediate versions.

changelog_begin

- [Daml Compiler] The supported input LF versions for
  data-dependencies are now limited to LF 1.8 and newer.

changelog_end

* fix some tests

changelog_begin
changelog_end

* Drop export 1.6 tests

changelog_begin
changelog_end

* Drop daml2js support for LF < 1.8

changelog_begin

- [Daml2js] DARs with LF version < 1.8 are no longer supported.

changelog_end

* .

changelog_begin
changelog_end

* bash is bad, stop using it

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2021-11-30 17:24:08 +01:00
Sofia Faro
1d7bca801e
Add optional typerep argument in UExerciseInterface. (#11910)
* Add type rep argument for interface exercises.

(Still WIP.)

Part of #11703. Fixes the order in which errors are raised ("wrong type"
takes priority over "does not implement interface"). This PR also simplifies
ExerciseInterface by making the guard mandatory, otherwise there's too
many variations. We can revisit that later if we want.

changelog_begin
changelog_end

* haskell side

* dont throw exception in checkTemplateId

* scalafmt

* evidence security

* fix TypingSpec test
2021-11-30 15:10:33 +00:00
Moritz Kiefer
5785bbfcfd
Drop LF < 1.14 from supported damlc output versions (#11701)
* Drop LF < 1.14 from supported damlc output versions

fixes #11319

We keep test coverage by depending on the most recent snapshot which
still has 1.14 support.

changelog_begin

- [Daml Compiler] Damlc can only produce Daml-LF 1.14 or
  newer. Passing aynthing older to `--target` is an error. If you
  need to produce older versions, use an older SDK.

changelog_end

* Switch around legacy_compiler_lf_versions

changelog_begin
changelog_end

* drop since-lf

changelog_begin
changelog_end
2021-11-22 16:20:17 +00:00
Moritz Kiefer
3b5f8a73e1
Remove precondition field from TemplateImplements (#11763)
* Remove precondition field from TemplateImplements

fixes #11635

changelog_begin
changelog_end

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala

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

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-18 17:10:40 +01:00
Sofia Faro
87f282c7f3
interfaces: Preserve/provide by_interface data for create actions. (#11639)
* interfaces: Preserve by_interface data for create.

Part of #10915

This was a lot more involved than fetch or exercise. The first issue is
that we need to preserve the interface id into speedy, so it needs a
separate primitive ("experimental" won't cut it). Second, because
speedy's create requires the template definition, and now the interface
id as well, we basically need to compile a separate version of "create"
for each interface that a template implements, hence the separate
`CreateByInterfaceDefRef(templateId, ifaceId)`.

changelog_begin
changelog_end

* scalafmt and refactoring

* fixx merge conflict

* fix silly mistakes
2021-11-11 12:57:55 +00:00
Moritz Kiefer
3bed7a9b4f
Drop unused defaultFeatureFlags (#11580)
I believe this is still from Daml 1.1, it’s definitely not the default
right now so this is at best confusing.

changelog_begin
changelog_end
2021-11-08 17:54:48 +01:00
Moisés Ackerman
7d68e05f7f
Remove virtual choices (#11482)
* Remove virtual choices

* Remove choices without a body in 'interface' definition
* Remove choices in 'template ... implements' section

part of #11372

changelog_begin
changelog_end

* Remove virtual choices cont.

Switch uses of virtual choices to fixed choice with method implementation

* update snapshot after pin on windows

* Disable failing interface tests with TODO #10810
2021-11-08 17:05:23 +01:00
Robin Krom
da76e2825b
iface: check for interface implementations precond (#11494)
* iface: check for interface implementations precond

We change speedy to also check all preconditions defined in interface
implementations upon a create.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala

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

* format

* interfaces: lfconversion for iface preconditions

This adds interface preconditions to the interface implementations
during completion phase in the LF conversion.

CHANGELOG_BEGIN
CHANGELOG_END

* format

* rebase

Co-authored-by: Remy <remy.haemmerle@daml.com>
2021-11-02 17:27:49 +00:00
Sofia Faro
741a6e75a7
interfaces: Add list of fixed choices in TemplateImplements structure. (#11364)
* interfaces: Add fixed choices in TemplateImplements

To make template choice collision checks local.

changelog_begin
changelog_end

* LF completer

* lint

* scary non-shadowing

* improve comment

* change field name
2021-11-01 11:51:51 +00:00
Robin Krom
d3b9c84908
ifaces: preconditions, proto changes (#11448)
This adds a precondition expression to the protobuf and the
encoders/decoders on the haskell side.

CHANGELOG_BEGIN
CHANGELOG_END
2021-10-28 13:15:22 +00:00
Moisés Ackerman
613aac3e47
Add support for non-star-kinded type synonyms in data-dependencies (#11293)
* Add DA.Internal.NatSyn as a stable package

This module exposes a type NatSyn, to be used for encoding
type synonyms of Nat-kinded types

* Add generalized roundtrip test helpers in LFConversion tests

roundtripTestsBy and roundtripTestsPartialBy are like their
non-By versions, except they take an explicit equality predicate
instead of relying on the Eq instance. This allows the source
and target types to differ.

* Define encoder/decoder for type synonyms

This works by saturating the RHS of the declaration with artificial
variable names and adding the corresponding parameters on the LHS
In the case of Nat type synonyms, the Proxy-like
DA.Internal.NatSyn.NatSyn type is used to wrap the value into
something of kind star.

* Use type synonym encoder/decoder when generating/consuming DALF

This closes #11226

changelog_begin
changelog_end

* Extend type synonyms over data-dependencies test

* Add test cases for multi-param type class synonyms
2021-10-25 17:10:05 +02:00
Sofia Faro
7e2edbdfaf
interface fixed choices: Haskell Typechecker (#11177)
Part of #11137

changelog_begin
changelog_end
2021-10-08 15:42:29 +01:00
Sofia Faro
53c76d47c3
interface fixed choices: Haskell AST (#11160)
* interface fixed choices: Haskell AST

Part of #11137

changelog_begin
changelog_end

* Make intParam strict
2021-10-07 10:46:50 +00:00
Sofia Faro
0d3ae6e14c
interface methods: Haskell Typechecker (#11028)
part of #11006

changelog_begin
changelog_end
2021-09-27 12:32:05 +01: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
724e50d739
interfaces: Add to/from interface in Haskell AST (#10945)
Part of #10810

changelog_begin
changelog_end
2021-09-21 10:24:10 +01: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
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