Skip to content

Commit

Permalink
Fix missing module refs issue (digital-asset#4211)
Browse files Browse the repository at this point in the history
changelog_begin
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
  • Loading branch information
2 people authored and mergify[bot] committed Jan 24, 2020
1 parent 2737303 commit 2160ad5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion language-support/ts/codegen/src/TsCodeGenMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ genDefDataType curPkgId conName mod tpls def =
Nothing -> ((makeType typeDesc, makeSer serDesc), Set.unions fieldRefs)
Just tpl ->
let (chcs, argRefs) = unzip
[((unChoiceName (chcName chc), t, rtyp, rser), argRefs)
[((unChoiceName (chcName chc), t, rtyp, rser), Set.union argRefs retRefs)
| chc <- NM.toList (tplChoices tpl)
, let tLf = snd (chcArgBinder chc)
, let rLf = chcReturnType chc
, let (t, _) = genType (moduleName mod) tLf
, let (rtyp, rser) = genType (moduleName mod) rLf
, let argRefs = Set.setOf typeModuleRef tLf
, let retRefs = Set.setOf typeModuleRef rLf
]
(keyTypeTs, keySer) = case tplKey tpl of
Nothing -> ("undefined", "() => jtv.constant(undefined)")
Expand Down
14 changes: 14 additions & 0 deletions language-support/ts/codegen/tests/daml/Main.daml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Main where
import DA.TextMap
import Lib.Mod

import T

template AllTypes with
unit: ()
Expand Down Expand Up @@ -90,3 +91,16 @@ data Quux =
Corge { x: Int, y: Text }
| Grault { z: Bool }
deriving (Show, Eq)

-- This template is interesting in that the 'T' it mentions is
-- external to this module and only mentioned as a choice return
-- type. Thus, for the resulting Main.ts to compile, we are testing
-- that we have correctly generated import directives for this case.
template U with
party: Party
where
signatory party
controller party can
C: ContractId T with
do
create T with party
9 changes: 9 additions & 0 deletions language-support/ts/codegen/tests/daml/T.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Copyright (c) 2020 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
daml 1.2
-- See 'template U' in Main.daml for why this is here.
module T where
template T with
party: Party
where
signatory party

0 comments on commit 2160ad5

Please sign in to comment.