Ticket #93 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

Module names need to be filtred in generated C code

Reported by: erikd@… Owned by: benl
Priority: trivial Milestone: 0.1.3
Component: Compilation Driver Version: 0.1.2
Keywords: Cc:

Description

If a code module is named 'hello-world.ds' containing:

main = print "Hello World."

the generated C code will result in output C code with illegal C identifiers like:

#include "hello-world.ddc.h"

Obj** _ddcCAF_hello-world_main = 0;

Obj* symddcInitModule_helloMsworld () {

/**/ _ddcCAF_hello-world_main = _ddcSlotPtr++; /**/ _CAF(hello-world_main) = 0; /**/ _CAF(hello-world_main) = hello-world_main();

}

Obj* hello-world_main () {

Obj* _vxSS0; _ENTER (2);

symhelloMsworld_main_start: _S(0) = Data_String_boxString("Hello world!"); _S(1) = System_Console_print (_S(0)); _vxSS0 = _S(1); _LEAVE (2); return _vxSS0;

}

Change History

Changed 5 years ago by anonymous

  • status changed from new to assigned
  • component changed from Unknown to Compilation Driver
  • priority changed from normal to trivial
  • version set to 0.1.2
  • milestone set to 0.1.3
  • owner set to anonymous

In GHC, you can compile a single source file named "hello-world.hs", because GHC defaults the module name to "Main". You can't have a module named "hello-world" in a larger project though because the following Haskell code is a parse error:

module hello-world where ...

DDC names the module being compiled after the file name. The character '-' should not be in a module name, so we can just refuse to compile source files with '-' as well.

Changed 5 years ago by benl

  • owner changed from anonymous to benl
  • status changed from assigned to new

Changed 5 years ago by benl

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.