Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 06, 2013 inout method is not callable using a const object | ||||
---|---|---|---|---|
| ||||
Can someone help me understand how to correct this error? Error: inout method ...ValidSparseDataStore.opIndex is not callable using a const object The specific method is defined as: struct ValidSparseDataStore { inout(DataT*) opIndex(const Address addr) inout { if (auto node = findNode(addr)) return cast(inout)&(node.data); return null; } private ValidSparseNode* findNode(const Address ids) const { ... } } Thank you, JC |
September 06, 2013 Re: inout method is not callable using a const object | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Crapuchettes | On 09/06/2013 01:14 PM, Jonathan Crapuchettes wrote: > Can someone help me understand how to correct this error? > > Error: inout method ...ValidSparseDataStore.opIndex is not callable using > a const object That error is about opIndex but we don't see any code that makes that call. > The specific method is defined as: > > struct ValidSparseDataStore > { > inout(DataT*) opIndex(const Address addr) inout > { > if (auto node = findNode(addr)) > return cast(inout)&(node.data); > > return null; > } > > private ValidSparseNode* findNode(const Address ids) const > { > ... > } > } > > Thank you, > JC I can reproduce it with this code: struct S { void foo(int) inout {} } void main() { const s = S(); s.foo(42); // <-- works s.foo(); // <-- ERROR } Error: inout method deneme.S.foo is not callable using a const object I can't know whether this matches your case but the compiler should error about not finding a matching foo() overload instead of bringing the inout into the discussion. Ali |
September 06, 2013 Re: inout method is not callable using a const object | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Fri, 06 Sep 2013 13:27:20 -0700, Ali Çehreli wrote:
> On 09/06/2013 01:14 PM, Jonathan Crapuchettes wrote:
>
> > Can someone help me understand how to correct this error?
> >
> > Error: inout method ...ValidSparseDataStore.opIndex is not callable
> > using a const object
>
> That error is about opIndex but we don't see any code that makes that call.
>
> > The specific method is defined as:
> >
> > struct ValidSparseDataStore {
> > inout(DataT*) opIndex(const Address addr) inout {
> > if (auto node = findNode(addr))
> > return cast(inout)&(node.data);
> >
> > return null;
> > }
> >
> > private ValidSparseNode* findNode(const Address ids) const {
> > ...
> > }
> > }
> >
> > Thank you,
> > JC
>
> I can reproduce it with this code:
>
> struct S {
> void foo(int) inout {}
> }
>
> void main()
> {
> const s = S();
> s.foo(42); // <-- works s.foo(); // <-- ERROR
> }
>
> Error: inout method deneme.S.foo is not callable using a const object
>
> I can't know whether this matches your case but the compiler should error about not finding a matching foo() overload instead of bringing the inout into the discussion.
>
> Ali
Sorry for not including the call site. Here is an example of the call:
void main()
{
auto store = ...;
//add items to the storage
const cStore = store;
auto dp = cStore[16057]; //<-- ERROR
}
I can try to minimize the code to a working example if needed.
Thank you,
JC
|
September 06, 2013 Re: inout method is not callable using a const object | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Crapuchettes | I think it is the same issue then. On 09/06/2013 02:00 PM, Jonathan Crapuchettes wrote: >> > inout(DataT*) opIndex(const Address addr) inout { Unless Address is an alias of int, there is no matching opIndex overload for the following call: > auto dp = cStore[16057]; //<-- ERROR Ali |
September 06, 2013 Re: inout method is not callable using a const object | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Fri, 06 Sep 2013 14:08:19 -0700, Ali Çehreli wrote:
> I think it is the same issue then.
>
> On 09/06/2013 02:00 PM, Jonathan Crapuchettes wrote:
>
> >> > inout(DataT*) opIndex(const Address addr) inout {
>
> Unless Address is an alias of int, there is no matching opIndex overload for the following call:
>
> > auto dp = cStore[16057]; //<-- ERROR
>
> Ali
Thank you for your help. For some reason, no one else in the office
noticed that problem. In my code Address was something like TypeTuple!
(int, char) and I was trying to call opIndex(int, int).
Thank you again.
|
September 06, 2013 Re: inout method is not callable using a const object | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On 09/06/2013 01:27 PM, Ali Çehreli wrote: > the compiler should > error about not finding a matching foo() overload instead of bringing > the inout into the discussion. http://d.puremagic.com/issues/show_bug.cgi?id=10982 Ali |
Copyright © 1999-2021 by the D Language Foundation