Thread overview
Why is my code does not compile? (dmd 2.021 linux)
Dec 12, 2008
Weed
Dec 12, 2008
Bill Baxter
Dec 12, 2008
Weed
Dec 12, 2008
Bill Baxter
Dec 12, 2008
Weed
December 12, 2008
void main()
{
    int i;

    ref int func()
    {
      return i;
    }

    func() = 4;
}

lval.d(5): found 'ref' instead of statement
lval.d(10): no identifier for declarator func
lval.d(11): unrecognized declaration


but code like this compiles:

ref int func()
{
  int* i = new int;
  return *i;
}

void main()
{
    func() = 4;
}
December 12, 2008
On Sat, Dec 13, 2008 at 5:45 AM, Weed <resume755@mail.ru> wrote:
>
> void main()
> {
>    int i;
>
>    ref int func()
>    {
>      return i;
>    }
>
>    func() = 4;
> }
>
> lval.d(5): found 'ref' instead of statement
> lval.d(10): no identifier for declarator func
> lval.d(11): unrecognized declaration
>
>
> but code like this compiles:
>
> ref int func()
> {
>  int* i = new int;
>  return *i;
> }
>
> void main()
> {
>    func() = 4;
> }
>

Ref return values are a very new feature in D2.  I suspect its just a bug that they don't work on inner functions yet.

--bb
December 12, 2008
Bill Baxter пишет:
> On Sat, Dec 13, 2008 at 5:45 AM, Weed <resume755@mail.ru> wrote:
>> void main()
>> {
>>    int i;
>>
>>    ref int func()
>>    {
>>      return i;
>>    }
>>
>>    func() = 4;
>> }
>>
>> lval.d(5): found 'ref' instead of statement
>> lval.d(10): no identifier for declarator func
>> lval.d(11): unrecognized declaration
>>
>>
>> but code like this compiles:
>>
>> ref int func()
>> {
>>  int* i = new int;
>>  return *i;
>> }
>>
>> void main()
>> {
>>    func() = 4;
>> }
>>
> 
> Ref return values are a very new feature in D2.  I suspect its just a
> bug that they don't work on inner functions yet.
> 
> --bb

message implies that the authors are aware of this limitation? report they do not need?
December 12, 2008
2008/12/13 Weed <resume755@mail.ru>:
> Bill Baxter пишет:
>>
>> On Sat, Dec 13, 2008 at 5:45 AM, Weed <resume755@mail.ru> wrote:
>>>
>>> void main()
>>> {
>>>   int i;
>>>
>>>   ref int func()
>>>   {
>>>     return i;
>>>   }
>>>
>>>   func() = 4;
>>> }
>>>
>>> lval.d(5): found 'ref' instead of statement
>>> lval.d(10): no identifier for declarator func
>>> lval.d(11): unrecognized declaration
>>>
>>>
>>> but code like this compiles:
>>>
>>> ref int func()
>>> {
>>>  int* i = new int;
>>>  return *i;
>>> }
>>>
>>> void main()
>>> {
>>>   func() = 4;
>>> }
>>>
>>
>> Ref return values are a very new feature in D2.  I suspect its just a bug that they don't work on inner functions yet.
>>
>> --bb
>
> message implies that the authors are aware of this limitation? report they do not need?

No, a report is probably needed.  There are lots of bugs with the new const and ref features in D2.  Many have been reported, but there are still many more to be discovered.  Returning refs in particular is very new, so I would expect bugs a plenty with that, though I think few have been reported so far.  I don't keep up with the bugs newsgroup these days, though.  Certainly try to search for it in the bug db before filing a new report, though.  D's bugzilla is here: http://d.puremagic.com/issues/

--bb

December 12, 2008
Bill Baxter пишет:

>>> Ref return values are a very new feature in D2.  I suspect its just a
>>> bug that they don't work on inner functions yet.
>>>
>>> --bb
>> message implies that the authors are aware of this limitation? report they
>> do not need?
> 
> No, a report is probably needed.  There are lots of bugs with the new
> const and ref features in D2.  Many have been reported, but there are
> still many more to be discovered.  Returning refs in particular is
> very new, so I would expect bugs a plenty with that, though I think
> few have been reported so far.  I don't keep up with the bugs
> newsgroup these days, though.  Certainly try to search for it in the
> bug db before filing a new report, though.  D's bugzilla is here:
> http://d.puremagic.com/issues/

Posted here: http://d.puremagic.com/issues/show_bug.cgi?id=2509