www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11301] New: [2.064 beta] core.sys.linux.sys.mman triggers enum resolution error

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301

           Summary: [2.064 beta] core.sys.linux.sys.mman triggers enum
                    resolution error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at


--- Comment #0 from David Nadlinger <code klickverbot.at> 2013-10-19 11:20:57
PDT ---
---
~/Build/Source/druntime/src (2.064=)$ ../../dmd/src/dmd
core/sys/linux/sys/mman.d 
core/sys/posix/sys/mman.d(193): Error: alias core.sys.posix.sys.mman.MAP_ANON
cannot resolve
---
(DMD a913ce4, druntime c0978e9)

This regresses build systems that automatically pull in module dependencies for
compilation and don't have a special case for druntime. The druntiem build
itself doesn't break, as this is a header-only module.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 19 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code dawg.eu


--- Comment #1 from Martin Nowak <code dawg.eu> 2013-10-24 01:55:42 PDT ---
So this happens when compiling the linux and the posix header together?
I think it's a problem with the circular import, will fix.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 24 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #2 from David Nadlinger <code klickverbot.at> 2013-10-24 02:05:47
PDT ---
(In reply to comment #1)
 So this happens when compiling the linux and the posix header together?
At least it also happens when compiling core.sys.linux.sys.mman on its own. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 24 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2013-10-26
13:26:40 PDT ---
Reduced test case:

------ a.d --------
public import b;

static if (1) enum {
    MAP_ANON = 1,
}
------ b.d --------
static import a;
alias MAP_ANON = a.MAP_ANON;
-------------------

dmd -c a.d

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2013-10-26
18:49:21 PDT ---
This also happens with 2.063, so it is not a regression.

The trouble is the declaration of a.MAP_ANON is hidden inside a conditionally
compiled block. Because the exp of "static if (exp)" cannot be evaluated in
advance, the compiler cannot know yet that the declarations in the block exist.

Then, when doing semantic analysis on module a, it looks up a.MAP_ANON. It
doesn't find MAP_ANON in a, but a.d imports b.d, and b declares a MAP_ANON!

The error is the alias essentially resolves to itself, which is an error.

I think the only solution is to fix the druntime code so it doesn't trigger
what is essentially an unresolvable forward reference error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2013-10-26
19:46:50 PDT ---
https://github.com/D-Programming-Language/druntime/pull/644

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #6 from github-bugzilla puremagic.com 2013-10-27 03:05:34 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/54ca71b154fd9476520a63e30a50980af8927a56
fix Issue 11301 - [2.064 beta] core.sys.linux.sys.mman triggers enum resolution
error

https://github.com/D-Programming-Language/druntime/commit/9c0a711cc48f0893e8c0790fc6b967fc5c637179
Merge pull request #644 from WalterBright/fix11301

fix Issue 11301 - [2.064 beta] core.sys.linux.sys.mman triggers enum res...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301


David Nadlinger <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #7 from github-bugzilla puremagic.com 2013-10-27 11:51:03 PDT ---
Commit pushed to 2.064 at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/2abb4b0e1c73bcf0ec7347c27ea945f90252c337
Merge pull request #644 from WalterBright/fix11301

fix Issue 11301 - [2.064 beta] core.sys.linux.sys.mman triggers enum res...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #8 from Martin Nowak <code dawg.eu> 2013-10-29 11:43:54 PDT ---
(In reply to comment #4)
 Then, when doing semantic analysis on module a, it looks up a.MAP_ANON.
I don't follow here, why is there a lookup of MAP_ANON during semantic analysis of a? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #9 from Walter Bright <bugzilla digitalmars.com> 2013-10-29
13:06:19 PDT ---
 I don't follow here, why is there a lookup of MAP_ANON during semantic analysis
 of a?
How else can it resolve a.MAP_ANON? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11301



--- Comment #10 from Martin Nowak <code dawg.eu> 2013-10-29 16:51:10 PDT ---
(In reply to comment #9)
 I don't follow here, why is there a lookup of MAP_ANON during semantic analysis
 of a?
How else can it resolve a.MAP_ANON?
Module a defines MAP_ANON itself, hidden in the static if block. So I presume the forward reference happens because the imported module b is semantically analyzed before a is analyzed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2013