Thread overview
Weird dmd error?
Nov 07, 2016
Andrea Fontana
Nov 07, 2016
Anonymous
Nov 07, 2016
Anonymous
Nov 07, 2016
Andrea Fontana
Nov 07, 2016
Anonymous
Nov 07, 2016
Anonymous
Nov 07, 2016
Andrea Fontana
Nov 07, 2016
Ali Çehreli
Nov 07, 2016
Andrea Fontana
November 07, 2016
--- test.d
void* test (ssize_t );
import core.sys.posix.unistd;
---

Try to run:
dmd test.d

It says:
/usr/include/dmd/druntime/import/core/sys/posix/sys/types.d(100): Error: undefined identifier 'c_long'

November 07, 2016
On Monday, 7 November 2016 at 08:34:55 UTC, Andrea Fontana wrote:
>
> --- test.d
> void* test (ssize_t );
> import core.sys.posix.unistd;
> ---
>
> Try to run:
> dmd test.d
>
> It says:
> /usr/include/dmd/druntime/import/core/sys/posix/sys/types.d(100): Error: undefined identifier 'c_long'

It looks normal but it's not documented. It's just that the import is not yet known in the scope. It 's like:

void main(string[] args)
{
    writeln();
    import std.stdio;
}

But

void main(string[] args)
{
    writeln();
}
import std.stdio;

works because the symbol lookup succeeds in the parent scope.

For your example to work, another semantic pass would necessary.
November 07, 2016
On Monday, 7 November 2016 at 09:58:08 UTC, Anonymous wrote:
> On Monday, 7 November 2016 at 08:34:55 UTC, Andrea Fontana wrote:
>>
>> --- test.d
>> void* test (ssize_t );
>> import core.sys.posix.unistd;
>> ---
>>
>> Try to run:
>> dmd test.d
>>
>> It says:
>> /usr/include/dmd/druntime/import/core/sys/posix/sys/types.d(100): Error: undefined identifier 'c_long'
>
> It looks normal but it's not documented. It's just that the import is not yet known in the scope.

To be clearer, the problem is the same with:

void main()
{
    foo;
    void foo(){}
}

Exactly the same thing happens. There's already 3 semantic passes. To solve this kind of forward references another semantic pass would be required. But in this case you couldn't determine how many passes would be necessary so there would be a  complexity problem in the compiler.
November 07, 2016
On Monday, 7 November 2016 at 10:57:49 UTC, Anonymous wrote:
> Exactly the same thing happens. There's already 3 semantic passes. To solve this kind of forward references another semantic pass would be required. But in this case you couldn't determine how many passes would be necessary so there would be a  complexity problem in the compiler.

But it's not really the same, error in my case is inside druntime.
In your example errors are inside my code.
November 07, 2016
On Monday, 7 November 2016 at 11:57:48 UTC, Andrea Fontana wrote:
> On Monday, 7 November 2016 at 10:57:49 UTC, Anonymous wrote:
>> Exactly the same thing happens. There's already 3 semantic passes. To solve this kind of forward references another semantic pass would be required. But in this case you couldn't determine how many passes would be necessary so there would be a  complexity problem in the compiler.
>
> But it's not really the same, error in my case is inside druntime.
> In your example errors are inside my code.

i'm on a 2071.2 frontend now, my comments are based on this.
are you on 2072 ?
November 07, 2016
On Monday, 7 November 2016 at 12:31:57 UTC, Anonymous wrote:
> On Monday, 7 November 2016 at 11:57:48 UTC, Andrea Fontana wrote:
>> On Monday, 7 November 2016 at 10:57:49 UTC, Anonymous wrote:
>>> Exactly the same thing happens. There's already 3 semantic passes. To solve this kind of forward references another semantic pass would be required. But in this case you couldn't determine how many passes would be necessary so there would be a  complexity problem in the compiler.
>>
>> But it's not really the same, error in my case is inside druntime.
>> In your example errors are inside my code.
>
> i'm on a 2071.2 frontend now, my comments are based on this.
> are you on 2072 ?

oh no yet another 2.072 regression !
November 07, 2016
On 11/07/2016 03:57 AM, Andrea Fontana wrote:
> On Monday, 7 November 2016 at 10:57:49 UTC, Anonymous wrote:
>> Exactly the same thing happens. There's already 3 semantic passes. To
>> solve this kind of forward references another semantic pass would be
>> required. But in this case you couldn't determine how many passes
>> would be necessary so there would be a  complexity problem in the
>> compiler.
>
> But it's not really the same, error in my case is inside druntime.
> In your example errors are inside my code.

You're right. It's a bug that module core.sys.posix.sys.types uses c_long without importing its definition presumably from module core.stdc.config.

Ali

November 07, 2016
On Monday, 7 November 2016 at 12:31:57 UTC, Anonymous wrote:
> On Monday, 7 November 2016 at 11:57:48 UTC, Andrea Fontana wrote:
>> On Monday, 7 November 2016 at 10:57:49 UTC, Anonymous wrote:
>>> Exactly the same thing happens. There's already 3 semantic passes. To solve this kind of forward references another semantic pass would be required. But in this case you couldn't determine how many passes would be necessary so there would be a  complexity problem in the compiler.
>>
>> But it's not really the same, error in my case is inside druntime.
>> In your example errors are inside my code.
>

2071.2 too. On linux, here :)

Andrea

November 07, 2016
On Monday, 7 November 2016 at 12:56:06 UTC, Ali Çehreli wrote:
> You're right. It's a bug that module core.sys.posix.sys.types uses c_long without importing its definition presumably from module core.stdc.config.
>
> Ali

https://issues.dlang.org/show_bug.cgi?id=16666