Nested function passed by alias not emitted (std.file.dirEntries) #131

Closed
bioinfornatics opened this Issue Jun 25, 2012 · 6 comments

Comments

Projects
None yet
3 participants
@bioinfornatics
Contributor

bioinfornatics commented Jun 25, 2012

This code fail at build

import std.file;

void main( ){
    auto dFiles = dirEntries( "./", "*.d", SpanMode.depth);
}
search.o: In function `_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result6__ctorMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result':
search:(.text._D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result6__ctorMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result[_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result6__ctorMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result]+0xdb): undefined reference to `_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result1fMFS3std4file8DirEntryZb'
search.o: In function `_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result8popFrontMFZv':
search:(.text._D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result8popFrontMFZv[_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result8popFrontMFZv]+0xc8): undefined reference to `_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result1fMFS3std4file8DirEntryZb'
collect2: erreur: ld a retourné 1 code d'état d'exécution
Error: linki

Note: edit some bug disappear after the update left this one

@klickverbot

This comment has been minimized.

Show comment Hide comment
@klickverbot

klickverbot Jun 26, 2012

Member

Seems like we are declaring _D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result1fMFS3std4file8DirEntryZb (which seems to be the nested function f in dirEntries), but never defining it.

Member

klickverbot commented Jun 26, 2012

Seems like we are declaring _D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterMFS3std4file11DirIteratorZS3std4file10dirEntries62__T6filterS48_D3std4file10dirEntries1fMFS3std4file8DirEntryZbZ35__T6filterTS3std4file11DirIteratorZ6filterM6Result6Result1fMFS3std4file8DirEntryZb (which seems to be the nested function f in dirEntries), but never defining it.

@klickverbot

This comment has been minimized.

Show comment Hide comment
@klickverbot

klickverbot Jun 26, 2012

Member

DtoDeclareFunction(std.file.dirEntries.f) is first called from nested within DtoDefineFunc(std.file.dirEntries.filter!(f).filter!(DirIterator).filter.Result.this), and (gIR->dmodule is the main module, s->getModule() is std.file) the function never gets pushed back into the global function list. This might have worked for D1 because of https://github.com/ldc-developers/ldc/blob/master/gen/nested.cpp#L353. @AlexeyProkhin, does this ring any bell to you?

Member

klickverbot commented Jun 26, 2012

DtoDeclareFunction(std.file.dirEntries.f) is first called from nested within DtoDefineFunc(std.file.dirEntries.filter!(f).filter!(DirIterator).filter.Result.this), and (gIR->dmodule is the main module, s->getModule() is std.file) the function never gets pushed back into the global function list. This might have worked for D1 because of https://github.com/ldc-developers/ldc/blob/master/gen/nested.cpp#L353. @AlexeyProkhin, does this ring any bell to you?

@alexrp

This comment has been minimized.

Show comment Hide comment
@alexrp

alexrp Jul 6, 2012

Contributor

FWIW, I can confirm this exact bug in my project as well.

Contributor

alexrp commented Jul 6, 2012

FWIW, I can confirm this exact bug in my project as well.

@klickverbot

This comment has been minimized.

Show comment Hide comment
@klickverbot

klickverbot Oct 6, 2012

Member

A related test case which causes a segfault using latest LDC:

// algorithm.d

template filter(alias pred) {
    auto filter(Range)(Range rs) {
        return FilterResult!(pred, Range)(rs);
    }
}

struct FilterResult(alias pred, Range) {
    this(Range r) {}
}
// file.d
import algorithm;

struct DirIterator {}

auto dirEntries() {
    void f() {}
    return filter!f(DirIterator());
}
ldc2 file.d algorithm.d

Hopefully, fixing the root cause of this will also fix the dirEntries issue.

Member

klickverbot commented Oct 6, 2012

A related test case which causes a segfault using latest LDC:

// algorithm.d

template filter(alias pred) {
    auto filter(Range)(Range rs) {
        return FilterResult!(pred, Range)(rs);
    }
}

struct FilterResult(alias pred, Range) {
    this(Range r) {}
}
// file.d
import algorithm;

struct DirIterator {}

auto dirEntries() {
    void f() {}
    return filter!f(DirIterator());
}
ldc2 file.d algorithm.d

Hopefully, fixing the root cause of this will also fix the dirEntries issue.

@klickverbot

This comment has been minimized.

Show comment Hide comment
@klickverbot

klickverbot Oct 6, 2012

Member

Getting closer (hopefully for real, this time):

// test.d
template filter(alias pred)
{
    auto filter(Range)(Range rs)
    {
        return FilterResult!(pred, Range)(rs);
    }
}

private struct FilterResult(alias pred, Range)
{
    Range _input;
    this(Range r)
    {
        auto a = pred(r.front);
    }
}

struct RefCounted(T)
{
    T payload;
    ~this() {}
}

struct DirIteratorImpl {}

struct DirIterator
{
    RefCounted!(DirIteratorImpl) impl;
    @property int front(){ return 0; }
}

auto dirEntries()
{
    bool f(int a) { return false; }
    return filter!f(DirIterator());
}
import file;

void main() {
    auto dFiles = dirEntries();
}
Member

klickverbot commented Oct 6, 2012

Getting closer (hopefully for real, this time):

// test.d
template filter(alias pred)
{
    auto filter(Range)(Range rs)
    {
        return FilterResult!(pred, Range)(rs);
    }
}

private struct FilterResult(alias pred, Range)
{
    Range _input;
    this(Range r)
    {
        auto a = pred(r.front);
    }
}

struct RefCounted(T)
{
    T payload;
    ~this() {}
}

struct DirIteratorImpl {}

struct DirIterator
{
    RefCounted!(DirIteratorImpl) impl;
    @property int front(){ return 0; }
}

auto dirEntries()
{
    bool f(int a) { return false; }
    return filter!f(DirIterator());
}
import file;

void main() {
    auto dFiles = dirEntries();
}
@klickverbot

This comment has been minimized.

Show comment Hide comment
@klickverbot

klickverbot Oct 7, 2012

Member

Fixed, at last!

Member

klickverbot commented Oct 7, 2012

Fixed, at last!

redstar pushed a commit that referenced this issue Sep 27, 2014

Merge pull request #131 from jmdavis/time
Moved std.datetime.abs to core.time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment