Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify return type unit fallback #470

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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