**Describe the bug** With cppfront from git ecd37263f9b5a71f5beb18affc275d76ee537f9f and g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0: ```c++ pred: (x: int) -> int = x < 20; main: () = { p2 := :(x) -> _ = x < 20; b := 5 is (p2); // true std::cout << b << "\n"; b = 5 is (pred); // false std::cout << b << "\n"; } ``` I expected both `is` expressions to produce `true`, but the second one is `false`. A secondary problem is that rewriting `pred` to be a template fails to compile: ```c++ pred: (x) -> _ = x < 20; ``` ``` lessthan.cpp2:48:17: error: no matching function for call to ‘is(int, <unresolved overloaded function type>)’ ... snip candidates ... ```
Activity
JohelEGP commentedon Sep 18, 2023
The reason seems to be
cppfront/include/cpp2util.h
Line 883 in ecd3726
predreturns anint, sobool{pred(5)}is narrowing, and the requires-expression evaluates tofalse.ntrel commentedon Sep 18, 2023
Oops, thanks! So this definition works:
The remaining problem is if I don't specify a type for
xthen it doesn't compile.filipsajdak commentedon Sep 19, 2023
I am currently working on
isimprovements. I will push it soon.filipsajdak commentedon Sep 19, 2023
OK, I have solved also the generic function case.