Jump to page: 1 2
Thread overview
[Issue 4563] New: [module system] Error messages for missing package or missing name
Aug 01, 2010
Andrej Mitrovic
Jan 10, 2012
Leandro Lucarella
Oct 24, 2012
Andrej Mitrovic
Oct 24, 2012
Andrej Mitrovic
Oct 24, 2012
Andrej Mitrovic
Oct 24, 2012
Andrej Mitrovic
August 01, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4563

           Summary: [module system] Error messages for missing package or
                    missing name
           Product: D
           Version: D1 & D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-08-01 15:10:25 PDT ---
This is a wrong D2 program ("bitmanips" name doesn't exist):


import std.bitmanips: bitfields;
void main() {}


This is the error message given by dmd 2.047:

test.d(1): Error: module bitmanips is in file 'std\bitmanips.d' which cannot be
read


But a better error message can be:

test.d(1): Error: module 'bitmanips' not found in package 'std'.

---------------------

This is another wrong D2 program (the 'bitfield' name is missing inside
std.bimanip):


import std.bitmanip: bitfield;
void main() {}


This is the error message given by dmd 2.047:

test.d(1): Error: import bitfield not found
test.d(1): Error: alias test.bitfield recursive alias declaration


But the second error message can be omitted, it's useless and quite confusing. So DMD can print just:

test.d(1): Error: import name 'bitfield' not found inside 'std.bitmanip'
module.


See also bug 3845

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 01, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4563


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2010-08-01 15:43:08 PDT ---
Agreed. There's an example in the docs (which I've filed a bug report for) that imports std.hiddenfunc which doesn't exist anymore. "File cannot be read" is pretty ambiguous in it's meaning.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4563



--- Comment #2 from bearophile_hugs@eml.cc 2011-08-10 14:05:55 PDT ---
Giving code to a D newbie such person didn't know what this error message means:


foo.d(3): Error: module ascii is in file 'std/ascii.d' which cannot
be read
import path[0] = /usr/include/d
import path[1] = /usr/include/d/druntime/import


The problem was simple, he has used dmd 2.053 instead of the successive one, so std.ascii was not present yet. This error message is not clear enough.

In a similar situation Python2 gives:
ImportError: No module named foo

I suggest an error message like:

foo.d(3): Error: module "std.ascii" not found (file 'std/ascii.d').

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4563



--- Comment #3 from bearophile_hugs@eml.cc 2011-11-25 16:36:00 PST ---
Now the situation is worse (DMD 2.057head):


import std.math: foo;
void main() {}


Gives:

test.d(1): Error: import __anonymous foo not found
test.d(1): Error: alias test.foo recursive alias declaration

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4563



--- Comment #4 from bearophile_hugs@eml.cc 2012-01-04 03:11:27 PST ---
The situation is not improved.

Wrong D2 code:


import core.stdc.stdlib: puts;
import std.stdio: reverse;
void main() {
    puts("hello");
    int[] a = [1, 2, 3];
    reverse(a);
}



After the recent changes in import semantics DMD 2.058head gives:

test.d(4): Error: undefined identifier puts
test.d(6): Error: undefined identifier reverse

But instead of such errors at the usage point I suggest to give import errors, something like:

test.d(1): Error: name 'puts' not present in 'core.stdc.stdlib' module.
test.d(2): Error: name 'reverse' not present in 'std.stdio' module.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4563


Leandro Lucarella <leandro.lucarella@sociomantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |leandro.lucarella@sociomant
                   |                            |ic.com


--- Comment #5 from Leandro Lucarella <leandro.lucarella@sociomantic.com> 2012-01-10 04:40:42 PST ---
*** Issue 7253 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4563



--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-23 18:53:44 PDT ---
(In reply to comment #0)
> import std.bitmanips;
> void main() {}
> 
> test.d(1): Error: module bitmanips is in file 'std\bitmanips.d' which cannot     be read

This is the only test-case left to fix in this Issue (the others seem to be
fixed).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4563



--- Comment #7 from bearophile_hugs@eml.cc 2012-10-24 05:09:04 PDT ---
(In reply to comment #6)

> This is the only test-case left to fix in this Issue (the others seem to be
> fixed).

This is the current situation:

----------------

// Case#1
import std.bitmanips: bitfields;
void main() {}

test.d(1): Error: module bitmanips is in file 'std\bitmanips.d' which cannot be
read
import path[0] = C:\dmd2\src\phobos\
import path[1] = C:\dmd2\src\druntime\import\
import path[2] = C:\leonardo\d_bugs\
import path[3] = C:\dmd2\windows\bin\..\..\src\phobos
import path[4] = C:\dmd2\windows\bin\..\..\src\druntime\import

----------------

// Case#2
import std.bitmanip: bitfield;
void main() {}

test.d(1): Error: module std.bitmanip import 'bitfield' not found, did you mean
'template bitfields(T...)'?

----------------

// Case#3
import std.math: foo;
void main() {}

test.d(1): Error: module std.math import 'foo' not found, did you mean
'function fma'?

----------------

The Case#1 probably needs a better error message.

The messages in cases #2 and #3 seem acceptable, it's not bad. But they sub-optimal, in Case#3 this seems better:

test.d(1): Error: name 'foo' not found in module std.math, did you mean
function 'fma'?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4563



--- Comment #8 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-24 06:48:43 PDT ---
(In reply to comment #7)
> test.d(1): Error: module bitmanips is in file 'std\bitmanips.d' which cannot be
> read
> The Case#1 probably needs a better error message.

Yes, it can be:

test.d(1): Error: module bitmanips not found in package 'std'

However what if the module is not in any package? Example:

import bitmanips; void main() { }

=> test.d(1): Error: module bitmanips is in file 'bitmanips.d' which cannot be
read

What should we do here?

> test.d(1): Error: name 'foo' not found in module std.math, did you mean
> function 'fma'?

I would replace 'name' with 'symbol' here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4563



--- Comment #9 from bearophile_hugs@eml.cc 2012-10-24 10:13:27 PDT ---
(In reply to comment #8)

> However what if the module is not in any package? Example:
> 
> import bitmanips; void main() { }
> 
> => test.d(1): Error: module bitmanips is in file 'bitmanips.d' which cannot be
> read
> 
> What should we do here?

Instead of writing:

test.d(1): Error: module bitmanips cannot be found in package 'std'.

It omits the last part of the message:

test.d(1): Error: module bitmanips cannot be found.

(Unrelated: do you know why D error messages don't have an ending full stop "." as in correct English?)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2