On Wednesday, 5 February 2025 at 01:20:07 UTC, Jonathan M Davis
wrote:
Note that it talks about the "initial inferred return type",
whereas your function doesn't have an initial inferred return
type, because it fails to compile when determining the return
type. So, while the spec doesn't expand
On Tuesday, February 4, 2025 5:53:02 AM MST axricard via Digitalmars-d-learn
wrote:
> Basically the same question than
> https://forum.dlang.org/post/aoltazzfmnztsyatf...@forum.dlang.org
> but with functions/delegates and inferred return types:
>
> ``` D
> interface I {
> bool check();
>
Basically the same question than
https://forum.dlang.org/post/aoltazzfmnztsyatf...@forum.dlang.org
but with functions/delegates and inferred return types:
``` D
interface I {
bool check();
}
class A : I {
bool check() =>true;
}
class B : I {
bool check() =>false;
}
void
On Tuesday, 28 November 2023 at 15:46:18 UTC, Paul Backus wrote:
On Thursday, 23 November 2023 at 19:17:20 UTC, Antonio wrote:
Basically, the ternary conditional ```?:``` result type is not
inferred even if the type returned by the two possibilities
are the same.
**Is it a bug or the expected
On Thursday, 23 November 2023 at 19:17:20 UTC, Antonio wrote:
Basically, the ternary conditional ```?:``` result type is not
inferred even if the type returned by the two possibilities are
the same.
**Is it a bug or the expected behaviour?**
Known bug, first reported in 2009:
https://issues
On Tuesday, 28 November 2023 at 14:10:30 UTC, Dom DiSc wrote:
On Tuesday, 28 November 2023 at 11:01:14 UTC, Antonio wrote:
```d
I aOrB(bool check){
if(check)
return new A();
else
return new B();
}
```
**Is it the expected behaviour for ternary conditional?**
Here the compiler know
On Tuesday, 28 November 2023 at 11:01:14 UTC, Antonio wrote:
```d
I aOrB(bool check){
if(check)
return new A();
else
return new B();
}
```
**Is it the expected behaviour for ternary conditional?**
Here the compiler knows what type to return (from the function
signature).
But the t
On Thursday, 23 November 2023 at 19:17:20 UTC, Antonio wrote:
```d
interface I {
bool check();
}
class A : I {
bool check() =>true;
}
class B : I {
bool check() =>false;
}
I aOrB(bool check) => check ? new A() : new B();
void main()
{
assert( aOrB(true).check );
}
```
```d
interface I {
bool check();
}
class A : I {
bool check() =>true;
}
class B : I {
bool check() =>false;
}
I aOrB(bool check) => check ? new A() : new B();
void main()
{
assert( aOrB(true).check );
}
```
Compiler error:
```d
x.d(11): Error: cannot implicitly conver