[erlang-questions] Case insensitivity - Windows trap or bug?

Doug Edmunds dae@REDACTED
Tue Jan 15 22:14:04 CET 2008

The Erlang compiler assumes that filenames are
case sensitive.  It does not check the existence
of a file based on a case-sensitive spelling.
But Windows filenames are not case sensitive.
This can lead to unexpected results.

(I don't have a *nix system to check this on. I
assume this is a Windows-only problem.)

Assume this scenario:
(note the spelling, a capital T in both file name and module).

a file named:   myTest.erl
containing a module:  -module(myTest).

 > compile:file(myTest).
produces myTest.beam

So far so good.


An inadvertent typo can cause unexpected results
which are not flagged by the compiler (in Windows):


 > compile:file(mytest).   %% case insensitive input accepted.
{ok,myTest}             %% note difference between input and output

What is the filename just created?
'mytest.beam', not 'myTest.beam'

Any errors or warnings?  No.


2. Having done step 1, things can become very strange:
Remember, the name of the beam file is mytest.beam.
There is no myTest.beam.

 > code:file_load(myTest).
{module,myTest}  %% loads

3. But this doesn't work:


=ERROR REPORT==== 15-Jan-2008::09:56:50 ===
beam/beam_load.c(1035): Error loading module mytest:
   module name in object code is myTest

=ERROR REPORT==== 15-Jan-2008::09:56:50 ===
Loading of c:/erl_dae2/compile sensitivity bugs/mytest.beam failed: badfile


Running erlc from a DOS shell, has the same problems.
erlc ignores case, and compiles a beam
file that does not match the internal module name.

erlc mytest.erl  %% erlc accepts this filename in Windows

produces mytest.beam from myTest.erl without any warning.
The mytest.beam will have the same usage issues as indicated
above (it will contain a module name 'myTest' and will not load.

I think of these as bugs.  Other Erlang functions
can capture/retain filename case sensitivity in Windows.
(c:ls/0, for example reports myTest.erl).  You won't change
Windows. The Erlang compiler functions need to test
for file existence based on case-sensitivity.

Doug Edmunds

More information about the erlang-questions mailing list