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

Preserve empty variant constructor in data-deps. #7303

Merged
merged 3 commits into from
Sep 2, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Add test for special case
  • Loading branch information
sofiafaro-da committed Sep 2, 2020
commit 59926babb9e698dbaa9e85ecabacd3d575c25df0
7 changes: 7 additions & 0 deletions compiler/damlc/tests/src/DA/Test/Packaging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D
writeFileUTF8 (tmpDir </> "type" </> "Foo.daml") $ unlines
[ "module Foo where"
, "data A = B | C Int"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a third case D () and check that it behaves like D when imported as data-dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. D () is something we're deprecating, and the fact that it's treated the same as D in the current compiler is mostly a mistake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally agree but would feel more comfortable to have a test as long as users can still write it, even though they get warned about it.

Copy link
Contributor Author

@sofiafaro-da sofiafaro-da Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test for D () in the single constructor case, which is something we had talked about adding as a special case (since we can't distinguish single-constructor variants from enums any other way, and there's no ambiguity in the single constructor case). (This actually also came up in one of the other tests, but better to add one here as well.)

, "data D = D ()" -- single-constructor case uses explicit unit
]
withCurrentDirectory (tmpDir </> "type") $
callProcessSilent damlc ["build", "-o", "type.dar"]
Expand All @@ -1707,6 +1708,12 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D
, " case a of"
, " B -> 0"
, " C n -> n"
, "mkD : D"
, "mkD = D ()"
, "matchD : D -> ()"
, "matchD d ="
, " case d of"
, " D () -> ()"
]
withCurrentDirectory (tmpDir </> "proj") $
callProcessSilent damlc ["build"]
Expand Down