Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing module refs issue #4211

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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