On Monday, 7 March 2016 at 19:06:54 UTC, Chris Wright wrote:
On Mon, 07 Mar 2016 11:06:13 +0000, ZombineDev wrote:
The compiler should detect that this call is ambiguous and would not allow it.

It's a potentially significant amount of work to determine that the expression is ambiguous, or to disambiguate.

I don't think so. At least not much more than what currently the compiler does for overload resolution (comparing the void(A) overloard to the void(B)). Tuples literals / struct initializer literals / delegates should be classified before the end of the parsing phase (which is actually at least an order of magnitude faster than the semantic phase).

To resolve the ambiguity, the user can write:
foo(A{ x: 1 });

That's why I suggested it.

And you only need explicit type marking at the top level; it's unambiguous after that.

I'm not sure what you mean by "explicit type marking at the top level".

It always is unambiguous to write things like:
  auto a = A{x: {y: 1}};

Ah ok, agreed.


Reply via email to