Thread overview
[Issue 3642] New: Poor error message when using shared: function ___ not callable with argument types ___
Dec 24, 2009
Jason House
Dec 25, 2009
Walter Bright
Dec 25, 2009
Jason House
[Issue 3642] Poor error message: function ___ not callable with argument types ___
Dec 29, 2009
Jason House
Aug 16, 2012
Jacob Carlborg
Dec 23, 2012
Andrej Mitrovic
December 24, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3642

           Summary: Poor error message when using shared: function ___ not
                    callable with argument types ___
           Product: D
           Version: 2.036
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: jason.james.house@gmail.com


--- Comment #0 from Jason House <jason.james.house@gmail.com> 2009-12-23 17:41:40 PST ---
Sample code

==================
struct foo{
  void unsharedfunc(){}
    void sharedfunc() shared {}
}
void main(){
    foo unsharedvar;
    shared(foo) sharedvar;
    unsharedvar.sharedfunc();
    sharedvar.unsharedfunc();
}
==================

Output with dmd 2.037
(Bug report lists dmd 2.036 because 2.037 was not an option at the time)

$ dmd test.d
test.d(8): Error: function test.foo.sharedfunc () shared is not callable using
argument types ()
test.d(9): Error: function test.foo.unsharedfunc () is not callable using
argument types () shared


Here's the kind of error message I would expect to see
test.d(8): Error: Only shared types can call shared functions
test.d(9): Error: Shared types can only call shared functions

Maybe the function or variable name could be worked into the message, but that's the essence of what should be displayed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 25, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3642


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2009-12-25 13:22:46 PST ---
The function name is in the message already.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 25, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3642



--- Comment #2 from Jason House <jason.james.house@gmail.com> 2009-12-25 14:29:23 PST ---
(In reply to comment #1)
> The function name is in the message already.

The function name isn't particularly important. The error message isn't particularly clear about the misuse of shared.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3642


Jason House <jason.james.house@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Poor error message when     |Poor error message:
                   |using shared: function ___  |function ___ not callable
                   |not callable with argument  |with argument types ___
                   |types ___                   |


--- Comment #3 from Jason House <jason.james.house@gmail.com> 2009-12-28 21:02:22 PST ---
I just came across another example where this is poor.  No test case this time ;)

Here's the error message:
hb/search/factory.d(58): Error: function libego.adapter.move.compressedHash ()
is not callable using argument types ()

Any guesses what is wrong?  Calling a no argument function is not callable using no arguments?  In this particular case, the instance of libego.adapter.move is immutable and the compressedHash function is neither marked as const nor immuatable.  The error message really should be better.

Example alternate error message:
hb/search/factory.d(58): Error: Can't call mutating function on an immutable
object.

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


Jacob Carlborg <doob@me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob@me.com
            Version|2.036                       |future


--- Comment #4 from Jacob Carlborg <doob@me.com> 2012-08-16 04:56:31 PDT ---
I've hit this error a couple of times and it can be really annoying. I always think I'm missing an argument. For example:

module test;

struct Foo
{
    void foo () const
    {
        auto b = bar;
    }

    bool bar ()
    {
        return false;
    }
}

Compile the above code with DMD 2.060 results in:

Error: function test.Foo.bar () is not callable using argument types ()

If I add parentheses when calling "bar", I get a better error message:

Error: function test.Foo.bar () is not callable using argument types () const

Where it actually mentions "const". Although the error message could be even better than this.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-23 13:45:29 PST ---
*** This issue has been marked as a duplicate of issue 1730 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------