Error naming a module

Hey, I named my file ‘chore.daml’ then named my module ‘Chore’ and the IDE showed the error below:
‘Module names should always match file names, as per documentation. Please change the filename to Chore.daml.’
Instead of changing the file name to ‘Chore.daml’ I changed the module name to ‘chore’ however it then showed the following error:
“parse error on input ‘chore’”
I assumed that the module name (and therefore the file name) must be capitalised however, I searched the documentation and found the file structure page here which supports the first error message that the file and module names must be the same however, it doesn’t state that they must both be capitalised.
I found this question and I tried to close the tabs & VS which didn’t work - How to fix incorrect module name errors in Daml Studio?. My issue also isn’t that I renamed a file so I don’t know how much it applies.
Any help on how to resolve this is much appreciated.
Thanks, Dave

2 Likes

Module names (and type names) must start with an uppercase letter. If that’s not documented, it definitely should be.

1 Like

Agree, it is in there but you have to look for it, and the most relevant reference 2.2.2.1 Template name is actually broken across 2 pages in the .PDF which makes it easy to miss.

Searched the DA_SDK.pdf using the following terms:

  • capital
  • module capital
  • template capital
  • module uppercase
  • module capitaliZ/Se

Search results below.

2.2.10.1 File structure

This file’s module name (module NameOfThisFile where).
Part of a hierarchical module system to facilitate code reuse. Must be the same as the Daml file name, without the file extension.
For a file with path ./Scenarios/Demo.daml, use module Scenarios.Demo where.

Understand the generated classes (Page 377/577)

The Java package for the generated classes is the equivalent of the lowercase Daml module name

Develop with Daml Studio (Page 393/577)

The first two lines specify language version and module name

2.2.1.2 Choice structure (Page 111/577)

a name Must begin with a capital letter. Must be unique - choices in different templates can’t have the same name

2.2.2.1 Template name (Pages 112-113/577)

This is the name of the template. It’s preceded by template keyword. Must begin with a capital letter. This is the highest level of nesting.

As far as Type requiring a CAPITAL I did not see it.

Searched using:

  • type name
  • type capital
  • type uppercase
  • type capitaliZ/Se

Should be clearer? Yes. I’d suggest a definitions of TERMs, perhaps as an Appendix that details these specific requirements.

1 Like