digitalmars.D.bugs - [Issue 4841] New: An array()/map inlining problem
- d-bugmail puremagic.com (32/32) Sep 08 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (32/32) Sep 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (32/32) Jan 16 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Jan 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (31/31) Jan 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (9/9) Feb 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Feb 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (13/13) Feb 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (6/6) Feb 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (9/10) Feb 06 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (6/6) Feb 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (80/80) Feb 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (15/15) Mar 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Jun 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Jun 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Jun 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (46/46) Jun 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (7/7) Jun 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Jun 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (8/10) Jun 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Jul 09 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (13/13) Jul 11 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (9/9) Jul 11 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
- d-bugmail puremagic.com (10/10) Oct 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4841
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Summary: An array()/map inlining problem
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
This is a D2 program:
import std.algorithm: map;
import std.array: array;
void main() {
int c;
array(map!((x){return c;})([1]));
}
It works if you compile it with dmd 2.048 with:
dmd test.d
But if use inlining:
dmd -inline test.d
It doesn't compile and dmd returns:
test.d(5): Error: function D main is a nested function and cannot be accessed
from array
I think this is a compiler bug because inlining should not affect the
compilability of a program.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 08 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug yahoo.com.au
Summary|An array()/map inlining |-inline wrecks delegate
|problem |literals as alias
| |parameters (An array()/map
| |inlining problem)
Original title: "An array()/map inlining problem"
Here's a simpler case that gives the same error message, only with -inline:
---
struct Struct4841(alias pred)
{
this(int k) { }
}
void bug4841a() {
Struct4841!( (t) { any_old_garbage;} )( 1 );
}
void bug4841b() {
bug4841a();
}
---
This is a problem with delegates and alias templates. It's not a regression.
There also seems to be an accepts-invalid bug in this. You can put any old
garbage inside the alias, which seems odd. And you cannot declare a variable of
type Struct4841!( (t) { any_old_garbage;} ) --- it's rejected at the parsing
stage.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Trass3r <mrmocool gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mrmocool gmx.de
I think the following test case also belongs to this issue:
R1 find(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle)
{
return simpleMindedFind!pred(haystack, needle);
}
R1 simpleMindedFind(alias pred, R1, R2)(R1 haystack, R2 needle)
{
bool haystackTooShort()
{
return true;
}
return haystack;
}
sizediff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)sub)
{
const(Char1)[] balance = find!({})(s, sub);
return -1;
}
string extStr;
void main()
{
extStr.indexOf("bla");
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 16 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841
David Simcha <dsimcha yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dsimcha yahoo.com
*** Issue 4724 has been marked as a duplicate of this issue. ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |2.059
Summary|-inline wrecks delegate |-inline wrecks nested
|literals as alias |struct with alias template
|parameters (An array()/map |parameter (An array()/map
|inlining problem) |inlining problem)
Further reduced shows neither constructor nor delegate is required.
struct Struct4841(alias pred)
{
void unused_func();
}
void bug4841a() {
int w;
Struct4841!( w ) m;
}
void bug4841b() {
bug4841a();
}
----------------
The unused function is required only because it makes Struct4841 into a nested
struct.
I think it is because moving a templated nested struct changes its type - the
enclosing function is part of the mangled name, or something like that. It
can't trivially be moved around.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 27 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841 Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7766bbd9857ab5ad5b1d5ff0444cb7088823a793 fix Issue 4841 - -inline wrecks nested struct with alias template parameter (An array()/map inlining problem) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla digitalmars.com
Resolution| |FIXED
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841
David Simcha <dsimcha yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
I just tested the fix that was merged recently. It only fixes some cases such
as Don's and Tass3r's. Bearophile's case is still broken, as is the case I
reported in Bug 4724.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841 22:08:20 PST --- I believe this is the same as bug 5939. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841I believe this is the same as bug 5939.I don't think bug 5939 involves -inline, but this one definitely does. Unless there are plans to make compiler changes are to fix bug 5939, the inliner shouldn't be making this transformation. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 06 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841 See also Issue 7559 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 21 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Jonathan M Davis <jmdavisProg gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jmdavisProg gmx.com
PST ---
Another example of this would be:
import std.string;
void main()
{
auto str = new char[](5);
assert(sformat(str, "%s", 42) == "42");
}
If you compile with -inline, it fails to compile with the latest master, giving
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2593): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2593): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2596): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2596): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2596): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2597): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2593): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2593): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2596): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2596): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2596): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2597): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2601): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2601): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2604): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2604): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2604): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2605): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, char[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2601): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2601): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)[]).put
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(2604): Error:
function std.string.sformat!(char, int).sformat is a nested function and cannot
be accessed from std.range.put!(Sink, const(char)[]).put
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
import std.array: array;
import std.algorithm: map;
void main() {
int[] foo;
auto r1 = map!(i => foo[0])([0]);
auto r2 = array(r1);
}
Gives (dmd 2.063 alpha):
temp.d(5): Error: function D main is a nested function and cannot be accessed
from std.array.array!(MapResult!(__lambda2, int[])).array
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Denis Shelomovskij <verylonglogin.reg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egustc gmail.com
2013-06-10 16:40:53 MSD ---
*** Issue 9187 has been marked as a duplicate of this issue. ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Denis Shelomovskij <verylonglogin.reg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |html exc.eu
2013-06-10 16:43:09 MSD ---
*** Issue 9996 has been marked as a duplicate of this issue. ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Denis Shelomovskij <verylonglogin.reg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |torarind gmail.com
2013-06-10 16:46:21 MSD ---
*** Issue 7129 has been marked as a duplicate of this issue. ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Denis Shelomovskij <verylonglogin.reg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |verylonglogin.reg gmail.com
2013-06-10 16:47:35 MSD ---
Currently failing tests:
1. From Description
---
import std.algorithm: map;
import std.array: array;
void main()
{
int c;
map!(x => c)([1]).array();
}
---
2. From Comment 10
---
import std.string;
void main()
{
assert(new char[5].sformat("%s", 42) == "42");
}
---
3. From Issue 7129 Comment 4
---
auto fun()
{
int i;
struct Result
{
this(int u) {}
auto bar() { i = 42; }
}
return Result();
}
void main()
{
auto t = fun();
t.bar();
}
---
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841 2013-06-10 16:54:37 MSD --- As mixing -inline/non-inline modules may result in a wrong code because of Issue 9193 one can use "-inline" only for toy D projects. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Denis Shelomovskij <verylonglogin.reg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Platform|x86 |All
Target Milestone|2.059 |---
OS/Version|Windows |All
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841As mixing -inline/non-inline modules may result in a wrong code because of Issue 9193 one can use "-inline" only for toy D projects.If you believe that to be true, then I think you should raise the Importance of this issue to Major. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Kenji Hara <k.hara.pg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |pull
---
https://github.com/D-Programming-Language/dmd/pull/2329
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841 Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1fbbe5966e372abb20e70c4ac69ecfaeaa6db952 fix Issue 4841 - -inline wrecks certain nested structs causing error "*** is a nested function and cannot be accessed from ***" https://github.com/D-Programming-Language/dmd/commit/c19b8a43f45da1347302d3b49a3d1b0b53997003 Issue 4841 - -inline wrecks certain nested structs causing error "*** is a nested function and cannot be accessed from ***" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 11 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 11 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4841
Kenji Hara <k.hara.pg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |code benjamin-thaut.de
---
*** Issue 11210 has been marked as a duplicate of this issue. ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 10 2013









d-bugmail puremagic.com 