diff --git a/changelog/dmd.error-messages.dd b/changelog/dmd.error-messages.dd index 2d3ce440b10..927aca53c1c 100644 --- a/changelog/dmd.error-messages.dd +++ b/changelog/dmd.error-messages.dd @@ -30,7 +30,12 @@ Error: `app.bar` called with argument types `(string)` matches multiple overload */ --- -When there's no index / slice operator overload found for a type, a new supplemental message suggests where to implement it. +Error messages related to operator overloading have been improved. +When the related template functions (`opUnary`, `opBinary`, `opBinaryRight`, `opOpAssign`, `opIndex`, `opSlice`) +are missing, a suggestion to implement them is given. + +When they do exist but fail to instantiate, the error from instantiation is shown. +There's no longer a need to manually e.g. rewrite `s + 1` to `s.opBinary!"+"(1)` to diagnose the error. --- struct S {} @@ -53,9 +58,6 @@ app.d(1): perhaps define `auto opSlice(int lower, string upper) {}` for ` */ --- -When overloading binary operators, and `opBinary`, `opBinaryRight` or `opOpAssign` is missing / fails to instantiate, -the error message now points out the problem: - --- struct Str {} diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 7e9c95b9a9f..0f19607b9ab 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -8857,9 +8857,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor result = exp.incompatibleTypes(); return; } - if (exp.e1.checkNoBool()) - return setError(); - if (exp.e1.checkArithmetic(exp.op) || + if (exp.e1.checkNoBool() || + exp.e1.checkArithmetic(exp.op) || exp.e1.checkSharedAccess(sc)) return setError(); @@ -8885,11 +8884,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor result = exp.incompatibleTypes(); return; } - if (exp.e1.checkNoBool()) - return setError(); - if (exp.e1.checkArithmetic(exp.op)) - return setError(); - if (exp.e1.checkSharedAccess(sc)) + + if (exp.e1.checkNoBool() || + exp.e1.checkArithmetic(exp.op) || + exp.e1.checkSharedAccess(sc)) return setError(); result = exp.e1; @@ -8922,9 +8920,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor result = exp.incompatibleTypes(); return; } - if (exp.e1.checkNoBool()) - return setError(); - if (exp.e1.checkIntegral() || + if (exp.e1.checkNoBool() || + exp.e1.checkIntegral() || exp.e1.checkSharedAccess(sc)) return setError(); diff --git a/compiler/src/dmd/opover.d b/compiler/src/dmd/opover.d index 7607a0be06b..185e5861684 100644 --- a/compiler/src/dmd/opover.d +++ b/compiler/src/dmd/opover.d @@ -293,6 +293,16 @@ Expression opOverloadUnary(UnaExp e, Scope* sc) } break; } + + // For ++ and --, rewrites to += and -= are also tried, so don't error yet + if (!e.isPreExp()) + { + error(e.loc, "operator `%s` is not defined for `%s`", EXPtoString(e.op).ptr, ad.toChars()); + errorSupplemental(ad.loc, "perhaps overload the operator with `auto opUnary(string op : \"%s\")() {}`", + EXPtoString(e.op).ptr); + return ErrorExp.get(); + } + break; } return result; diff --git a/compiler/test/fail_compilation/dep_d1_ops.d b/compiler/test/fail_compilation/dep_d1_ops.d index 8d800b42a65..83e700632a8 100644 --- a/compiler/test/fail_compilation/dep_d1_ops.d +++ b/compiler/test/fail_compilation/dep_d1_ops.d @@ -2,163 +2,172 @@ REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dep_d1_ops.d(272): Error: operator `+` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` -fail_compilation/dep_d1_ops.d(273): Error: operator `+` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` -fail_compilation/dep_d1_ops.d(274): Error: operator `-` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` -fail_compilation/dep_d1_ops.d(275): Error: operator `-` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` -fail_compilation/dep_d1_ops.d(276): Error: operator `*` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` -fail_compilation/dep_d1_ops.d(277): Error: operator `*` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` -fail_compilation/dep_d1_ops.d(278): Error: operator `/` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` -fail_compilation/dep_d1_ops.d(279): Error: operator `/` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` -fail_compilation/dep_d1_ops.d(280): Error: operator `%` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` -fail_compilation/dep_d1_ops.d(281): Error: operator `%` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` -fail_compilation/dep_d1_ops.d(283): Error: operator `&` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` -fail_compilation/dep_d1_ops.d(284): Error: operator `|` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "|")(int rhs) {}` -fail_compilation/dep_d1_ops.d(285): Error: operator `^` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "^")(int rhs) {}` -fail_compilation/dep_d1_ops.d(287): Error: operator `<<` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` -fail_compilation/dep_d1_ops.d(288): Error: operator `<<` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` -fail_compilation/dep_d1_ops.d(289): Error: operator `>>` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(290): Error: operator `>>` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(291): Error: operator `>>>` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(292): Error: operator `>>>` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(294): Error: operator `~` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` -fail_compilation/dep_d1_ops.d(295): Error: operator `~` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` -fail_compilation/dep_d1_ops.d(297): Error: operator `+` is not defined for `s` of type `S` -fail_compilation/dep_d1_ops.d(298): Error: operator `-` is not defined for `s` of type `S` -fail_compilation/dep_d1_ops.d(299): Error: `s` is not of integral type, it is a `S` -fail_compilation/dep_d1_ops.d(300): Error: operator `++` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}` -fail_compilation/dep_d1_ops.d(301): Error: operator `--` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opUnary(string op : "--")() {}` or `auto opOpAssign(string op : "-")(int) {}` -fail_compilation/dep_d1_ops.d(302): Error: can only `*` a pointer, not a `S` -fail_compilation/dep_d1_ops.d(304): Error: operator `in` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` -fail_compilation/dep_d1_ops.d(305): Error: operator `in` is not defined for type `S` -fail_compilation/dep_d1_ops.d(165): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` -fail_compilation/dep_d1_ops.d(307): Error: operator `+=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "+")(int) {}` -fail_compilation/dep_d1_ops.d(308): Error: operator `-=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "-")(int) {}` -fail_compilation/dep_d1_ops.d(309): Error: operator `*=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "*")(int) {}` -fail_compilation/dep_d1_ops.d(310): Error: operator `/=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "/")(int) {}` -fail_compilation/dep_d1_ops.d(311): Error: operator `%=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "%")(int) {}` -fail_compilation/dep_d1_ops.d(312): Error: operator `&=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "&")(int) {}` -fail_compilation/dep_d1_ops.d(313): Error: operator `|=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "|")(int) {}` -fail_compilation/dep_d1_ops.d(314): Error: operator `^=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "^")(int) {}` -fail_compilation/dep_d1_ops.d(315): Error: operator `<<=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "<<")(int) {}` -fail_compilation/dep_d1_ops.d(316): Error: operator `>>=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : ">>")(int) {}` -fail_compilation/dep_d1_ops.d(317): Error: operator `>>>=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : ">>>")(int) {}` -fail_compilation/dep_d1_ops.d(318): Error: operator `~=` not supported for `s` of type `S` -fail_compilation/dep_d1_ops.d(165): perhaps implement `auto opOpAssign(string op : "~")(int) {}` -fail_compilation/dep_d1_ops.d(322): Error: operator `+` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` -fail_compilation/dep_d1_ops.d(323): Error: operator `+` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` -fail_compilation/dep_d1_ops.d(324): Error: operator `-` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` -fail_compilation/dep_d1_ops.d(325): Error: operator `-` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` -fail_compilation/dep_d1_ops.d(326): Error: operator `*` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` -fail_compilation/dep_d1_ops.d(327): Error: operator `*` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` -fail_compilation/dep_d1_ops.d(328): Error: operator `/` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` -fail_compilation/dep_d1_ops.d(329): Error: operator `/` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` -fail_compilation/dep_d1_ops.d(330): Error: operator `%` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` -fail_compilation/dep_d1_ops.d(331): Error: operator `%` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` -fail_compilation/dep_d1_ops.d(333): Error: operator `&` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` -fail_compilation/dep_d1_ops.d(334): Error: operator `|` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "|")(int rhs) {}` -fail_compilation/dep_d1_ops.d(335): Error: operator `^` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "^")(int rhs) {}` -fail_compilation/dep_d1_ops.d(337): Error: operator `<<` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` -fail_compilation/dep_d1_ops.d(338): Error: operator `<<` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` -fail_compilation/dep_d1_ops.d(339): Error: operator `>>` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(340): Error: operator `>>` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(341): Error: operator `>>>` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(342): Error: operator `>>>` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` -fail_compilation/dep_d1_ops.d(344): Error: operator `~` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` -fail_compilation/dep_d1_ops.d(345): Error: operator `~` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` -fail_compilation/dep_d1_ops.d(347): Error: operator `+` is not defined for `c` of type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(348): Error: operator `-` is not defined for `c` of type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(349): Error: `c` is not of integral type, it is a `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(350): Error: operator `++` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}` -fail_compilation/dep_d1_ops.d(351): Error: operator `--` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opUnary(string op : "--")() {}` or `auto opOpAssign(string op : "-")(int) {}` -fail_compilation/dep_d1_ops.d(352): Error: can only `*` a pointer, not a `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(354): Error: operator `in` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` -fail_compilation/dep_d1_ops.d(355): Error: operator `in` is not defined for type `dep_d1_ops.C` -fail_compilation/dep_d1_ops.d(216): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` -fail_compilation/dep_d1_ops.d(357): Error: operator `+=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "+")(int) {}` -fail_compilation/dep_d1_ops.d(358): Error: operator `-=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "-")(int) {}` -fail_compilation/dep_d1_ops.d(359): Error: operator `*=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "*")(int) {}` -fail_compilation/dep_d1_ops.d(360): Error: operator `/=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "/")(int) {}` -fail_compilation/dep_d1_ops.d(361): Error: operator `%=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "%")(int) {}` -fail_compilation/dep_d1_ops.d(362): Error: operator `&=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "&")(int) {}` -fail_compilation/dep_d1_ops.d(363): Error: operator `|=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "|")(int) {}` -fail_compilation/dep_d1_ops.d(364): Error: operator `^=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "^")(int) {}` -fail_compilation/dep_d1_ops.d(365): Error: operator `<<=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "<<")(int) {}` -fail_compilation/dep_d1_ops.d(366): Error: operator `>>=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : ">>")(int) {}` -fail_compilation/dep_d1_ops.d(367): Error: operator `>>>=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : ">>>")(int) {}` -fail_compilation/dep_d1_ops.d(368): Error: operator `~=` not supported for `c` of type `C` -fail_compilation/dep_d1_ops.d(216): perhaps implement `auto opOpAssign(string op : "~")(int) {}` -fail_compilation/dep_d1_ops.d(377): Error: `nd` is not of integral type, it is a `dep_d1_ops.NoDeprecation` +fail_compilation/dep_d1_ops.d(281): Error: operator `+` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` +fail_compilation/dep_d1_ops.d(282): Error: operator `+` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` +fail_compilation/dep_d1_ops.d(283): Error: operator `-` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` +fail_compilation/dep_d1_ops.d(284): Error: operator `-` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` +fail_compilation/dep_d1_ops.d(285): Error: operator `*` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` +fail_compilation/dep_d1_ops.d(286): Error: operator `*` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` +fail_compilation/dep_d1_ops.d(287): Error: operator `/` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` +fail_compilation/dep_d1_ops.d(288): Error: operator `/` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` +fail_compilation/dep_d1_ops.d(289): Error: operator `%` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` +fail_compilation/dep_d1_ops.d(290): Error: operator `%` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` +fail_compilation/dep_d1_ops.d(292): Error: operator `&` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` +fail_compilation/dep_d1_ops.d(293): Error: operator `|` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "|")(int rhs) {}` +fail_compilation/dep_d1_ops.d(294): Error: operator `^` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "^")(int rhs) {}` +fail_compilation/dep_d1_ops.d(296): Error: operator `<<` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` +fail_compilation/dep_d1_ops.d(297): Error: operator `<<` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` +fail_compilation/dep_d1_ops.d(298): Error: operator `>>` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(299): Error: operator `>>` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(300): Error: operator `>>>` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(301): Error: operator `>>>` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(303): Error: operator `~` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` +fail_compilation/dep_d1_ops.d(304): Error: operator `~` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` +fail_compilation/dep_d1_ops.d(306): Error: operator `+` is not defined for `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "+")() {}` +fail_compilation/dep_d1_ops.d(307): Error: operator `-` is not defined for `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "-")() {}` +fail_compilation/dep_d1_ops.d(308): Error: operator `~` is not defined for `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "~")() {}` +fail_compilation/dep_d1_ops.d(309): Error: operator `++` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}` +fail_compilation/dep_d1_ops.d(310): Error: operator `--` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opUnary(string op : "--")() {}` or `auto opOpAssign(string op : "-")(int) {}` +fail_compilation/dep_d1_ops.d(311): Error: operator `*` is not defined for `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "*")() {}` +fail_compilation/dep_d1_ops.d(313): Error: operator `in` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` +fail_compilation/dep_d1_ops.d(314): Error: operator `in` is not defined for type `S` +fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` +fail_compilation/dep_d1_ops.d(316): Error: operator `+=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "+")(int) {}` +fail_compilation/dep_d1_ops.d(317): Error: operator `-=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "-")(int) {}` +fail_compilation/dep_d1_ops.d(318): Error: operator `*=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "*")(int) {}` +fail_compilation/dep_d1_ops.d(319): Error: operator `/=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "/")(int) {}` +fail_compilation/dep_d1_ops.d(320): Error: operator `%=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "%")(int) {}` +fail_compilation/dep_d1_ops.d(321): Error: operator `&=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "&")(int) {}` +fail_compilation/dep_d1_ops.d(322): Error: operator `|=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "|")(int) {}` +fail_compilation/dep_d1_ops.d(323): Error: operator `^=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "^")(int) {}` +fail_compilation/dep_d1_ops.d(324): Error: operator `<<=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "<<")(int) {}` +fail_compilation/dep_d1_ops.d(325): Error: operator `>>=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : ">>")(int) {}` +fail_compilation/dep_d1_ops.d(326): Error: operator `>>>=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : ">>>")(int) {}` +fail_compilation/dep_d1_ops.d(327): Error: operator `~=` not supported for `s` of type `S` +fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "~")(int) {}` +fail_compilation/dep_d1_ops.d(331): Error: operator `+` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` +fail_compilation/dep_d1_ops.d(332): Error: operator `+` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` +fail_compilation/dep_d1_ops.d(333): Error: operator `-` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` +fail_compilation/dep_d1_ops.d(334): Error: operator `-` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` +fail_compilation/dep_d1_ops.d(335): Error: operator `*` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` +fail_compilation/dep_d1_ops.d(336): Error: operator `*` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` +fail_compilation/dep_d1_ops.d(337): Error: operator `/` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` +fail_compilation/dep_d1_ops.d(338): Error: operator `/` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` +fail_compilation/dep_d1_ops.d(339): Error: operator `%` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` +fail_compilation/dep_d1_ops.d(340): Error: operator `%` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` +fail_compilation/dep_d1_ops.d(342): Error: operator `&` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` +fail_compilation/dep_d1_ops.d(343): Error: operator `|` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "|")(int rhs) {}` +fail_compilation/dep_d1_ops.d(344): Error: operator `^` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "^")(int rhs) {}` +fail_compilation/dep_d1_ops.d(346): Error: operator `<<` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` +fail_compilation/dep_d1_ops.d(347): Error: operator `<<` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` +fail_compilation/dep_d1_ops.d(348): Error: operator `>>` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(349): Error: operator `>>` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(350): Error: operator `>>>` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(351): Error: operator `>>>` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` +fail_compilation/dep_d1_ops.d(353): Error: operator `~` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` +fail_compilation/dep_d1_ops.d(354): Error: operator `~` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` +fail_compilation/dep_d1_ops.d(356): Error: operator `+` is not defined for `C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "+")() {}` +fail_compilation/dep_d1_ops.d(357): Error: operator `-` is not defined for `C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "-")() {}` +fail_compilation/dep_d1_ops.d(358): Error: operator `~` is not defined for `C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "~")() {}` +fail_compilation/dep_d1_ops.d(359): Error: operator `++` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}` +fail_compilation/dep_d1_ops.d(360): Error: operator `--` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opUnary(string op : "--")() {}` or `auto opOpAssign(string op : "-")(int) {}` +fail_compilation/dep_d1_ops.d(361): Error: operator `*` is not defined for `C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "*")() {}` +fail_compilation/dep_d1_ops.d(363): Error: operator `in` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` +fail_compilation/dep_d1_ops.d(364): Error: operator `in` is not defined for type `dep_d1_ops.C` +fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` +fail_compilation/dep_d1_ops.d(366): Error: operator `+=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "+")(int) {}` +fail_compilation/dep_d1_ops.d(367): Error: operator `-=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "-")(int) {}` +fail_compilation/dep_d1_ops.d(368): Error: operator `*=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "*")(int) {}` +fail_compilation/dep_d1_ops.d(369): Error: operator `/=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "/")(int) {}` +fail_compilation/dep_d1_ops.d(370): Error: operator `%=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "%")(int) {}` +fail_compilation/dep_d1_ops.d(371): Error: operator `&=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "&")(int) {}` +fail_compilation/dep_d1_ops.d(372): Error: operator `|=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "|")(int) {}` +fail_compilation/dep_d1_ops.d(373): Error: operator `^=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "^")(int) {}` +fail_compilation/dep_d1_ops.d(374): Error: operator `<<=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "<<")(int) {}` +fail_compilation/dep_d1_ops.d(375): Error: operator `>>=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : ">>")(int) {}` +fail_compilation/dep_d1_ops.d(376): Error: operator `>>>=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : ">>>")(int) {}` +fail_compilation/dep_d1_ops.d(377): Error: operator `~=` not supported for `c` of type `C` +fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "~")(int) {}` +fail_compilation/dep_d1_ops.d(386): Error: operator `~` is not defined for `NoDeprecation` +fail_compilation/dep_d1_ops.d(390): perhaps overload the operator with `auto opUnary(string op : "~")() {}` --- */ diff --git a/compiler/test/fail_compilation/operator_undefined.d b/compiler/test/fail_compilation/operator_undefined.d index 3065bdb8e79..1c9803d21ee 100644 --- a/compiler/test/fail_compilation/operator_undefined.d +++ b/compiler/test/fail_compilation/operator_undefined.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/operator_undefined.d(19): Error: operator `-` is not defined for `toJson(2)` of type `Json` +fail_compilation/operator_undefined.d(20): Error: operator `-` is not defined for `Json` +fail_compilation/operator_undefined.d(11): perhaps overload the operator with `auto opUnary(string op : "-")() {}` --- */