Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion error for nested functions #19144

Open
dlangBugzillaToGithub opened this issue Jun 9, 2016 · 4 comments
Open

Assertion error for nested functions #19144

dlangBugzillaToGithub opened this issue Jun 9, 2016 · 4 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

Seb reported this on 2016-06-09T02:39:01Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=16143

CC List

  • basile-z
  • RazvanN

Description

For the following snippet dmd stops with:

dmd: toir.c:249: elem* getEthis(Loc, IRState*, Dsymbol*): Assertion `thisfd->isNested() || thisfd->vthis' failed.

This probably is due to passing the nested function to another function in `transformToInterval`. This snippet is extracted out of context - at that time I successfully used a `struct` template to return multiple functions (tuple didn't work).


```
struct IntervalPoint(S)
{
    S x;
    S tx;
}

IntervalPoint!S intervalPoint(alias f0, S)(S x)
{
    return IntervalPoint!S(x, f0(x));
}

auto transform(alias f0, double c)()
{
    alias t0 = (x) => x + 1;

    struct Functions2D
    {
        alias f0 = t0;
    }

    Functions2D f;
    return f;
}

auto transformToInterval(alias f0, double c, S)(S x)
{
    auto t = transform!(f0, c);
    return intervalPoint!(t.f0)(x);
}

unittest
{
    alias f0 = (x) => x + 1;
    auto t = transformToInterval!(f0, 1.0)(1.0);
}
```
@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2022-11-09T14:49:39Z

I cannot reproduce this. The code compiles fine with the most recent version of master.

@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2022-11-09T14:50:12Z

Argh, forgot to add unittest. Still asserts.

@dlangBugzillaToGithub
Copy link
Author

b2.temp commented on 2022-11-09T18:03:18Z

Do you use an older compiler ? with dmd 2.100.2 there's an error during semantics:

> /tmp/temp_7F6C1D38FB90.d:32:32: Error: function `runnable.__unittest_L35_C1.transformToInterval!(__lambda1, 1.0, double).transformToInterval` cannot get frame pointer to `runnable.__unittest_L35_C1.transform!(__lambda1, 1.0).transform.intervalPoint!(__lambda1, double).intervalPoint`

@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2022-11-10T07:29:12Z

(In reply to Basile-z from comment #3)
> Do you use an older compiler ? with dmd 2.100.2 there's an error during
> semantics:
> 
> > /tmp/temp_7F6C1D38FB90.d:32:32: Error: function `runnable.__unittest_L35_C1.transformToInterval!(__lambda1, 1.0, double).transformToInterval` cannot get frame pointer to `runnable.__unittest_L35_C1.transform!(__lambda1, 1.0).transform.intervalPoint!(__lambda1, double).intervalPoint`

Nope, but I did not use the -unittest switch cause I did not see the unittest.

Anyway, in git master this results in an ice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant