mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
use isXXX() functions for ReturnStatement semantic
This commit is contained in:
parent
2625a1607c
commit
3ff8eb67a7
1 changed files with 9 additions and 10 deletions
|
@ -2526,10 +2526,9 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
if (fd.fes)
|
||||
fd = fd.fes.func; // fd is now function enclosing foreach
|
||||
|
||||
TypeFunction tf = cast(TypeFunction)fd.type;
|
||||
assert(tf.ty == Tfunction);
|
||||
auto tf = fd.type.isTypeFunction();
|
||||
|
||||
if (rs.exp && rs.exp.op == EXP.variable && (cast(VarExp)rs.exp).var == fd.vresult)
|
||||
if (rs.exp && rs.exp.isVarExp() && rs.exp.isVarExp().var == fd.vresult)
|
||||
{
|
||||
// return vresult;
|
||||
if (sc.fes)
|
||||
|
@ -2617,7 +2616,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
rs.exp.checkSharedAccess(sc, returnSharedRef);
|
||||
|
||||
// for static alias this: https://issues.dlang.org/show_bug.cgi?id=17684
|
||||
if (rs.exp.op == EXP.type)
|
||||
if (rs.exp.isTypeExp())
|
||||
rs.exp = resolveAliasThis(sc, rs.exp);
|
||||
|
||||
rs.exp = resolveProperties(sc, rs.exp);
|
||||
|
@ -2633,14 +2632,14 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
|
||||
// Extract side-effect part
|
||||
rs.exp = Expression.extractLast(rs.exp, e0);
|
||||
if (rs.exp.op == EXP.call)
|
||||
if (rs.exp.isCallExp())
|
||||
rs.exp = valueNoDtor(rs.exp);
|
||||
|
||||
/* Void-return function can have void / noreturn typed expression
|
||||
* on return statement.
|
||||
*/
|
||||
auto texp = rs.exp.type;
|
||||
const convToVoid = texp.ty == Tvoid || texp.ty == Tnoreturn;
|
||||
const convToVoid = texp.ty == Tvoid || texp.isTypeNoreturn();
|
||||
|
||||
if (tbret && tbret.ty == Tvoid || convToVoid)
|
||||
{
|
||||
|
@ -2689,7 +2688,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
{
|
||||
tf.next = rs.exp.type;
|
||||
}
|
||||
else if (tret.ty != Terror && !rs.exp.type.equals(tret))
|
||||
else if (!tret.isTypeError() && !rs.exp.type.equals(tret))
|
||||
{
|
||||
int m1 = rs.exp.type.implicitConvTo(tret);
|
||||
int m2 = tret.implicitConvTo(rs.exp.type);
|
||||
|
@ -2790,7 +2789,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
// Found an actual return value before
|
||||
else if (tf.next.ty != Tvoid && !resType.toBasetype().isTypeNoreturn())
|
||||
{
|
||||
if (tf.next.ty != Terror)
|
||||
if (!tf.next.isTypeError())
|
||||
{
|
||||
error(rs.loc, "mismatched function return type inference of `void` and `%s`", tf.next.toChars());
|
||||
}
|
||||
|
@ -2808,7 +2807,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
|
||||
if (tbret.ty != Tvoid && !resType.isTypeNoreturn()) // if non-void return
|
||||
{
|
||||
if (tbret.ty != Terror)
|
||||
if (!tbret.isTypeError())
|
||||
{
|
||||
if (e0)
|
||||
error(rs.loc, "expected return type of `%s`, not `%s`", tret.toChars(), resType.toChars());
|
||||
|
@ -2902,7 +2901,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
}
|
||||
if (e0)
|
||||
{
|
||||
if (e0.op == EXP.declaration || e0.op == EXP.comma)
|
||||
if (e0.isDeclarationExp() || e0.isCommaExp())
|
||||
{
|
||||
rs.exp = Expression.combine(e0, rs.exp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue