Thread overview
[Issue 3326] New: $ in delegate literal causes Access Violation
Sep 17, 2009
Kasumi Hanazuki
[Issue 3326] Regression(2.010): $ in delegate literal causes Access Violation
Jul 23, 2010
Don
Aug 06, 2010
Don
Aug 09, 2010
Walter Bright
Jul 02, 2011
yebblies
Jul 02, 2011
yebblies
September 17, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3326

           Summary: $ in delegate literal causes Access Violation
           Product: D
           Version: 2.032
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hanazuki@gmail.com


--- Comment #0 from Kasumi Hanazuki <k.hanazuki@gmail.com> 2009-09-17 07:46:16 PDT ---
Windows DMD 2.032

Evaluating $ in a delegate literal in an array indexing or slicing throws access violation Error.

----

void main() {
    int[] a = [1];

    auto x = a[{ auto n = $; return 0; }()];
        // object.Error: Access Violation

    auto y = a[{ auto n = $; return 0; }() .. $];
        // object.Error: Access Violation
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 23, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3326


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Version|2.032                       |D2
            Summary|$ in delegate literal       |Regression(2.010): $ in
                   |causes Access Violation     |delegate literal causes
                   |                            |Access Violation
           Severity|normal                      |regression


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-07-23 00:05:49 PDT ---
This worked in 2.000 and all versions of D1, Failed with access violation in 2.012. Bumping up to regression.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3326


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Version|D2                          |D1 & D2
            Summary|Regression(2.010): $ in     |$ in delegate literal
                   |delegate literal causes     |causes Access Violation
                   |Access Violation            |
           Severity|regression                  |major


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-08-06 00:11:01 PDT ---
This isn't a regression, it never worked properly (on D1, it doesn't segfault,
but the generated code is wrong).
It's happening because __dollar isn't a real variable in the parent scope. I
think to fix this properly, either the implementation of __dollar would need to
change, OR the delegate literal would need to be inlined; but this case is so
obscure, it doesn't matter much.

To turn this from wrong-code into a rather obscure rejects-valid:
declaration.c, VarDeclaration::checkNestedReference(), line 1441 (D2 svn 599):

            fdv->closureVars.push(this);
          L2: ;
+            // __dollar creates problems because it isn't a real variable
+            if (ident == Id::dollar)
+                ::error(loc, "cannnot use $ inside a function literal
(Bugzilla 3326)");

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3326


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2010-08-08 22:30:46 PDT ---
http://www.dsource.org/projects/dmd/changeset/608

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3326


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch, wrong-code           |rejects-valid
             Status|RESOLVED                    |REOPENED
                 CC|                            |yebblies@gmail.com
         Resolution|FIXED                       |


--- Comment #4 from yebblies <yebblies@gmail.com> 2011-07-02 15:11:16 EST ---
Reopening as this hasn't been fixed, just turned into a rejects-valid

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3326


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4
           Severity|major                       |minor


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------