@@ -1053,16 +1053,23 @@ void main()
1053
1053
types (basic, user-defined, template) are supported.)
1054
1054
$(LI The lambda function body must contain a single expression
1055
1055
(no return statement) which contains only numeric values,
1056
- manifest constants, enum values and function arguments. If the
1057
- expression contains local variables, function calls or return
1058
- statements, the function is considered uncomparable .)
1056
+ manifest constants, enum values, function arguments and function
1057
+ calls. If the expression contains local variables or return
1058
+ statements, the function is considered incomparable .)
1059
1059
)
1060
1060
1061
1061
$(P If these constraints aren't fulfilled, the function is considered
1062
1062
incomparable and `isSame` returns $(D false).)
1063
1063
1064
1064
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
1065
1065
---
1066
+ int f() { return 2; }
1067
+ void test(alias pred)()
1068
+ {
1069
+ // f() from main is a different function from top-level f()
1070
+ static assert(!__traits(isSame, (int a) => a + f(), pred));
1071
+ }
1072
+
1066
1073
void main()
1067
1074
{
1068
1075
static assert(__traits(isSame, (a, b) => a + b, (c, d) => c + d));
@@ -1074,6 +1081,11 @@ void main()
1074
1081
int b;
1075
1082
static assert(!__traits(isSame, a => a + b, a => a + b));
1076
1083
1084
+ // lambdas calling other functions are comparable
1085
+ int f() { return 3;}
1086
+ static assert(__traits(isSame, a => a + f(), a => a + f()));
1087
+ test!((int a) => a + f())();
1088
+
1077
1089
class A
1078
1090
{
1079
1091
int a;
0 commit comments