www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Weird dmd error?

reply Andrea Fontana <nospam example.com> writes:
--- 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'
Nov 07 2016
parent reply Anonymous <anon anon.hu> writes:
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.
Nov 07 2016
parent reply Anonymous <anon anon.hu> writes:
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.
Nov 07 2016
parent reply Andrea Fontana <nospam example.com> writes:
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.
Nov 07 2016
next sibling parent reply Anonymous <anon anon.hu> writes:
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 ?
Nov 07 2016
next sibling parent Anonymous <anon anon.hu> writes:
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 !
Nov 07 2016
prev sibling parent Andrea Fontana <nospam example.com> writes:
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
Nov 07 2016
prev sibling parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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
Nov 07 2016
parent Andrea Fontana <nospam example.com> writes:
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
Nov 07 2016