mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Fix Issue 23861 - Compiler segmentation fault with ref and alias this (#15133)
This commit is contained in:
parent
0455553f82
commit
01a569d959
2 changed files with 41 additions and 2 deletions
|
@ -1220,7 +1220,7 @@ private bool haveSameThis(FuncDeclaration outerFunc, FuncDeclaration calledFunc)
|
|||
/***************************************
|
||||
* Pull out any properties.
|
||||
*/
|
||||
private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 = null)
|
||||
private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 = null, BinExp saveAtts = null)
|
||||
{
|
||||
//printf("resolvePropertiesX, e1 = %s %s, e2 = %s\n", EXPtoString(e1.op).ptr, e1.toChars(), e2 ? e2.toChars() : null);
|
||||
Loc loc = e1.loc;
|
||||
|
@ -1294,7 +1294,14 @@ private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 =
|
|||
{
|
||||
Expression e = new CallExp(loc, e1);
|
||||
if (e2)
|
||||
{
|
||||
e = new AssignExp(loc, e, e2);
|
||||
if (saveAtts)
|
||||
{
|
||||
(cast(BinExp)e).att1 = saveAtts.att1;
|
||||
(cast(BinExp)e).att2 = saveAtts.att2;
|
||||
}
|
||||
}
|
||||
return e.expressionSemantic(sc);
|
||||
}
|
||||
}
|
||||
|
@ -1412,7 +1419,14 @@ private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 =
|
|||
}
|
||||
Expression e = new CallExp(loc, e1);
|
||||
if (e2)
|
||||
{
|
||||
e = new AssignExp(loc, e, e2);
|
||||
if (saveAtts)
|
||||
{
|
||||
(cast(BinExp)e).att1 = saveAtts.att1;
|
||||
(cast(BinExp)e).att2 = saveAtts.att2;
|
||||
}
|
||||
}
|
||||
return e.expressionSemantic(sc);
|
||||
}
|
||||
}
|
||||
|
@ -9092,7 +9106,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
* or:
|
||||
* f() = value
|
||||
*/
|
||||
if (Expression e = resolvePropertiesX(sc, e1x, exp.e2))
|
||||
if (Expression e = resolvePropertiesX(sc, e1x, exp.e2, exp))
|
||||
return setResult(e);
|
||||
|
||||
if (e1x.checkRightThis(sc))
|
||||
|
|
25
compiler/test/fail_compilation/fail23861.d
Normal file
25
compiler/test/fail_compilation/fail23861.d
Normal file
|
@ -0,0 +1,25 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=23861
|
||||
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail23861.d(24): Error: cannot implicitly convert expression `3` of type `int` to `Foo`
|
||||
---
|
||||
*/
|
||||
|
||||
Foo global;
|
||||
|
||||
struct Foo
|
||||
{
|
||||
ref Foo get()
|
||||
{
|
||||
return global;
|
||||
}
|
||||
alias get this;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
Foo g;
|
||||
g = 3;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue