documented overload disambiguation [backport] (#18865)
* documented overload disambiguation [backport] * Update doc/manual.rst Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * documented overload disambiguation [backport] * documented overload disambiguation [backport] Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
parent
6cd219c3a3
commit
ca51bb8fd9
1 changed files with 19 additions and 1 deletions
|
|
@ -2708,6 +2708,24 @@ a parameter typed as `untyped` (for unresolved expressions) or the type class
|
||||||
assert toSeq2(items(@[1,2])) == @[1, 2] # but items(@[1,2]) is
|
assert toSeq2(items(@[1,2])) == @[1, 2] # but items(@[1,2]) is
|
||||||
|
|
||||||
|
|
||||||
|
Overload disambiguation
|
||||||
|
=======================
|
||||||
|
|
||||||
|
For routine calls "overload resolution" is performed. There is a weaker form of
|
||||||
|
overload resolution called *overload disambiguation* that is performed when an
|
||||||
|
overloaded symbol is used in a context where there is additional type information
|
||||||
|
available. Let `p` be an overloaded symbol. These contexts are:
|
||||||
|
|
||||||
|
- In a function call `q(..., p, ...)` when the corresponding formal parameter
|
||||||
|
of `q` is a `proc` type. If `q` itself is overloaded then the cartesian product
|
||||||
|
of every interpretation of `q` and `p` must be considered.
|
||||||
|
- In an object constructor `Obj(..., field: p, ...)` when `field` is a `proc`
|
||||||
|
type. Analogous rules exist for array/set/tuple constructors.
|
||||||
|
- In a declaration like `x: T = p` when `T` is a `proc` type.
|
||||||
|
|
||||||
|
As usual, ambiguous matches produce a compile-time error.
|
||||||
|
|
||||||
|
|
||||||
Statements and expressions
|
Statements and expressions
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue