mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Short-circuit checkArithmeticBin when lhs is an error
This commit is contained in:
parent
8358e6d33f
commit
279f3054bf
6 changed files with 23 additions and 28 deletions
|
@ -4144,9 +4144,6 @@ Expression typeCombine(BinExp be, Scope* sc)
|
||||||
return ErrorExp.get();
|
return ErrorExp.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Type t1 = be.e1.type.toBasetype();
|
|
||||||
Type t2 = be.e2.type.toBasetype();
|
|
||||||
|
|
||||||
if (auto result = typeMerge(sc, be.op, be.e1, be.e2))
|
if (auto result = typeMerge(sc, be.op, be.e1, be.e2))
|
||||||
{
|
{
|
||||||
if (be.type is null)
|
if (be.type is null)
|
||||||
|
|
|
@ -592,6 +592,13 @@ extern (C++) abstract class Expression : ASTNode
|
||||||
error(loc, msg, EXPtoString(op).ptr, toChars(), type.toChars());
|
error(loc, msg, EXPtoString(op).ptr, toChars(), type.toChars());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Existing code relies on adding / subtracting types in typeof() expressions:
|
||||||
|
// alias I = ulong; alias U = typeof(I + 1u);
|
||||||
|
// https://github.com/dlang/dmd/issues/20763
|
||||||
|
if (op == EXP.add || op == EXP.min)
|
||||||
|
return false;
|
||||||
|
|
||||||
return checkValue();
|
return checkValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3067,9 +3074,7 @@ extern (C++) abstract class BinExp : Expression
|
||||||
|
|
||||||
extern (D) final bool checkArithmeticBin()
|
extern (D) final bool checkArithmeticBin()
|
||||||
{
|
{
|
||||||
bool r1 = e1.checkArithmetic(this.op);
|
return e1.checkArithmetic(this.op) || e2.checkArithmetic(this.op);
|
||||||
bool r2 = e2.checkArithmetic(this.op);
|
|
||||||
return (r1 || r2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/fail10534.d(28): Error: illegal operator `+` for `a` of type `int delegate()`
|
fail_compilation/fail10534.d(24): Error: illegal operator `+` for `a` of type `int delegate()`
|
||||||
fail_compilation/fail10534.d(28): Error: illegal operator `+` for `b` of type `int delegate()`
|
fail_compilation/fail10534.d(24): Error: illegal operator `+` for `b` of type `int delegate()`
|
||||||
fail_compilation/fail10534.d(29): Error: illegal operator `-` for `a` of type `int delegate()`
|
fail_compilation/fail10534.d(25): Error: illegal operator `-` for `a` of type `int delegate()`
|
||||||
fail_compilation/fail10534.d(29): Error: illegal operator `-` for `b` of type `int delegate()`
|
fail_compilation/fail10534.d(25): Error: illegal operator `-` for `b` of type `int delegate()`
|
||||||
fail_compilation/fail10534.d(30): Error: illegal operator `/` for `a` of type `int delegate()`
|
fail_compilation/fail10534.d(26): Error: illegal operator `/` for `a` of type `int delegate()`
|
||||||
fail_compilation/fail10534.d(30): Error: illegal operator `/` for `b` of type `int delegate()`
|
fail_compilation/fail10534.d(27): Error: illegal operator `*` for `a` of type `int delegate()`
|
||||||
fail_compilation/fail10534.d(31): Error: illegal operator `*` for `a` of type `int delegate()`
|
fail_compilation/fail10534.d(32): Error: illegal operator `+` for `a` of type `int function()`
|
||||||
fail_compilation/fail10534.d(31): Error: illegal operator `*` for `b` of type `int delegate()`
|
fail_compilation/fail10534.d(32): Error: illegal operator `+` for `b` of type `int function()`
|
||||||
fail_compilation/fail10534.d(36): Error: illegal operator `+` for `a` of type `int function()`
|
fail_compilation/fail10534.d(33): Error: illegal operator `-` for `a` of type `int function()`
|
||||||
fail_compilation/fail10534.d(36): Error: illegal operator `+` for `b` of type `int function()`
|
fail_compilation/fail10534.d(33): Error: illegal operator `-` for `b` of type `int function()`
|
||||||
fail_compilation/fail10534.d(37): Error: illegal operator `-` for `a` of type `int function()`
|
fail_compilation/fail10534.d(34): Error: illegal operator `/` for `a` of type `int function()`
|
||||||
fail_compilation/fail10534.d(37): Error: illegal operator `-` for `b` of type `int function()`
|
fail_compilation/fail10534.d(35): Error: illegal operator `*` for `a` of type `int function()`
|
||||||
fail_compilation/fail10534.d(38): Error: illegal operator `/` for `a` of type `int function()`
|
|
||||||
fail_compilation/fail10534.d(38): Error: illegal operator `/` for `b` of type `int function()`
|
|
||||||
fail_compilation/fail10534.d(39): Error: illegal operator `*` for `a` of type `int function()`
|
|
||||||
fail_compilation/fail10534.d(39): Error: illegal operator `*` for `b` of type `int function()`
|
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/fail11445.d(12): Error: illegal operator `+` for `a` of type `double[string]`
|
fail_compilation/fail11445.d(11): Error: illegal operator `+` for `a` of type `double[string]`
|
||||||
fail_compilation/fail11445.d(12): Error: illegal operator `+` for `b` of type `double[string]`
|
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/fail297.d(31): Error: operator `+` is not defined for `Bar()` of type `Bar`
|
fail_compilation/fail297.d(30): Error: operator `+` is not defined for `Bar()` of type `Bar`
|
||||||
fail_compilation/fail297.d(31): Error: operator `+` is not defined for `baz()` of type `const(Bar)`
|
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/fail3.d(42): Error: operator `+` is not defined for `a` of type `vec2`
|
fail_compilation/fail3.d(41): Error: operator `+` is not defined for `a` of type `vec2`
|
||||||
fail_compilation/fail3.d(42): Error: operator `+` is not defined for `b` of type `vec2`
|
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue