Skip to content

Commit

Permalink
Specify return type unit fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Nov 16, 2023
1 parent 496ef38 commit 191f803
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3568,6 +3568,15 @@ Closure Expressions
A :t:`closure expression` is an :t:`expression` that defines a
:t:`closure type` and constructs a value of that :t:`type`.

:dp:`fls_UgJgur0z6d4a`
The :t:`return type` of a :t:`closure type` is determined as follows:

* :dp:`fls_af1WL2mBKMfW`
If the :t:`closure expression` specifies a :s:`ClosureBodyWithReturnType`, then the :t:`return type` is the specified :s:`ReturnTypeWithoutBounds`.

* :dp:`fls_wLVeE6cNG8oa`
Otherwise the :t:`return type` is the :t:`type` of the :t:`closure body`.

:dp:`fls_srbl7ptknjyk`
A :t:`closure body` is a :t:`construct` that represents the executable portion
of a :t:`closure expression`.
Expand Down
12 changes: 10 additions & 2 deletions src/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ The :t:`pattern` of a :t:`function parameter` shall be an :t:`irrefutable
pattern`.

:dp:`fls_vljy4mm0zca2`
A :t:`return type` is the :t:`type` of the result a :t:`function` returns.
A :t:`return type` is the :t:`type` of the result a :t:`function`, :t:`closure type` or :t:`function pointer type` returns.

:dp:`fls_EqJb3Jl3vK8K`
The :t:`return type` of a :t:`function` is determined as follows:

* :dp:`fls_C7dvzcXcpQCy`
If the :s:`FunctionDeclaration` specifies a :s:`ReturnType`, then the :t:`return type` is the specified :s:`ReturnType`.

* :dp:`fls_J8X8ahnJLrMo`
Otherwise the :t:`return type` is the :t:`unit type`.

:dp:`fls_927nfm5mkbsp`
A :t:`function body` is the :t:`block expression` of a :t:`function`.
Expand Down Expand Up @@ -183,4 +192,3 @@ program. A :t:`main function` is subject to the following restrictions:
}
fn main() {}
9 changes: 9 additions & 0 deletions src/types-and-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,15 @@ parameters.
A :t:`variadic part` shall be specified only when the :t:`ABI` of the
:t:`function pointer type` is either ``extern "C"`` or ``extern "cdecl"``.

:dp:`fls_g1iYVw7upBnH`
The :t:`return type` of a :t:`function pointer type` is determined as follows:

* :dp:`fls_8gpvNJfVlyaD`
If the :t:`function pointer type` specifies a :s:`ReturnTypeWithoutBounds`, then the :t:`return type` is the specified :s:`ReturnTypeWithoutBounds`.

* :dp:`fls_KcI6yK0P8Onn`
Otherwise the :t:`return type` is the :t:`unit type`.

.. rubric:: Undefined Behavior

:dp:`fls_52thmi9hnoks`
Expand Down

0 comments on commit 191f803

Please sign in to comment.