D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14666 - [REG2.061] Bogus forward reference error
Summary: [REG2.061] Bogus forward reference error
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2015-06-09 00:12 UTC by deadalnix
Modified: 2016-10-01 11:45 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description deadalnix 2015-06-09 00:12:45 UTC
*****************

module d.base.location;

struct Location {
	import d.base.name;
}

*****************

auto getNames() {
	import d.lexer;
}

enum Names = getNames;

*****************

module d.lexer;

import d.base.location;

struct Token {
	Location location;
}

*****************

I get libd/src/d/lexer.d(5): Error: struct d.lexer.Token has forward references when compiling d/base/location.d
Comment 1 Vladimir Panteleev 2015-06-10 02:04:58 UTC
This is a regression.

Introduced in https://github.com/D-Programming-Language/dmd/commit/a04cf864b932061ad7b72e7cad8b16fabc6a825a
Comment 2 Kenji Hara 2015-06-10 02:53:28 UTC
(In reply to Vladimir Panteleev from comment #1)
> This is a regression.
> 
> Introduced in
> https://github.com/D-Programming-Language/dmd/commit/
> a04cf864b932061ad7b72e7cad8b16fabc6a825a

Could you please tell me how did you check that? I cannot reproduce the issue because the provided code lacks:
- file name of each modules
- directory tree
- command line
Comment 3 Vladimir Panteleev 2015-06-10 04:45:11 UTC
(In reply to Kenji Hara from comment #2)
> Could you please tell me how did you check that? I cannot reproduce the
> issue because the provided code lacks:
> - file name of each modules
> - directory tree
> - command line

I used my psychic powers :)

https://github.com/CyberShadow/DBugTests/tree/master/14666

(Command is "dmd -o- location.d" as per bisect.ini)
Comment 4 deadalnix 2015-06-10 05:35:01 UTC
Sorry for the missing filenames, here they are:

******  d/base/location.d  ***********

module d.base.location;

struct Location {
	import d.base.name;
}

******  d/base/name.d  ***********

auto getNames() {
	import d.lexer;
}

enum Names = getNames;

******  d.lexer.d  ***********

module d.lexer;

import d.base.location;

struct Token {
	Location location;
}

*****************

$ dmd -c d/base/location.d
Comment 5 Kenji Hara 2015-06-10 12:20:53 UTC
(In reply to deadalnix from comment #4)
> Sorry for the missing filenames, here they are:
[snip]

Thanks!

https://github.com/D-Programming-Language/dmd/pull/4735
Comment 6 github-bugzilla 2015-06-10 17:35:19 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0504d664beacd11ec5d0e8afaf209357f2d0f9de
fix Issue 14666 - Bogus forward reference error

https://github.com/D-Programming-Language/dmd/commit/640c0e189eeb04daea64257d7de1e4acd2df562e
Merge pull request #4735 from 9rnsr/fix14666

[REG2.061] Issue 14666 - Bogus forward reference error
Comment 8 github-bugzilla 2016-03-31 07:05:44 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/711944c56bf50a7e7323cd34008311345e53f57c
Add deferred semantic2 mechanism, and run semantic2 for all imported modules

When a module is only imported from function local scopes, it couldn't get a change to run semantic2 analysis.
It was "fix" for the issue 14666 case, but the deferred instance size finalization collides with that.

Now, function local imports can cause module level mutual forward references. Their resolutions can be deferred until the global level analysis loop in `mars.d` at maximum, and all function local imports will work as same as module level ones.
Comment 9 github-bugzilla 2016-10-01 11:45:42 UTC
Commit pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/711944c56bf50a7e7323cd34008311345e53f57c
Add deferred semantic2 mechanism, and run semantic2 for all imported modules