Bug 11230 – [REG2.064a] Inexact mangling for template function literal.
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-11T17:38:00Z
Last change time
2013-10-16T21:27:36Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
deadalnix
Comments
Comment #0 by deadalnix — 2013-10-11T17:38:40Z
Once again, a regression from DMD master (it used to compile).
import std.algorithm;
class A {
A[] as;
}
class B {
A[] as;
}
class C : A {
}
C visit(A a) {
a.as.map!(a => visit);
}
C visit(B b) {
b.as.map!(a => visit);
}
C visit() {
}
output : Assertion failed: (type->ty != Tstruct || ((TypeStruct *)type)->sym == this), function semantic, file struct.c, line 876.
Comment #1 by bugzilla — 2013-10-13T11:33:29Z
With the 2.064 beta:
test.d(14): Error: function test.visit has no return statement, but is expected to return a value of type test.C
which is correct.
Comment #2 by deadalnix — 2013-10-13T12:18:46Z
(In reply to comment #1)
> With the 2.064 beta:
>
> test.d(14): Error: function test.visit has no return statement, but is expected
> to return a value of type test.C
>
> which is correct.
You stopped yourself to the first line. Added a return statement so you won't :
cat test.d
import std.algorithm;
class A {
A[] as;
}
class B {
A[] as;
}
class C : A {
}
C visit(A a) {
a.as.map!(a => visit);
}
C visit(B b) {
b.as.map!(a => visit);
}
C visit() {
return null;
}
./dmd test.d
test.d(15): Error: function test.visit has no return statement, but is expected to return a value of type test.C
./../../phobos/std/algorithm.d(415): Error: struct test.visit.MapResult!(__lambda2, A[]).MapResult failed semantic analysis
./../../phobos/std/algorithm.d(425): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(430): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(436): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(448): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(454): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(459): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(471): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(479): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(496): Error: this for _input needs to be type MapResult not type MapResult!(__lambda2, A[])
./../../phobos/std/algorithm.d(411): Error: template instance test.visit.MapResult!(__lambda2, A[]) error instantiating
test.d(20): instantiated from here: map!(A[])
test.d(20): Error: template instance test.visit.map!((a) => visit).map!(A[]) error instantiating
test.d(19): Error: function test.visit has no return statement, but is expected to return a value of type test.C
Comment #3 by deadalnix — 2013-10-13T12:25:42Z
(In reply to comment #2)
> (In reply to comment #1)
> > With the 2.064 beta:
> >
> > test.d(14): Error: function test.visit has no return statement, but is expected
> > to return a value of type test.C
> >
> > which is correct.
>
> You stopped yourself to the first line. Added a return statement so you won't :
>
> cat test.d
>
> import std.algorithm;
>
> class A {
> A[] as;
> }
>
> class B {
> A[] as;
> }
>
> class C : A {
> }
>
> C visit(A a) {
> a.as.map!(a => visit);
> }
>
> C visit(B b) {
> b.as.map!(a => visit);
> }
>
> C visit() {
> return null;
> }
>
>
> ./dmd test.d
> test.d(15): Error: function test.visit has no return statement, but is expected
> to return a value of type test.C
> ./../../phobos/std/algorithm.d(415): Error: struct
> test.visit.MapResult!(__lambda2, A[]).MapResult failed semantic analysis
> ./../../phobos/std/algorithm.d(425): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(430): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(436): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(448): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(454): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(459): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(471): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(479): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(496): Error: this for _input needs to be type
> MapResult not type MapResult!(__lambda2, A[])
> ./../../phobos/std/algorithm.d(411): Error: template instance
> test.visit.MapResult!(__lambda2, A[]) error instantiating
> test.d(20): instantiated from here: map!(A[])
> test.d(20): Error: template instance test.visit.map!((a) => visit).map!(A[])
> error instantiating
> test.d(19): Error: function test.visit has no return statement, but is expected
> to return a value of type test.C
Ho damned, that is solved, indeed XD Sorry, for the noise.
Correct test case from bug 11249 comment#0.
import std.algorithm;
class A {
A[] as;
}
class B {
A[] as;
}
A visit(A a) {
a.as.map!(a => visit);
return null;
}
A visit(B b) {
b.as.map!(a => visit);
return null;
}
A visit() {
return null;
}
$ ../dmd/src/dmd -c -offail.o fail.d
../dmd/src/../../phobos/std/algorithm.d(415): Error: struct
fail.visit.MapResult!(__lambda2, A[]).MapResult failed semantic analysis
../dmd/src/../../phobos/std/algorithm.d(425): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(430): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(436): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(448): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(454): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(459): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(471): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(479): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(496): Error: this for _input needs to
be type MapResult not type MapResult!(__lambda2, A[])
../dmd/src/../../phobos/std/algorithm.d(411): Error: template instance
fail.visit.MapResult!(__lambda2, A[]) error instantiating
fail.d(18): instantiated from here: map!(A[])
fail.d(18): Error: template instance fail.visit.map!((a) => visit).map!(A[])
error instantiating
Comment #6 by k.hara.pg — 2013-10-13T22:53:28Z
*** Issue 11249 has been marked as a duplicate of this issue. ***
Comment #7 by github-bugzilla — 2013-10-13T23:57:53Z