Skip to content

Commit

Permalink
Allow imports of internal modules
Browse files Browse the repository at this point in the history
changelog_begin
- [Daml Compiler] Imports of internal modules are no longer illegal.
  Previously, the compiler raised an error when it encountered imports
  of internal modules such as `DA.Internal.*`. Such imports are now
  accepted by the compile. Note, however, that internal modules are
  still not part of the stable API.
  Fixes #10379
changelog_end

Previously, imports of internal modules such as
  • Loading branch information
aherrmann committed Jul 23, 2021
1 parent 6a16684 commit 068467a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 1 addition & 8 deletions compiler/damlc/daml-preprocessor/src/DA/Daml/Preprocessor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ damlPreprocessor dataDependableExtensions mbUnitId dflags x
, checkKinds x
]
, preprocErrors = concat
[ checkImports x
, checkDataTypes x
[ checkDataTypes x
, checkModuleDefinition x
, checkRecordConstructor x
, checkModuleName x
Expand Down Expand Up @@ -160,12 +159,6 @@ checkModuleName (GHC.L _ m)
| otherwise
= []

-- | We ban people from importing modules such
checkImports :: GHC.ParsedSource -> [(GHC.SrcSpan, String)]
checkImports x =
[ (ss, "Import of internal module " ++ GHC.moduleNameString m ++ " is not allowed.")
| GHC.L ss GHC.ImportDecl{ideclName=GHC.L _ m} <- GHC.hsmodImports $ GHC.unLoc x, isInternal m]

-- | Emit a warning if the "daml 1.2" version header is present.
checkDamlHeader :: GHC.ParsedSource -> [(GHC.SrcSpan, String)]
checkDamlHeader (GHC.L _ m)
Expand Down
5 changes: 2 additions & 3 deletions compiler/damlc/tests/daml-test-files/InternalImport.daml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
-- Copyright (c) 2020, Digital Asset (Switzerland) GmbH and/or its affiliates.
-- All rights reserved.

-- @ERROR range=9:1-9:28; Import of internal module DA.Internal.Template is not allowed.

-- Internal imports used to be forbidden but are allowed since 1.16.0.

module InternalImport where

import DA.Internal.Template
import DA.Internal.Template()

0 comments on commit 068467a

Please sign in to comment.