Bug 16143 – Assertion error for nested functions

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-06-09T02:39:01Z
Last change time
2024-12-13T18:48:26Z
Keywords
backend
Assigned to
No Owner
Creator
Seb
Moved to GitHub: dmd#19144 →

Comments

Comment #0 by greensunny12 — 2016-06-09T02:39:01Z
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); } ```
Comment #1 by razvan.nitu1305 — 2022-11-09T14:49:39Z
I cannot reproduce this. The code compiles fine with the most recent version of master.
Comment #2 by razvan.nitu1305 — 2022-11-09T14:50:12Z
Argh, forgot to add unittest. Still asserts.
Comment #3 by b2.temp — 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`
Comment #4 by razvan.nitu1305 — 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.
Comment #5 by robert.schadek — 2024-12-13T18:48:26Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19144 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB