[dmd-internals] ref const(T) doesn't accept struct temporaries?

Andrei Alexandrescu andrei at erdani.com
Fri Dec 10 12:28:50 PST 2010


An rvalue should not bind to a reference. I think Duration is small 
enough to pass by value. If not, we need to wait for "auto ref" to be fixed.

Andrei

On 12/10/10 11:51 AM, Sean Kelly wrote:
> I suppose I should have already known this, but I was surprised today to find that this didn't work:
>
>      auto val = x + seconds(y);
>
>      Duration seconds(long x) { ... }
>
>      struct Duration {
>          Duration opOpAssign(string op)( ref const(Duration) other ) { ... }
>      }
>
> With the error:
>
>      Error: function core.time.Duration.opOpAssign!("+").opOpAssign (ref const(Duration) other) is not callable using argument types (Duration)
>      src/core/sync/config.d(59): Error: seconds(y) is not an lvalue
>
> Someone please tell me that this is a bug and that it will be fixed soon.  A quick search on the bug tracker didn't turn up anything.
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals


More information about the dmd-internals mailing list